PVS-StudioWarnings

PVS-Studio warning V512 for ACE

Nov 21st, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. struct Message
  2. {
  3.   unsigned int sn;
  4.   unsigned short payload[payload_size];
  5. };
  6.  
  7. int
  8. ACE_TMAIN (int argc, ACE_TCHAR* argv[])
  9. {
  10.   ...
  11.   if (ACE_OS::memcmp (expected_msg.payload,
  12.                       msg.payload,
  13.                       payload_size) != 0)
  14.   {
  15.     damaged[msg.sn] = 1;
  16.   }
  17.   ...
  18. }
  19.  
  20. Most likely this is what should be written here: payload_size * sizeof(short)
  21.  
  22.  
  23. This suspicious code was found in ACE project by PVS-Studio static code analyzer.
  24. Warning message is:
  25. V512 A call of the 'memcmp' function will lead to underflow of the buffer 'expected_msg.payload'. Send_Msg_Receiver receiver.cpp 109
  26.  
  27. 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