summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm>2019-05-31 11:34:09 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2019-05-31 15:18:25 +0100
commit1a3a973bd08e2890eac6711eb01255b2410bec75 (patch)
tree86ee9652ead469df957f0fcfb269684bca72775e
parente4eec92852754996d8c2a3fae361deb6639f3c4b (diff)
Allow % strings that are all numbers or %s, and fix a double free. Both
reported by George Nachman, GitHub issues 1765 and 1766.
-rw-r--r--cmd-parse.y10
-rw-r--r--control.c1
2 files changed, 7 insertions, 4 deletions
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);
diff --git a/control.c b/control.c
index b7ac3f62..16fa71bb 100644
--- a/control.c
+++ b/control.c
@@ -91,7 +91,6 @@ control_callback(struct client *c, int closed, __unused void *data)
case CMD_PARSE_ERROR:
item = cmdq_get_callback(control_error, pr->error);
cmdq_append(c, item);
- free(pr->error);
break;
case CMD_PARSE_SUCCESS:
item = cmdq_get_command(pr->cmdlist, NULL, NULL, 0);