Commit 03f2eb1e authored by Daniel Stone's avatar Daniel Stone
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 47818287
...@@ -79,7 +79,7 @@ ProcXIGrabDevice(ClientPtr client) ...@@ -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) ...@@ -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,14 +42,19 @@ ...@@ -42,14 +42,19 @@
* *
* @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,7 +131,10 @@ ProcXISelectEvents(ClientPtr client) ...@@ -126,7 +131,10 @@ 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 */
...@@ -138,10 +146,13 @@ ProcXISelectEvents(ClientPtr client) ...@@ -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, ...@@ -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 */
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