Author: jmorlan
Date: Sat Jul 26 12:15:37 2008
New Revision: 34810
URL:
http://svn.reactos.org/svn/reactos?rev=34810&view=rev
Log:
In mkdir, don't add a backslash to the end - it can trick CreateDirectory into
creating a dir with the name of a DOS device (even in Windows).
Modified:
trunk/reactos/base/shell/cmd/internal.c
Modified: trunk/reactos/base/shell/cmd/internal.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/internal.c?…
==============================================================================
--- trunk/reactos/base/shell/cmd/internal.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/internal.c [iso-8859-1] Sat Jul 26 12:15:37 2008
@@ -439,16 +439,16 @@
p += 2;
while (*p == _T('\\'))
p++; /* skip drive root */
- while ((p = _tcschr(p, _T('\\'))) != NULL)
+ do
{
- n = p - DirPath + 1;
+ p = _tcschr(p, _T('\\'));
+ n = p ? p++ - DirPath : _tcslen(DirPath);
_tcsncpy(path, DirPath, n);
path[n] = _T('\0');
if( !CreateDirectory(path, NULL) &&
(GetLastError() != ERROR_ALREADY_EXISTS))
return FALSE;
- p++;
- }
+ } while (p != NULL);
if (GetLastError() == ERROR_ALREADY_EXISTS)
SetLastError(ERROR_SUCCESS);
@@ -463,7 +463,7 @@
{
LPTSTR dir; /* pointer to the directory to change to */
LPTSTR place; /* used to search for the \ when no space is used */
- LPTSTR new_dir, *p = NULL;
+ LPTSTR *p = NULL;
INT argc;
nErrorLevel = 0;
if (!_tcsncmp (param, _T("/?"), 2))
@@ -514,17 +514,6 @@
if(p != NULL)
freep (p);
return 1;
- }
-
- /* Add a \ at the end of the path is there isnt on already */
- if (dir[_tcslen (dir) - 1] != _T('\\'))
- {
- new_dir = cmd_realloc(dir, (_tcslen (dir) + 2) * sizeof(TCHAR));
- if (new_dir != NULL)
- {
- p[0] = dir = new_dir;
- _tcscat(dir,_T("\\"));
- }
}
if (!MakeFullPath(dir))