csi: validate param before indexing into the 256-color array

This commit is contained in:
Daniel Eklöf 2019-07-18 14:22:19 +02:00
parent 67583540b4
commit df9162450d
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

6
csi.c
View file

@ -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;
}