Commit b01dd9d3 authored by Daniel Stone's avatar Daniel Stone Committed by Peter Hutterer
Browse files

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's avatarDaniel Stone <daniel@fooishbar.org>
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 495e0142
......@@ -79,7 +79,7 @@ ProcXIGrabDevice(ClientPtr client)
if (!IsMaster(dev))
stuff->paired_device_mode = GrabModeAsync;
if (XICheckInvalidMaskBits((unsigned char*)&stuff[1],
if (XICheckInvalidMaskBits(client, (unsigned char*)&stuff[1],
stuff->mask_len * 4) != Success)
return BadValue;
......
......@@ -118,7 +118,7 @@ ProcXIPassiveGrabDevice(ClientPtr client)
return BadValue;
}
if (XICheckInvalidMaskBits((unsigned char*)&stuff[1],
if (XICheckInvalidMaskBits(client, (unsigned char*)&stuff[1],
stuff->mask_len * 4) != Success)
return BadValue;
......
......@@ -42,14 +42,19 @@
*
* @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))
{
int i;
for (i = XI2LASTEVENT + 1; i < len * 8; i++)
{
if (BitIsOn(mask, i))
{
client->errorValue = i;
return BadValue;
}
}
}
return Success;
......@@ -126,7 +131,10 @@ ProcXISelectEvents(ClientPtr client)
{
unsigned char *bits = (unsigned char*)&evmask[1];
if (BitIsOn(bits, XI_HierarchyChanged))
{
client->errorValue = XI_HierarchyChanged;
return BadValue;
}
}
/* Raw events may only be selected on root windows */
......@@ -138,10 +146,13 @@ ProcXISelectEvents(ClientPtr client)
BitIsOn(bits, XI_RawButtonPress) ||
BitIsOn(bits, XI_RawButtonRelease) ||
BitIsOn(bits, XI_RawMotion))
{
client->errorValue = XI_RawKeyPress;
return BadValue;
}
}
if (XICheckInvalidMaskBits((unsigned char*)&evmask[1],
if (XICheckInvalidMaskBits(client, (unsigned char*)&evmask[1],
evmask->mask_len * 4) != Success)
return BadValue;
......
......@@ -307,6 +307,6 @@ XISetEventMask(DeviceIntPtr dev, WindowPtr win, ClientPtr client,
unsigned int len, unsigned char* mask);
extern int
XICheckInvalidMaskBits(unsigned char *mask, int len);
XICheckInvalidMaskBits(ClientPtr client, unsigned char *mask, int len);
#endif /* EXEVENTS_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment