Xi: extra length checking for requests providing masks.
masks can be of arbitrary length. If the client did not initialize mask_len, some sort of boundary check is needed to avoid running over memory. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
0e4dd3b2d2
commit
58c298acc1
|
@ -69,6 +69,7 @@ ProcXISelectEvents(ClientPtr client)
|
|||
DeviceIntRec dummy;
|
||||
xXIEventMask *evmask;
|
||||
int *types = NULL;
|
||||
int len;
|
||||
|
||||
REQUEST(xXISelectEventsReq);
|
||||
REQUEST_AT_LEAST_SIZE(xXISelectEventsReq);
|
||||
|
@ -80,11 +81,18 @@ ProcXISelectEvents(ClientPtr client)
|
|||
if (rc != Success)
|
||||
return rc;
|
||||
|
||||
len = sz_xXISelectEventsReq;
|
||||
|
||||
/* check request validity */
|
||||
evmask = (xXIEventMask*)&stuff[1];
|
||||
num_masks = stuff->num_masks;
|
||||
while(num_masks--)
|
||||
{
|
||||
len += sizeof(xXIEventMask) + evmask->mask_len * 4;
|
||||
|
||||
if (bytes_to_int32(len) > stuff->length)
|
||||
return BadLength;
|
||||
|
||||
if (evmask->deviceid != XIAllDevices &&
|
||||
evmask->deviceid != XIAllMasterDevices)
|
||||
rc = dixLookupDevice(&dev, evmask->deviceid, client, DixUseAccess);
|
||||
|
@ -128,6 +136,9 @@ ProcXISelectEvents(ClientPtr client)
|
|||
evmask++;
|
||||
}
|
||||
|
||||
if (bytes_to_int32(len) != stuff->length)
|
||||
return BadLength;
|
||||
|
||||
/* Set masks on window */
|
||||
evmask = (xXIEventMask*)&stuff[1];
|
||||
num_masks = stuff->num_masks;
|
||||
|
|
Loading…
Reference in New Issue