From 83db2b126e8623824e1303e74070375994984599 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 1 Sep 2009 15:58:02 +1000 Subject: Xi: don't try to set oversized or non-existing masks. Fixes crash if the first XISelectEvents has a zero sized event mask. Fixes crash if the mask provided is larger than others->xi2mask[]. Signed-off-by: Peter Hutterer --- Xi/exevents.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Xi') diff --git a/Xi/exevents.c b/Xi/exevents.c index 2173f354a..b1412f018 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -2148,15 +2148,18 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client, } } - if (!others && len) + len = min(len, sizeof(others->xi2mask[dev->id])); + + if (len && !others) { AddExtensionClient(win, client, 0, 0); others= wOtherInputMasks(win)->inputClients; } - if (!len) + if (others) memset(others->xi2mask[dev->id], 0, sizeof(others->xi2mask[dev->id])); - else + + if (len) memcpy(others->xi2mask[dev->id], mask, len); RecalculateDeviceDeliverableEvents(win); -- cgit v1.2.3