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
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2208>
This commit is contained in:
Peter Hutterer 2026-04-18 07:35:15 +10:00 committed by Marge Bot
parent 86a321ad98
commit 6b6e8020b9

View file

@ -5637,12 +5637,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;