xorg-x11-server-Xwayland/0026-xkb-Fix-out-of-bounds-array-access-in-_CheckSetShape.patch
2026-06-16 09:59:01 +02:00

52 lines
2.2 KiB
Diff

From 342245c9b2c5f813dfecdc08eb2a7863bebcebb4 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Sat, 18 Apr 2026 07:34:51 +1000
Subject: [PATCH xserver 26/31] xkb: Fix out-of-bounds array access in
_CheckSetShapes()
The primaryNdx and approxNdx fields in the shape wire description are
attacker-controlled CARD8 values from the client request. They are used
to index into the shape->outlines[] array, but were only checked against
XkbNoShape (0xff) and never validated against the actual number of
outlines (shapeWire->nOutlines).
Assisted-by: Claude:claude-claude-opus-4-6
(cherry picked from commit 86a321ad98213957bbb56f295417b0939326718b)
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2225>
---
xkb/xkb.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/xkb/xkb.c b/xkb/xkb.c
index c2b845197..5ab6a3f52 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -5565,10 +5565,22 @@ _CheckSetShapes(XkbGeometryPtr geom,
ol->num_points = olWire->nPoints;
olWire = (xkbOutlineWireDesc *)ptWire;
}
- if (shapeWire->primaryNdx != XkbNoShape)
+ if (shapeWire->primaryNdx != XkbNoShape) {
+ if (shapeWire->primaryNdx >= shapeWire->nOutlines) {
+ client->errorValue = _XkbErrCode3(0x08, shapeWire->primaryNdx,
+ shapeWire->nOutlines);
+ return BadValue;
+ }
shape->primary = &shape->outlines[shapeWire->primaryNdx];
- if (shapeWire->approxNdx != XkbNoShape)
+ }
+ if (shapeWire->approxNdx != XkbNoShape) {
+ if (shapeWire->approxNdx >= shapeWire->nOutlines) {
+ client->errorValue = _XkbErrCode3(0x08, shapeWire->approxNdx,
+ shapeWire->nOutlines);
+ return BadValue;
+ }
shape->approx = &shape->outlines[shapeWire->approxNdx];
+ }
shapeWire = (xkbShapeWireDesc *) olWire;
}
wire = (char *) shapeWire;
--
2.54.0