Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void SERIAL_getErrorString(char* buffer, int length) {
- ...
- if((length - sysmsg_offset -
- strlen((const char*)sysmessagebuffer)) >= 0)
- memcpy(buffer + sysmsg_offset, sysmessagebuffer,
- strlen((const char*)sysmessagebuffer));
- ...
- }
- This is an example of unsafe code from the viewpoint of buffer overflows. The strlen() function returns size_t. It means that the check for buffer overflow doesn't work.
- This suspicious code was found in DOSBox project by PVS-Studio static code analyzer.
- Warning message is:
- V547 Expression is always true. Unsigned type value is always >= 0. dosbox libserial.cpp 155
- 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