[Ada] Handle malformed command line on Win32
authorNicolas Roche <roche@adacore.com>
Tue, 11 May 2021 05:58:42 +0000 (07:58 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 6 Jul 2021 14:46:58 +0000 (14:46 +0000)
gcc/ada/

* rtinit.c (skip_quoted_string): Handle malformed command line
with no closing double quote.
(skip_argument): Handle case in which a null character is
encountered by skip_quote_string.

gcc/ada/rtinit.c

index 391c7e9..83a63c8 100644 (file)
@@ -147,6 +147,19 @@ static void skip_quoted_string (const WCHAR **current_in,
        }
       ci++;
     }
+
+  /* Handle the case in which a nul character was found instead of a closing
+     double quote. In that case consider all the backslashes as literal
+     characters. */
+  if (*ci == '\0')
+    {
+      for (int i=0; i<qbs_count; i++)
+        {
+          *co='\\';
+          co++;
+        }
+    }
+
   *current_in = ci;
   *current_out = co;
 }
@@ -205,7 +218,10 @@ static void skip_argument (const WCHAR **current_in,
          bs_count = 0;
          *co = *ci; co++;
        }
-      ci++;
+      if (*ci != '\0')
+        {
+          ci++;
+        }
     }
 
   for (int i=0; i<bs_count; i++)