Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CUT_StrMethods::RemoveCRLF(LPSTR buf)
- {
- // v4.2 changed to size_t
- size_t len, indx = 1;
- if(buf != NULL){
- len = strlen(buf);
- while((len - indx) >= 0 && indx <= 2) {
- if(buf[len - indx] == '\r' ||
- buf[len - indx] == '\n')
- buf[len - indx] = 0;
- ++indx;
- }
- }
- }
- This is an example of vulnerability. When processing an empty string, the (len - indx) expression will equal 0xFFFFFFFFu. The value 0xFFFFFFFFu is above 0. An array overrun will occur.
- This suspicious code was found in UltimateTCPIP project by PVS-Studio static code analyzer.
- Warning message is:
- V547 Expression '( len - indx ) >= 0' is always true. Unsigned type value is always >= 0. UTDns utstrlst.cpp 58
- 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