PVS-StudioWarnings

PVS-Studio warning V547 for UltimateTCPIP

Nov 26th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. void CUT_StrMethods::RemoveSpaces(LPSTR szString) {
  2.   ...
  3.   size_t loop, len = strlen(szString);
  4.   // Remove the trailing spaces
  5.   for(loop = (len-1); loop >= 0; loop--) {
  6.     if(szString[loop] != ' ')
  7.       break;
  8.   }
  9.   ...
  10. }
  11.  
  12. An example of vulnerability. If a string contains only blanks, an array overrun will occur.
  13.  
  14.  
  15. This suspicious code was found in UltimateTCPIP project by PVS-Studio static code analyzer.
  16. Warning message is:
  17. V547 Expression 'loop >= 0' is always true. Unsigned type value is always >= 0. UTDns utstrlst.cpp 430
  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