xorg-x11-server-Xwayland/0027-xkb-Fix-off-by-one-in-color-index-validation-in-_Che.patch
2026-06-16 09:59:01 +02:00

41 lines
1.5 KiB
Diff

From d8103cb20b5e034c402722d66c6b1a1114f5e419 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Sat, 18 Apr 2026 07:35:15 +1000
Subject: [PATCH xserver 27/31] xkb: Fix off-by-one in color index validation
in _CheckSetGeom()
The bounds checks for baseColorNdx and labelColorNdx in _CheckSetGeom()
use '>' instead of '>=' when comparing against req->nColors. Since
nColors is a count and valid indices are 0 to nColors-1, an index equal
to nColors is one past the end of the array.
Assisted-by: Claude:claude-claude-opus-4-6
(cherry picked from commit 6b6e8020b902e48e3330f9a54cd439a51988bc50)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2225>
---
xkb/xkb.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/xkb/xkb.c b/xkb/xkb.c
index 5ab6a3f52..08a966647 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -5630,12 +5630,12 @@ _CheckSetGeom(XkbGeometryPtr geom, xkbSetGeometryReq * req, ClientPtr client)
client->errorValue = _XkbErrCode3(0x01, 2, req->nColors);
return BadValue;
}
- if (req->baseColorNdx > req->nColors) {
+ if (req->baseColorNdx >= req->nColors) {
client->errorValue =
_XkbErrCode3(0x03, req->nColors, req->baseColorNdx);
return BadMatch;
}
- if (req->labelColorNdx > req->nColors) {
+ if (req->labelColorNdx >= req->nColors) {
client->errorValue =
_XkbErrCode3(0x03, req->nColors, req->labelColorNdx);
return BadMatch;
--
2.54.0