diff options
author | 2019-05-31 11:34:09 +0000 | |
---|---|---|
committer | 2019-05-31 11:34:09 +0000 | |
commit | f48431f7258e814053b6ae2a3ce2fea01d91e4fb (patch) | |
tree | 69a14db8cc6d8ad2f2492615c7e1f7e69ddbdf8e | |
parent | remove duplicate page table (diff) | |
download | wireguard-openbsd-f48431f7258e814053b6ae2a3ce2fea01d91e4fb.tar.xz wireguard-openbsd-f48431f7258e814053b6ae2a3ce2fea01d91e4fb.zip |
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-- | usr.bin/tmux/cmd-parse.y | 12 | ||||
-rw-r--r-- | usr.bin/tmux/control.c | 3 |
2 files changed, 9 insertions, 6 deletions
diff --git a/usr.bin/tmux/cmd-parse.y b/usr.bin/tmux/cmd-parse.y index e3cd88ac72d..2733471e16b 100644 --- a/usr.bin/tmux/cmd-parse.y +++ b/usr.bin/tmux/cmd-parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-parse.y,v 1.10 2019/05/30 10:04:33 nicm Exp $ */ +/* $OpenBSD: cmd-parse.y,v 1.11 2019/05/31 11:34:09 nicm Exp $ */ /* * Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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/usr.bin/tmux/control.c b/usr.bin/tmux/control.c index 5fa287b4130..4af38905fa4 100644 --- a/usr.bin/tmux/control.c +++ b/usr.bin/tmux/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.22 2019/05/23 11:13:30 nicm Exp $ */ +/* $OpenBSD: control.c,v 1.23 2019/05/31 11:34:09 nicm Exp $ */ /* * Copyright (c) 2012 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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); |