mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-11 08:21:01 -04:00
csi: validate param before indexing into the 256-color array
This commit is contained in:
parent
67583540b4
commit
df9162450d
1 changed files with 4 additions and 2 deletions
2
csi.c
2
csi.c
|
|
@ -195,6 +195,7 @@ csi_sgr(struct terminal *term)
|
||||||
term->vt.params.v[i + 1].value == 5)
|
term->vt.params.v[i + 1].value == 5)
|
||||||
{
|
{
|
||||||
size_t idx = term->vt.params.v[i + 2].value;
|
size_t idx = term->vt.params.v[i + 2].value;
|
||||||
|
if (idx < 5)
|
||||||
term->vt.attrs.foreground = 1 << 31 | colors256[idx];
|
term->vt.attrs.foreground = 1 << 31 | colors256[idx];
|
||||||
i += 2;
|
i += 2;
|
||||||
|
|
||||||
|
|
@ -257,6 +258,7 @@ csi_sgr(struct terminal *term)
|
||||||
term->vt.params.v[i + 1].value == 5)
|
term->vt.params.v[i + 1].value == 5)
|
||||||
{
|
{
|
||||||
size_t idx = term->vt.params.v[i + 2].value;
|
size_t idx = term->vt.params.v[i + 2].value;
|
||||||
|
if (idx < 256)
|
||||||
term->vt.attrs.background = 1 << 31 | colors256[idx];
|
term->vt.attrs.background = 1 << 31 | colors256[idx];
|
||||||
i += 2;
|
i += 2;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue