mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 17:14:41 +00:00
fixed possible buffer overflow bug: pass correct buffer length (in characters, not bytes) to FileGetString()
svn path=/trunk/; revision=18187
This commit is contained in:
parent
580e685078
commit
0f55e53480
3 changed files with 5 additions and 6 deletions
|
@ -408,7 +408,7 @@ LPTSTR ReadBatchLine (LPBOOL bLocalEcho)
|
|||
return textline;
|
||||
}
|
||||
|
||||
if (!FileGetString (bc->hBatchFile, textline, sizeof (textline)))
|
||||
if (!FileGetString (bc->hBatchFile, textline, sizeof (textline) / sizeof (textline[0])))
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
DebugPrintf (_T("ReadBatchLine(): Reached EOF!\n"));
|
||||
|
|
|
@ -85,7 +85,7 @@ INT cmd_goto (LPTSTR cmd, LPTSTR param)
|
|||
/* jump to begin of the file */
|
||||
SetFilePointer (bc->hBatchFile, 0, &lNewPosHigh, FILE_BEGIN);
|
||||
|
||||
while (FileGetString (bc->hBatchFile, textline, sizeof(textline)))
|
||||
while (FileGetString (bc->hBatchFile, textline, sizeof(textline) / sizeof(textline[0])))
|
||||
{
|
||||
int pos;
|
||||
int size;
|
||||
|
|
|
@ -381,13 +381,12 @@ BOOL FileGetString (HANDLE hFile, LPTSTR lpBuffer, INT nBufferLength)
|
|||
while ((--nBufferLength > 0) &&
|
||||
ReadFile(hFile, &ch, 1, &dwRead, NULL) && dwRead)
|
||||
{
|
||||
if ((ch == '\n') || (ch == '\r'))
|
||||
lpString[len++] = ch;
|
||||
if ((ch == '\n') || (ch == '\r'))
|
||||
{
|
||||
/* read it*/
|
||||
lpString[len++] = ch;
|
||||
/* break at new line*/
|
||||
break;
|
||||
}
|
||||
lpString[len++] = ch;
|
||||
}
|
||||
|
||||
if (!dwRead && !len)
|
||||
|
|
Loading…
Reference in a new issue