diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c index 6734da991..98b591901 100644 --- a/Xi/xiselectev.c +++ b/Xi/xiselectev.c @@ -108,10 +108,10 @@ ProcXISelectEvent(ClientPtr client) return BadValue; } - if ((evmask->mask_len * 4) > XI_LASTEVENT) + if ((evmask->mask_len * 4) >= (XI_LASTEVENT + 8)/8) { unsigned char *bits = (unsigned char*)&evmask[1]; - for (i = XI_LASTEVENT; i < evmask->mask_len * 4; i++) + for (i = XI_LASTEVENT + 1; i < evmask->mask_len * 4; i++) { if (BitIsOn(bits, i)) return BadValue;