Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CPPString CPPHtmlDrawer::GetStringFromDll(....)
- {
- ...
- TCHAR szTemp[256];
- DWORD dwLen = ::LoadString(hInstDll, dwID, szTemp,
- (sizeof(szTemp) * sizeof(TCHAR)));
- ...
- }
- The LoadString function takes the buffer's size in characters as the last argument. In the Unicode version of the application, we will tell the function that the buffer's size is larger than it is actually. This may cause a buffer overflow. Note that if we fix the code in the following way, it will not become correct at all: sizeof(szTemp) / sizeof(TCHAR).
- This suspicious code was found in NetDefender project by PVS-Studio static code analyzer.
- Warning message is:
- V531 It is odd that a sizeof() operator is multiplied by sizeof(). fire pphtmldrawer.cpp 258
- 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