Skip to content

Commit 3d88695

Browse files
ofourdanmetux
authored andcommitted
xkb: Prevent overflow in XkbSetCompatMap()
The XkbCompatMap structure stores its "num_si" and "size_si" fields using an unsigned short. However, the function _XkbSetCompatMap() will store the sum of the input data "firstSI" and "nSI" in both XkbCompatMap's "num_si" and "size_si" without first checking if the sum overflows the maximum unsigned short value, leading to a possible overflow. To avoid the issue, check whether the sum does not exceed the maximum unsigned short value, or return a "BadValue" error otherwise. CVE-2025-62231, ZDI-CAN-27560 This vulnerability was discovered by: Jan-Niklas Sohn working with Trend Micro Zero Day Initiative Signed-off-by: Olivier Fourdan <[email protected]> Reviewed-by: Michel Dänzer <[email protected]> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2086>
1 parent 0e1a023 commit 3d88695

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

xkb/xkb.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2952,6 +2952,8 @@ _XkbSetCompatMap(ClientPtr client, DeviceIntPtr dev,
29522952
XkbSymInterpretPtr sym;
29532953
unsigned int skipped = 0;
29542954

2955+
if ((unsigned) (req->firstSI + req->nSI) > USHRT_MAX)
2956+
return BadValue;
29552957
if ((unsigned) (req->firstSI + req->nSI) > compat->size_si) {
29562958
compat->num_si = compat->size_si = req->firstSI + req->nSI;
29572959
compat->sym_interpret = reallocarray(compat->sym_interpret,

0 commit comments

Comments
 (0)