summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2010-12-17 17:13:34 +0000
committerPeter Hutterer <peter.hutterer@who-t.net>2010-12-23 11:38:46 +1000
commitb01dd9d33651999b0390bf8ed412b84f6929a13e (patch)
tree7506eabf254324807b5e69f7d7f837db520a8b9e
parent495e0142a77152c4cde5c88cdba4103ddc94df2c (diff)
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>
-rw-r--r--Xi/xigrabdev.c2
-rw-r--r--Xi/xipassivegrab.c2
-rw-r--r--Xi/xiselectev.c15
-rw-r--r--include/exevents.h2
4 files changed, 16 insertions, 5 deletions
diff --git a/Xi/xigrabdev.c b/Xi/xigrabdev.c
index 24ededcb1..0adc8787d 100644
--- a/Xi/xigrabdev.c
+++ b/Xi/xigrabdev.c
@@ -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;
diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c
index 296614510..e99b6e554 100644
--- a/Xi/xipassivegrab.c
+++ b/Xi/xipassivegrab.c
@@ -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;
diff --git a/Xi/xiselectev.c b/Xi/xiselectev.c
index 7aa3f0ab6..22fbaf5e7 100644
--- a/Xi/xiselectev.c
+++ b/Xi/xiselectev.c
@@ -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;
diff --git a/include/exevents.h b/include/exevents.h
index bfee385d3..dc594304f 100644
--- a/include/exevents.h
+++ b/include/exevents.h
@@ -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 */