mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-06-07 02:58:22 +02:00
xkb: Fix off-by-one and NULL dereferences in _CheckSetOverlay()
Off-by-one in rowUnder validation: the bounds check uses '>' instead of '>=' when comparing rWire->rowUnder against section->num_rows. Since num_rows is a count and valid indices are 0 to num_rows-1, rowUnder == num_rows passes the check but is one past the valid range. XkbAddGeomOverlayRow() uses this as an array index, causing an out-of-bounds read on section->rows[]. And throw in two alloc checks while we're at it. Assisted-by: Claude:claude-claude-opus-4-6 Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2208>
This commit is contained in:
parent
6b6e8020b9
commit
ed19312c4b
1 changed files with 5 additions and 1 deletions
|
|
@ -5368,6 +5368,8 @@ _CheckSetOverlay(char **wire_inout, xkbSetGeometryReq *req,
|
|||
}
|
||||
CHK_ATOM_ONLY(olWire->name);
|
||||
ol = XkbAddGeomOverlay(section, olWire->name, olWire->nRows);
|
||||
if (!ol)
|
||||
return BadAlloc;
|
||||
rWire = (xkbOverlayRowWireDesc *) &olWire[1];
|
||||
for (r = 0; r < olWire->nRows; r++) {
|
||||
register int k;
|
||||
|
|
@ -5377,12 +5379,14 @@ _CheckSetOverlay(char **wire_inout, xkbSetGeometryReq *req,
|
|||
if (!_XkbCheckRequestBounds(client, req, rWire, rWire + 1))
|
||||
return BadLength;
|
||||
|
||||
if (rWire->rowUnder > section->num_rows) {
|
||||
if (rWire->rowUnder >= section->num_rows) {
|
||||
client->errorValue = _XkbErrCode4(0x20, r, section->num_rows,
|
||||
rWire->rowUnder);
|
||||
return BadMatch;
|
||||
}
|
||||
row = XkbAddGeomOverlayRow(ol, rWire->rowUnder, rWire->nKeys);
|
||||
if (!row)
|
||||
return BadAlloc;
|
||||
kWire = (xkbOverlayKeyWireDesc *) &rWire[1];
|
||||
for (k = 0; k < rWire->nKeys; k++, kWire++) {
|
||||
if (!_XkbCheckRequestBounds(client, req, kWire, kWire + 1))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue