summaryrefslogtreecommitdiffstats
path: root/cmd-parse.y
diff options
context:
space:
mode:
authornicm <nicm>2019-05-31 11:34:09 +0000
committernicm <nicm>2019-05-31 11:34:09 +0000
commit82e47403c6a8d6fff90f77e9262840050b8e6b2e (patch)
tree38285e4e7654ad6d7e59facaba4b500fbf10ad92 /cmd-parse.y
parentb26523c26dc7cf0a24a1adb787aa1816deb40693 (diff)
Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.
Diffstat (limited to 'cmd-parse.y')
-rw-r--r--cmd-parse.y10
1 files changed, 7 insertions, 3 deletions
diff --git a/cmd-parse.y b/cmd-parse.y
index d5d12d95..0a627268 100644
--- a/cmd-parse.y
+++ b/cmd-parse.y
@@ -998,11 +998,15 @@ yylex(void)
if (ch == '%') {
/*
- * % is a condition unless it is alone, then it is a
- * token.
+ * % is a condition unless it is all % or all numbers,
+ * then it is a token.
*/
yylval.token = yylex_get_word('%');
- if (strcmp(yylval.token, "%") == 0)
+ for (cp = yylval.token; *cp != '\0'; cp++) {
+ if (*cp != '%' && !isdigit((u_char)*cp))
+ break;
+ }
+ if (*cp == '\0')
return (TOKEN);
if (strcmp(yylval.token, "%if") == 0) {
free(yylval.token);