From 1a3a973bd08e2890eac6711eb01255b2410bec75 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 31 May 2019 11:34:09 +0000 Subject: Allow % strings that are all numbers or %s, and fix a double free. Both reported by George Nachman, GitHub issues 1765 and 1766. --- cmd-parse.y | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'cmd-parse.y') diff --git a/cmd-parse.y b/cmd-parse.y index 113e6a92..4d43789e 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); -- cgit