aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-18 12:22:19 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-18 12:22:19 +0000
commitdf9162450df691f3c815dd79d52cf82a0e4a1782 (patch)
tree0eb29e2bef46bf5e2f947fc6485b67101bc2c721
parentmain: use our own terminfo 'foot' by default (diff)
csi: validate param before indexing into the 256-color array
-rw-r--r--csi.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/csi.c b/csi.c
index 1a0e1090..4e74a1dc 100644
--- a/csi.c
+++ b/csi.c
@@ -195,7 +195,8 @@ csi_sgr(struct terminal *term)
term->vt.params.v[i + 1].value == 5)
{
size_t idx = term->vt.params.v[i + 2].value;
- term->vt.attrs.foreground = 1 << 31 | colors256[idx];
+ if (idx < 5)
+ term->vt.attrs.foreground = 1 << 31 | colors256[idx];
i += 2;
}
@@ -257,7 +258,8 @@ csi_sgr(struct terminal *term)
term->vt.params.v[i + 1].value == 5)
{
size_t idx = term->vt.params.v[i + 2].value;
- term->vt.attrs.background = 1 << 31 | colors256[idx];
+ if (idx < 256)
+ term->vt.attrs.background = 1 << 31 | colors256[idx];
i += 2;
}