Correctly NULL-terminate the command-lines when needed (and avoid buffer overruns).

svn path=/trunk/; revision=63365
This commit is contained in:
Hermès Bélusca-Maïto 2014-05-18 23:45:43 +00:00
parent 3e159aa702
commit 65a58c440e
2 changed files with 6 additions and 2 deletions

View file

@ -119,8 +119,8 @@ static VOID WINAPI DosCmdInterpreterBop(LPWORD Stack)
STARTUPINFOA StartupInfo;
PROCESS_INFORMATION ProcessInformation;
/* NULL-terminate the command by removing the return carriage character */
while (*CmdPtr != '\r') CmdPtr++;
/* NULL-terminate the command line by removing the return carriage character */
while (*CmdPtr && *CmdPtr != '\r') CmdPtr++;
*CmdPtr = '\0';
DPRINT1("CMD Run Command '%s'\n", Command);

View file

@ -926,6 +926,10 @@ DWORD DosLoadExecutable(IN DOS_EXEC_TYPE LoadType,
return ERROR_NOT_SUPPORTED;
}
/* NULL-terminate the command line by removing the return carriage character */
while (*CommandLine && *CommandLine != '\r') CommandLine++;
*(LPSTR)CommandLine = '\0';
/* Open a handle to the executable */
FileHandle = CreateFileA(ExecutablePath,
GENERIC_READ,