In shells such as Win32 Cmd, malformed command line can be used to spawn
processes. As a consequence when parsing a quoted argument, the closing
double quote can be missing and a null character found instead. In that
case, behave as if the closing double quote is found with the exception
that trailing backslashes are not considered as part of an escape
sequence.
Tested on x86_64-pc-linux-gnu, committed on trunk
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.
diff --git a/gcc/ada/rtinit.c b/gcc/ada/rtinit.c
--- a/gcc/ada/rtinit.c
+++ b/gcc/ada/rtinit.c
@@ -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++)