st
simple terminal
git clone https://9o.is/git/st.git
commit 986bcb17d1ff59ffe0b65c4eaa340f8955035c3d
parent c212ee67346d0c3a4f69a064a1ad3b00f62b2f37
Author: Peter Hofmann <scm@uninformativ.de>
Date: Sat, 7 Oct 2023 07:39:00 +0200
Fix bounds checks of dc.col
dc.collen is the length of dc.col, not the maximum index, hence if x is
equal to dc.collen, then it's an error.
With config.def.h, the last valid index is 259, so this correctly
reports "black":
$ printf '\033]4;259;?\e\\'
260 is an invalid index and this reports garbage instead of printing an
error:
$ printf '\033]4;260;?\e\\'
Diffstat:
| M | x.c | | | 4 | ++-- |
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/x.c b/x.c @@ -818,7 +818,7 @@ xloadcols(void) int xgetcolor(int x, unsigned char *r, unsigned char *g, unsigned char *b) { - if (!BETWEEN(x, 0, dc.collen)) + if (!BETWEEN(x, 0, dc.collen - 1)) return 1; *r = dc.col[x].color.red >> 8; @@ -833,7 +833,7 @@ xsetcolorname(int x, const char *name) { Color ncolor; - if (!BETWEEN(x, 0, dc.collen)) + if (!BETWEEN(x, 0, dc.collen - 1)) return 1; if (!xloadcolor(x, name, &ncolor))