PRJosh / lz4

Automatically exported from code.google.com/p/lz4
0 stars 0 forks source link

Potential Size Extension Problem in LZ4F_readLE64 #160

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Our static analyzer (Coverity) is complaining about the following line in 
lz4frame.c:

     value64 += (srcPtr[3]<<24);

saying that the compiler will promote the rhs to a signed 32-bit integer with 
potential sign extension.  Should probably cast this with something like:

     value64 += ((U64)srcPtr[3]<<24);

Original issue reported on code.google.com by ericmbe...@gmail.com on 1 Apr 2015 at 3:39

GoogleCodeExporter commented 9 years ago
Thanks Eric

Good point.
srcPtr[3] being an unsigned byte, I naively expected the (srcPtr[3]<<24) 
operation to be completed on an unsigned 32 bits integer. But you are right, 
there is no guarantee. Quite a pity scan-build static analyzer did not find 
it...

I'll correct it

Original comment by yann.col...@gmail.com on 1 Apr 2015 at 4:23

GoogleCodeExporter commented 9 years ago
Moved to github :
https://github.com/Cyan4973/lz4/issues/70

Original comment by yann.col...@gmail.com on 1 Apr 2015 at 4:33

GoogleCodeExporter commented 9 years ago
Sorry about the dup, I had posted the first one before recognizing the move
to github and thought I needed to repost it there. But apparently not!

Original comment by ericmbe...@gmail.com on 1 Apr 2015 at 4:38

GoogleCodeExporter commented 9 years ago
no pb, you're welcomed ;)

Original comment by yann.col...@gmail.com on 1 Apr 2015 at 4:40