[ub] ub due to left operand of shift

John Regehr regehr at cs.utah.edu
Fri Oct 25 00:25:59 CEST 2013


>> Well, my guess is that Unisys has already been forced to implement two's
>> complement signed shifts since the alternative would almost certainly
>> break shifty applications like crpyto.
>
> What reason do you have to believe that crypto is using any signed
> arithmetic?  I would not.

Challenge accepted.  Below are the errors from a "make test" of today's 
OpenSSL snapshot using clang -fsanitize=undefined.

John


[regehr at dyson openssl-SNAP-20131024]$ grep 'runtime error' test.out | 
sort | uniq  | grep -v misalign
a_int.c:397:4: runtime error: left shift of 46242800822734955 by 8 
places cannot be represented in type 'long'
a_int.c:397:4: runtime error: left shift of 46549952932846891 by 8 
places cannot be represented in type 'long'
a_int.c:397:4: runtime error: left shift of 49332614088637912 by 8 
places cannot be represented in type 'long'
...b5242888/5242888.gost_crypt.c:244:49: runtime error: left shift of 
203 by 24 places cannot be represented in type 'int'
c_enc.c:107:6: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:112:2: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:113:2: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:114:2: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:118:2: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:120:2: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:71:2: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:72:2: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:73:2: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:74:2: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:75:2: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:76:2: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:77:2: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:78:2: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:79:2: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:80:2: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:81:2: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:82:2: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:85:6: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:86:6: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:87:6: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
c_enc.c:88:6: runtime error: shift exponent 32 is too large for 32-bit 
type 'unsigned int'
eng_table.c:349:2: runtime error: member access within null pointer of 
type 'ENGINE_TABLE' (aka 'struct st_engine_table')
gost89.c:123:48: runtime error: left shift of 173 by 24 places cannot be 
represented in type 'int'
gost89.c:143:42: runtime error: left shift of 130 by 24 places cannot be 
represented in type 'int'
gost89.c:144:42: runtime error: left shift of 192 by 24 places cannot be 
represented in type 'int'
.gost89.c:176:42: runtime error: left shift of 150 by 24 places cannot 
be represented in type 'int'
gost89.c:177:42: runtime error: left shift of 196 by 24 places cannot be 
represented in type 'int'
gost89.c:278:48: runtime error: left shift of 139 by 24 places cannot be 
represented in type 'int'
gost89.c:327:58: runtime error: left shift of 246 by 24 places cannot be 
represented in type 'int'
gost_crypt.c:250:49: runtime error: left shift of 166 by 24 places 
cannot be represented in type 'int'
obj_dat.c:143:15: runtime error: left shift of 2 by 30 places cannot be 
represented in type 'int'
s3_srvr.c:1886:13: runtime error: index 4 out of bounds for type 'BIGNUM 
*[4]'
         Serial Number:a_int.c:397:4: runtime error: left shift of 
46925722314542435 by 8 places cannot be represented in type 'long'
Testing GOST 28147-89 ..gost89.c:326:58: runtime error: left shift of 
227 by 24 places cannot be represented in type 'int'
This test will take some time....c_enc.c:75:2: runtime error: shift 
exponent 32 is too large for 32-bit type 'unsigned int'


More information about the ub mailing list