C++ Logo

sg12

Advanced search

Re: [ub] ub due to left operand of shift

From: John Regehr <regehr_at_[hidden]>
Date: Thu, 24 Oct 2013 16:51:53 -0600
> What reason do you have to believe that crypto is using any signed
> arithmetic? I would not.

Below is mhash-0.9.9.9. I don't know much about crypto code but I
suspect this usage is common.

Chandler is not (I think) talking about breaking the behaviors below,
but even so, I'd be afraid to turn on optimizations that exploit
undefined signed left shifts for a code base I didn't own, and hadn't
vetted extensively.

John



ripemd.c:931:13: runtime error: left shift of 8421504 by 8 places cannot
be represented in type 'int'
.ripemd.c:983:13: runtime error: left shift of 8414050 by 8 places
cannot be represented in type 'int'
sha1.c:265:13: runtime error: left shift of 8421504 by 8 places cannot
be represented in type 'int'
.sha1.c:326:13: runtime error: left shift of 8388608 by 8 places cannot
be represented in type 'int'
sha1.c:326:13: runtime error: left shift of 8388608 by 8 places cannot
be represented in type 'int'
sha256_sha224.c:237:13: runtime error: left shift of 8421504 by 8 places
cannot be represented in type 'int'
.sha256_sha224.c:298:13: runtime error: left shift of 8388608 by 8
places cannot be represented in type 'int'
sha256_sha224.c:298:13: runtime error: left shift of 8388608 by 8 places
cannot be represented in type 'int'
stdfns.c:175:12: runtime error: left shift of 128 by 24 places cannot be
represented in type 'int'

Received on 2013-10-25 00:52:10