PVS-StudioWarnings

PVS-Studio warning V610 for lib7z

Nov 18th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. SZ_RESULT SafeReadDirectUInt64(ISzInStream *inStream,
  2.                                UInt64 *value)
  3. {
  4.   int i;
  5.   *value = 0;
  6.   for (i = 0; i < 8; i++)
  7.   {
  8.     Byte b;
  9.     RINOK(SafeReadDirectByte(inStream, &b));
  10.     *value |= ((UInt32)b << (8 * i));
  11.   }
  12.   return SZ_OK;
  13. }
  14.  
  15. This suspicious code was found in lib7z project by PVS-Studio static code analyzer.
  16. Warning message is:
  17. V610 Undefined behavior. Check the shift operator '<<. The right operand ('(8 * i)' = [0..56]) is greater than or equal to the length in bits of the promoted left operand. lib7z 7zin.c 233
  18.  
  19. PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment