Author: hbelusca
Date: Sun Apr 5 17:11:29 2015
New Revision: 67065
URL:
http://svn.reactos.org/svn/reactos?rev=67065&view=rev
Log:
[CMD]: Check for cmd_realloc returned value. Adapted from patch by Patrick Martin, see
CORE-7298.
Modified:
trunk/reactos/base/shell/cmd/path.c
trunk/reactos/base/shell/cmd/where.c
Modified: trunk/reactos/base/shell/cmd/path.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/path.c?rev=…
==============================================================================
--- trunk/reactos/base/shell/cmd/path.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/path.c [iso-8859-1] Sun Apr 5 17:11:29 2015
@@ -59,7 +59,13 @@
}
else if (dwBuffer > ENV_BUFFER_SIZE)
{
+ LPTSTR pszOldBuffer = pszBuffer;
pszBuffer = (LPTSTR)cmd_realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
+ if (pszBuffer == NULL)
+ {
+ cmd_free(pszOldBuffer);
+ return 1;
+ }
GetEnvironmentVariable (_T("PATH"), pszBuffer, dwBuffer);
}
Modified: trunk/reactos/base/shell/cmd/where.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/where.c?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/where.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/where.c [iso-8859-1] Sun Apr 5 17:11:29 2015
@@ -152,7 +152,13 @@
dwBuffer = GetEnvironmentVariable (_T("PATHEXT"), pszPathExt,
ENV_BUFFER_SIZE);
if (dwBuffer > ENV_BUFFER_SIZE)
{
+ LPTSTR pszOldPathExt = pszPathExt;
pszPathExt = (LPTSTR)cmd_realloc (pszPathExt, dwBuffer * sizeof (TCHAR));
+ if (pszPathExt == NULL)
+ {
+ cmd_free(pszOldPathExt);
+ return FALSE;
+ }
GetEnvironmentVariable (_T("PATHEXT"), pszPathExt, dwBuffer);
_tcslwr(pszPathExt);
}
@@ -184,7 +190,14 @@
dwBuffer = GetEnvironmentVariable (_T("PATH"), pszPath, ENV_BUFFER_SIZE);
if (dwBuffer > ENV_BUFFER_SIZE)
{
+ LPTSTR pszOldPath = pszPath;
pszPath = (LPTSTR)cmd_realloc (pszPath, dwBuffer * sizeof (TCHAR));
+ if (pszPath == NULL)
+ {
+ cmd_free(pszOldPath);
+ cmd_free(pszPathExt);
+ return FALSE;
+ }
GetEnvironmentVariable (_T("PATH"), pszPath, dwBuffer);
}