render: Fix out of bounds access in SProcRenderCompositeGlyphs()

ZDI-CAN-14192, CVE-2021-4008

This vulnerability was discovered and the fix was suggested by:
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative

Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
(cherry picked from commit ebce7e2d80)
This commit is contained in:
Povilas Kanapickas 2021-12-14 15:00:03 +02:00 committed by Matt Turner
parent 67425fcab5
commit 35b4681c79

View File

@ -2309,6 +2309,9 @@ SProcRenderCompositeGlyphs(ClientPtr client)
i = elt->len;
if (i == 0xff) {
if (buffer + 4 > end) {
return BadLength;
}
swapl((int *) buffer);
buffer += 4;
}
@ -2319,12 +2322,18 @@ SProcRenderCompositeGlyphs(ClientPtr client)
buffer += i;
break;
case 2:
if (buffer + i * 2 > end) {
return BadLength;
}
while (i--) {
swaps((short *) buffer);
buffer += 2;
}
break;
case 4:
if (buffer + i * 4 > end) {
return BadLength;
}
while (i--) {
swapl((int *) buffer);
buffer += 4;