Bug 333637: assembleCmdLine needs to quote an empty-string argument. The NSPR_HEAD_20080120
authorwtc%google.com
Sun, 20 Jan 2008 07:13:54 +0000
changeset 3909 a10b5d9228032b9d26efcf07117bd3990547d80b
parent 3908 799bd862d51b985a11f32f383a9c4b7878d68155
child 3910 1283a0a5e8eaaf5f8463b48148daf249c134ad5a
push idunknown
push userunknown
push dateunknown
bugs333637
Bug 333637: assembleCmdLine needs to quote an empty-string argument. The patch is contributed by Aleksey Sanin <aleksey@aleksey.com>. r=wtc
pr/src/md/windows/ntmisc.c
--- a/pr/src/md/windows/ntmisc.c
+++ b/pr/src/md/windows/ntmisc.c
@@ -142,18 +142,21 @@ static int assembleCmdLine(char *const *
         /* Add a space to separates the arguments */
         if (arg != argv) {
             *p++ = ' '; 
         }
         q = *arg;
         numBackslashes = 0;
         argNeedQuotes = 0;
 
-        /* If the argument contains white space, it needs to be quoted. */
-        if (strpbrk(*arg, " \f\n\r\t\v")) {
+        /*
+         * If the argument is empty or contains white space, it needs to
+         * be quoted.
+         */
+        if (**arg == '\0' || strpbrk(*arg, " \f\n\r\t\v")) {
             argNeedQuotes = 1;
         }
 
         if (argNeedQuotes) {
             *p++ = '"';
         }
         while (*q) {
             if (*q == '\\') {