aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornicm <nicm>2020-10-29 16:33:01 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2020-10-30 08:17:38 +0000
commit733abfcfc5b05cb3e1f2cf08f00a9325c6f6fa04 (patch)
tree283e6b41f16c881754984b4db8f21379867c9af9
parent7a4aa146187cc60d2df66333b3e7dd5a5176f793 (diff)
downloadrtmux-733abfcfc5b05cb3e1f2cf08f00a9325c6f6fa04.tar.gz
rtmux-733abfcfc5b05cb3e1f2cf08f00a9325c6f6fa04.tar.bz2
rtmux-733abfcfc5b05cb3e1f2cf08f00a9325c6f6fa04.zip
Do not write after the end of the array and overwrite the stack when
colon-separated SGR sequences contain empty arguments. Reported by Sergey Nizovtsev.
-rw-r--r--input.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/input.c b/input.c
index a3850371..60bfa8e2 100644
--- a/input.c
+++ b/input.c
@@ -1975,8 +1975,13 @@ input_csi_dispatch_sgr_colon(struct input_ctx *ictx, u_int i)
free(copy);
return;
}
- } else
+ } else {
n++;
+ if (n == nitems(p)) {
+ free(copy);
+ return;
+ }
+ }
log_debug("%s: %u = %d", __func__, n - 1, p[n - 1]);
}
free(copy);