Xi: start checking for invalid mask bits _after_ LASTEVENT.

Two issues that combined to false positives and false negatives.
- The checking for invalid bits must be performed when there are enough bits
that an event outside of LASTEVENT may be selected.
- The first invalid bit is LASTEVENT + 1, not LASTEVENT.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2009-06-09 16:57:09 +10:00
parent e2fbaebb87
commit 9563feeeb5

View File

@ -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;