PVS-StudioWarnings

PVS-Studio warning V512 for MAME

Nov 18th, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #define CHD_SHA1_BYTES    20
  2. #define CHD_V4_HEADER_SIZE   108
  3. #define CHD_MAX_HEADER_SIZE   CHD_V4_HEADER_SIZE
  4.  
  5. static chd_error header_read(...., chd_header *header)
  6. {
  7.   UINT8 rawheader[CHD_MAX_HEADER_SIZE];
  8.   ...
  9.   memcpy(header->parentsha1, &rawheader[100],
  10.          CHD_SHA1_BYTES);
  11.   ...
  12. }
  13.  
  14. This suspicious code was found in MAME project by PVS-Studio static code analyzer.
  15. Warning message is:
  16. V512 A call of the 'memcpy' function will lead to the '& rawheader[100]' buffer becoming out of range.  chd.c 1870
  17.  
  18. 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