Input: Set client error value for invalid mask bits
When we send BadValue back to the client for having invalid mask bits, at least tell them what the (first) invalid bit was. Signed-off-by: Daniel Stone <daniel@fooishbar.org> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
495e0142a7
commit
b01dd9d336
|
@ -79,7 +79,7 @@ ProcXIGrabDevice(ClientPtr client)
|
||||||
if (!IsMaster(dev))
|
if (!IsMaster(dev))
|
||||||
stuff->paired_device_mode = GrabModeAsync;
|
stuff->paired_device_mode = GrabModeAsync;
|
||||||
|
|
||||||
if (XICheckInvalidMaskBits((unsigned char*)&stuff[1],
|
if (XICheckInvalidMaskBits(client, (unsigned char*)&stuff[1],
|
||||||
stuff->mask_len * 4) != Success)
|
stuff->mask_len * 4) != Success)
|
||||||
return BadValue;
|
return BadValue;
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ ProcXIPassiveGrabDevice(ClientPtr client)
|
||||||
return BadValue;
|
return BadValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (XICheckInvalidMaskBits((unsigned char*)&stuff[1],
|
if (XICheckInvalidMaskBits(client, (unsigned char*)&stuff[1],
|
||||||
stuff->mask_len * 4) != Success)
|
stuff->mask_len * 4) != Success)
|
||||||
return BadValue;
|
return BadValue;
|
||||||
|
|
||||||
|
|
|
@ -42,15 +42,20 @@
|
||||||
*
|
*
|
||||||
* @return BadValue if at least one invalid bit is set or Success otherwise.
|
* @return BadValue if at least one invalid bit is set or Success otherwise.
|
||||||
*/
|
*/
|
||||||
int XICheckInvalidMaskBits(unsigned char *mask, int len)
|
int XICheckInvalidMaskBits(ClientPtr client, unsigned char *mask, int len)
|
||||||
{
|
{
|
||||||
if (len >= XIMaskLen(XI2LASTEVENT))
|
if (len >= XIMaskLen(XI2LASTEVENT))
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = XI2LASTEVENT + 1; i < len * 8; i++)
|
for (i = XI2LASTEVENT + 1; i < len * 8; i++)
|
||||||
|
{
|
||||||
if (BitIsOn(mask, i))
|
if (BitIsOn(mask, i))
|
||||||
|
{
|
||||||
|
client->errorValue = i;
|
||||||
return BadValue;
|
return BadValue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
@ -126,8 +131,11 @@ ProcXISelectEvents(ClientPtr client)
|
||||||
{
|
{
|
||||||
unsigned char *bits = (unsigned char*)&evmask[1];
|
unsigned char *bits = (unsigned char*)&evmask[1];
|
||||||
if (BitIsOn(bits, XI_HierarchyChanged))
|
if (BitIsOn(bits, XI_HierarchyChanged))
|
||||||
|
{
|
||||||
|
client->errorValue = XI_HierarchyChanged;
|
||||||
return BadValue;
|
return BadValue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Raw events may only be selected on root windows */
|
/* Raw events may only be selected on root windows */
|
||||||
if (win->parent && evmask->mask_len >= 1)
|
if (win->parent && evmask->mask_len >= 1)
|
||||||
|
@ -138,10 +146,13 @@ ProcXISelectEvents(ClientPtr client)
|
||||||
BitIsOn(bits, XI_RawButtonPress) ||
|
BitIsOn(bits, XI_RawButtonPress) ||
|
||||||
BitIsOn(bits, XI_RawButtonRelease) ||
|
BitIsOn(bits, XI_RawButtonRelease) ||
|
||||||
BitIsOn(bits, XI_RawMotion))
|
BitIsOn(bits, XI_RawMotion))
|
||||||
|
{
|
||||||
|
client->errorValue = XI_RawKeyPress;
|
||||||
return BadValue;
|
return BadValue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (XICheckInvalidMaskBits((unsigned char*)&evmask[1],
|
if (XICheckInvalidMaskBits(client, (unsigned char*)&evmask[1],
|
||||||
evmask->mask_len * 4) != Success)
|
evmask->mask_len * 4) != Success)
|
||||||
return BadValue;
|
return BadValue;
|
||||||
|
|
||||||
|
|
|
@ -307,6 +307,6 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
|
||||||
unsigned int len, unsigned char* mask);
|
unsigned int len, unsigned char* mask);
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
XICheckInvalidMaskBits(unsigned char *mask, int len);
|
XICheckInvalidMaskBits(ClientPtr client, unsigned char *mask, int len);
|
||||||
|
|
||||||
#endif /* EXEVENTS_H */
|
#endif /* EXEVENTS_H */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user