[CMD]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 3 May 2014 18:07:07 +0000 (18:07 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 3 May 2014 18:07:07 +0000 (18:07 +0000)
Fix _tcsncat usage. Patch by Victor Martinez.
CORE-8149 #resolve

svn path=/trunk/; revision=63138

reactos/base/shell/cmd/cmd.c

index 2a56ed9..40cddc3 100644 (file)
@@ -397,13 +397,13 @@ Execute(LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND *Cmd)
         /* build command line for CreateProcess(): FullName + " " + rest */
         BOOL quoted = !!_tcschr(First, ' ');
         _tcscpy(szFullCmdLine, quoted ? _T("\"") : _T(""));
-        _tcsncat(szFullCmdLine, First, CMDLINE_LENGTH - _tcslen(szFullCmdLine));
-        _tcsncat(szFullCmdLine, quoted ? _T("\"") : _T(""), CMDLINE_LENGTH - _tcslen(szFullCmdLine));
+        _tcsncat(szFullCmdLine, First, CMDLINE_LENGTH - _tcslen(szFullCmdLine) - 1);
+        _tcsncat(szFullCmdLine, quoted ? _T("\"") : _T(""), CMDLINE_LENGTH - _tcslen(szFullCmdLine) - 1);
 
         if (*rest)
         {
-            _tcsncat(szFullCmdLine, _T(" "), CMDLINE_LENGTH - _tcslen(szFullCmdLine));
-            _tcsncat(szFullCmdLine, rest, CMDLINE_LENGTH - _tcslen(szFullCmdLine));
+            _tcsncat(szFullCmdLine, _T(" "), CMDLINE_LENGTH - _tcslen(szFullCmdLine) - 1);
+            _tcsncat(szFullCmdLine, rest, CMDLINE_LENGTH - _tcslen(szFullCmdLine) - 1);
         }
 
         TRACE ("[EXEC: %s]\n", debugstr_aw(szFullCmdLine));