From ce02d030202249b6df7ccca83aed5371deef4958 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Sat, 18 Apr 2026 07:35:15 +1000 Subject: [PATCH] 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: --- xkb/xkb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xkb/xkb.c b/xkb/xkb.c index f875a70c7..107284cff 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -5626,12 +5626,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;