summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm>2020-10-29 16:33:01 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2020-10-30 12:09:52 +0000
commitd0ad34e94d63def5178f02281637d2d15cb42c88 (patch)
treecf34b8ffee28549423fa0a3558effba509a7b85e
parenta10c4c60cb08a0e13e8c65b81a5c1328b1d4788d (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.
-rw-r--r--input.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/input.c b/input.c
index e794be2a..c2e87611 100644
--- a/input.c
+++ b/input.c
@@ -1929,8 +1929,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);