summaryrefslogtreecommitdiffstats
path: root/input.c
diff options
context:
space:
mode:
authornicm <nicm>2020-10-29 16:33:01 +0000
committernicm <nicm>2020-10-29 16:33:01 +0000
commita868bacb46e3c900530bed47a1c6f85b0fbe701c (patch)
tree2121794347b7f9ebb5b187e9117ce33e9ae64675 /input.c
parentb33a302235affc19d8a1d8f7473fe589d1bcd17e (diff)
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.
Diffstat (limited to 'input.c')
-rw-r--r--input.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/input.c b/input.c
index 42a60c92..c280c0d9 100644
--- a/input.c
+++ b/input.c
@@ -1976,8 +1976,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);