Author: khornicek
Date: Fri Oct 17 16:39:54 2014
New Revision: 64787
URL:
http://svn.reactos.org/svn/reactos?rev=64787&view=rev
Log:
[CMD]
- prevent a buffer underrun (fixes stray quotes being appended on autocomplete in some
cases)
- check if the input string is not empty (fixes first file in directory getting skipped on
autocomplete)
- fix some typos
CORE-8623
Modified:
trunk/reactos/base/shell/cmd/filecomp.c
Modified: trunk/reactos/base/shell/cmd/filecomp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/filecomp.c?…
==============================================================================
--- trunk/reactos/base/shell/cmd/filecomp.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/filecomp.c [iso-8859-1] Fri Oct 17 16:39:54 2014
@@ -556,7 +556,7 @@
/* Used to find and assemble the string that is returned */
TCHAR szBaseWord[MAX_PATH];
TCHAR szPrefix[MAX_PATH];
- TCHAR szOrginal[MAX_PATH];
+ TCHAR szOriginal[MAX_PATH];
TCHAR szSearchPath[MAX_PATH];
/* Save the strings used last time, so if they hit tab again */
static TCHAR LastReturned[MAX_PATH];
@@ -586,9 +586,9 @@
if (!_tcsnicmp (line, _T("rd "), 3) || !_tcsnicmp (line, _T("cd
"), 3))
ShowAll = FALSE;
- /* Copy the string, str can be edited and orginal should not be */
+ /* Copy the string, str can be edited and original should not be */
_tcscpy(str,strIN);
- _tcscpy(szOrginal,strIN);
+ _tcscpy(szOriginal,strIN);
/* Look to see if the cusor is not at the end of the string */
if ((cusor + 1) < _tcslen(str))
@@ -656,8 +656,8 @@
hFile = FindFirstFile (szSearchPath, &file);
if (hFile == INVALID_HANDLE_VALUE)
{
- /* Assemble the orginal string and return */
- _tcscpy(strOut,szOrginal);
+ /* Assemble the original string and return */
+ _tcscpy(strOut,szOriginal);
return;
}
@@ -685,8 +685,8 @@
{
/* Don't leak old buffer */
cmd_free(oldFileList);
- /* Assemble the orginal string and return */
- _tcscpy(strOut,szOrginal);
+ /* Assemble the original string and return */
+ _tcscpy(strOut,szOriginal);
FindClose(hFile);
ConOutFormatMessage (GetLastError());
return;
@@ -698,11 +698,10 @@
FindClose(hFile);
- /* Check the size of the list to see if we
- found any matches */
+ /* Check the size of the list to see if we found any matches */
if (FileListSize == 0)
{
- _tcscpy(strOut,szOrginal);
+ _tcscpy(strOut,szOriginal);
if (FileList != NULL)
cmd_free(FileList);
return;
@@ -712,7 +711,7 @@
qsort(FileList,FileListSize,sizeof(FileName), compare);
/* Find the next/previous */
- if (!_tcscmp(szOrginal,LastReturned))
+ if (_tcslen(szOriginal) && !_tcscmp(szOriginal,LastReturned))
{
if (bNext)
{
@@ -734,8 +733,7 @@
Sel = 0;
}
- /* nothing found that matched last time
- so return the first thing in the list */
+ /* nothing found that matched last time so return the first thing in the list */
strOut[0] = _T('\0');
/* Special character in the name */
@@ -792,7 +790,7 @@
}
}
- if (szPrefix[_tcslen(szPrefix) - 1] == _T('\"') || NeededQuote)
+ if (NeededQuote || (_tcslen(szPrefix) && szPrefix[_tcslen(szPrefix) - 1] ==
_T('\"')))
_tcscat(strOut,_T("\""));
_tcscpy(LastReturned,strOut);