Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CUT_StrMethods::RemoveSpaces(LPSTR szString) {
- ...
- size_t loop, len = strlen(szString);
- // Remove the trailing spaces
- for(loop = (len-1); loop >= 0; loop--) {
- if(szString[loop] != ' ')
- break;
- }
- ...
- }
- An example of vulnerability. If a string contains only blanks, an array overrun will occur.
- This suspicious code was found in UltimateTCPIP project by PVS-Studio static code analyzer.
- Warning message is:
- V547 Expression 'loop >= 0' is always true. Unsigned type value is always >= 0. UTDns utstrlst.cpp 430
- 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