diff options
author | Peter Hofmann <scm@uninformativ.de> | 2023-10-07 07:39:00 +0200 |
---|---|---|
committer | Rafael Marçalo <raroma09@gmail.com> | 2023-10-08 23:31:40 +0100 |
commit | 3343846d48e59734e4a77cb97c69742eb4f9baa4 (patch) | |
tree | 544cde9e988a4fcda7d87119bd3c760cdeb967ad /x.c | |
parent | 5de68c6b432f63b8ef260f982e2cea9fb4456dda (diff) |
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 (limited to 'x.c')
-rw-r--r-- | x.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -830,7 +830,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; @@ -845,7 +845,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)) |