From 8b1901148fceb95cf57ef9534fb6d1c71b051fcd Mon Sep 17 00:00:00 2001 From: Jeffrey Morlan Date: Thu, 26 Mar 2009 06:31:46 +0000 Subject: [PATCH] - Fix a buffer overflow in cmd - Make "CMD /C" clean up before exiting to get rid of spurious "memory leak" debug messages svn path=/trunk/; revision=40248 --- reactos/base/shell/cmd/cmd.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/reactos/base/shell/cmd/cmd.c b/reactos/base/shell/cmd/cmd.c index 5a4f3d4ebdd..d9445a42d86 100644 --- a/reactos/base/shell/cmd/cmd.c +++ b/reactos/base/shell/cmd/cmd.c @@ -335,7 +335,7 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND *Cmd) need rewrite some code to use cmd_realloc when it need instead of add 512bytes extra */ - first = cmd_alloc ( (_tcslen(First) + 512) * sizeof(TCHAR)); + first = cmd_alloc ( (_tcslen(Full) + 512) * sizeof(TCHAR)); if (first == NULL) { error_out_of_memory(); @@ -343,7 +343,7 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND *Cmd) return FALSE; } - rest = cmd_alloc ( (_tcslen(Rest) + 512) * sizeof(TCHAR)); + rest = cmd_alloc ( (_tcslen(Full) + 512) * sizeof(TCHAR)); if (rest == NULL) { cmd_free (first); @@ -1540,7 +1540,7 @@ ProcessInput() { PARSED_COMMAND *Cmd; - do + while (!bCanExit || !bExit) { Cmd = ParseCommand(NULL); if (!Cmd) @@ -1549,7 +1549,6 @@ ProcessInput() ExecuteCommand(Cmd); FreeCommand(Cmd); } - while (!bCanExit || !bExit); return nErrorLevel; } @@ -1891,7 +1890,7 @@ Initialize() GetCmdLineCommand(commandline, &ptr[2], AlwaysStrip); ParseCommandLine(commandline); if (option != _T('K')) - cmd_exit(nErrorLevel); + bExit = TRUE; } }