remove some hardcode commadline buffer value. first step to implement
dymatic buffer. but we need do it very carefull, so nothing will be
broken.
Modified: trunk/reactos/subsys/system/cmd/start.c
_____
Modified: trunk/reactos/subsys/system/cmd/start.c
--- trunk/reactos/subsys/system/cmd/start.c 2005-09-03 19:59:51 UTC
(rev 17625)
+++ trunk/reactos/subsys/system/cmd/start.c 2005-09-03 23:12:17 UTC
(rev 17626)
@@ -21,8 +21,8 @@
{
TCHAR szFullName[MAX_PATH];
TCHAR first[CMDLINE_LENGTH];
- TCHAR rest[CMDLINE_LENGTH];
- TCHAR param[CMDLINE_LENGTH];
+ TCHAR *rest;
+ TCHAR *param;
BOOL bWait = FALSE;
BOOL bBat = FALSE;
BOOL bCreate = FALSE;
@@ -30,6 +30,9 @@
PROCESS_INFORMATION prci;
STARTUPINFO stui;
+
+
+
param[0] = _T('\0');
if (_tcsncmp (Rest, _T("/?"), 2) == 0)
@@ -46,6 +49,8 @@
Rest = _T("cmd");
}
+ rest = malloc ( _tcslen(Rest) + 1 * sizeof(TCHAR));
+
_tcscpy(rest,Rest);
/* Parsing the command that gets called by start, and it's
parameters */
@@ -59,6 +64,7 @@
{
if(rest[i] == _T(' '))
{
+ param = malloc ( _tcslen(&rest[i]) + 1 *
sizeof(TCHAR));
_tcscpy(param,&rest[i]);
rest[i] = _T('\0');
break;
@@ -95,6 +101,7 @@
}
/* check for a drive change */
+
if (!_tcscmp (first + 1, _T(":")) && _istalpha (*first))
{
TCHAR szPath[MAX_PATH];
@@ -106,14 +113,27 @@
if (szPath[0] != (TCHAR)_totupper (*first))
ConErrResPuts (STRING_FREE_ERROR1);
+ if (rest != NULL)
+ free(rest);
+
+ if (param != NULL)
+ free(param);
+
return 0;
}
+
/* get the PATH environment variable and parse it */
/* search the PATH environment variable for the binary */
if (!SearchForExecutable (rest, szFullName))
{
error_bad_command ();
+
+ if (rest != NULL)
+ free(rest);
+
+ if (param != NULL)
+ free(param);
return 1;
}
@@ -128,6 +148,12 @@
if (!SearchForExecutable (_T("CMD"), szFullCmdLine))
{
error_bad_command ();
+ if (rest != NULL)
+ free(rest);
+
+ if (param != NULL)
+ free(param);
+
return 1;
}
@@ -200,6 +226,12 @@
}
// }
+ if (rest != NULL)
+ free(rest);
+
+ if (param != NULL)
+ free(param);
+
return 0;
}