The buffer overflow vulnerabilities occur in a function that resembles the following in Lhaz.exe.
// Possible modified version of extract_one() function.
sub_41D940(arg_0, arg_4, arg_8, arg_c)
{
DWORD var1;
time_t utimebuf[2];
struct stat stbuf;
char overflowedBuffer[MAX_PATH]; // 260-bytes
char loadStringBuf[0x20]; // 32-bytes
char textBuffer[0x100]; // 256-bytes
if(someFlag && strrstr(compressedFilename, '/'))
{
// Buffer Overflow when compressedFilename > 260-bytes. (including NULL)
// 552 bytes is required to overwrite saved EIP.
strcpy(overflowedBuffer, strrstr(compressedFilename, "/') + 1);
}
else
{
// Buffer Overflow when compressedFilename > 260-bytes. (including NULL)
// 552 bytes is required to overwrite saved EIP.
strcpy(overflowedBuffer, compressedFilename);
sub_529A70(overflowedBuffer, '/');
}
...
...
...
...
...
if (... && calculatedFileCRC != fileCRC)
{
LoadStringA(hInstance, 0x2A, &stbuf, 32);
LoadStringA(hInstance, 0x76, loadStringBuf, 32);
// This code may be Lhaz specific, and is executed only when the compressed file can be
// extracted, but the CRC do not match.
// Note: The name of the compressed file must not be too long such that it can't be
// created.
// Buffer overflow occurs due to unsafe use of sprintf() to construct the
// "File ...compressFileName.... is damaged" error message.
sprintf(textBuffer, "%s %s %s", &stbuf, overflowedBuffer, loadStringBuf);
MessageBox(hWnd, textBuffer, NULL, MB_OKCANCEL | MB_ICONEXCLAMATION | MB_APPLMODAL);
}
...
...
}
The following screen capture shows the saved EIP being overwritten by the "sprintf()" overflow. You may need to configure your English Windows to display non-unicode programs in Japanese. Otherwise, results will be different.