summaryrefslogtreecommitdiff
path: root/dix/inpututils.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-11-09 14:45:02 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-12-09 14:56:23 +1000
commit27425f07b29e0ddaa782345c1899273ca742891e (patch)
treeef0d3b989d4a517ec8ce015defe5af85459b8d95 /dix/inpututils.c
parent9b570ecbda954227c89938ee6f94b9efd192d3c6 (diff)
dix: use BUG_WARN for input mask size issues
Yes, we're likely corrupting memory here but really this is unlikely to be triggered other than a real bug in the server. In which case a stacktrace is going to be more useful than any silent error handling. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Diffstat (limited to 'dix/inpututils.c')
-rw-r--r--dix/inpututils.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/dix/inpututils.c b/dix/inpututils.c
index 05d4c7ce1..60f9fa0a8 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -972,8 +972,9 @@ xi2mask_isset(XI2Mask* mask, const DeviceIntPtr dev, int event_type)
{
int set = 0;
- if (dev->id < 0 || dev->id >= mask->nmasks || event_type >= mask->mask_size)
- return 0;
+ BUG_WARN(dev->id < 0);
+ BUG_WARN(dev->id >= mask->nmasks);
+ BUG_WARN(bits_to_bytes(event_type + 1) > mask->mask_size);
set = !!BitIsOn(mask->masks[XIAllDevices], event_type);
if (!set)
@@ -990,8 +991,9 @@ xi2mask_isset(XI2Mask* mask, const DeviceIntPtr dev, int event_type)
void
xi2mask_set(XI2Mask *mask, int deviceid, int event_type)
{
- if (deviceid < 0 || deviceid >= mask->nmasks || event_type >= mask->mask_size)
- return;
+ BUG_WARN(deviceid < 0);
+ BUG_WARN(deviceid >= mask->nmasks);
+ BUG_WARN(bits_to_bytes(event_type + 1) > mask->mask_size);
SetBit(mask->masks[deviceid], event_type);
}
@@ -1005,8 +1007,7 @@ xi2mask_zero(XI2Mask *mask, int deviceid)
{
int i;
- if (deviceid > 0 && deviceid >= mask->nmasks)
- return;
+ BUG_WARN(deviceid > 0 && deviceid >= mask->nmasks);
if (deviceid >= 0)
memset(mask->masks[deviceid], 0, mask->mask_size);
@@ -1055,8 +1056,8 @@ xi2mask_mask_size(const XI2Mask *mask)
void
xi2mask_set_one_mask(XI2Mask *xi2mask, int deviceid, const unsigned char *mask, size_t mask_size)
{
- if (deviceid < 0 || deviceid >= xi2mask->nmasks)
- return;
+ BUG_WARN(deviceid < 0);
+ BUG_WARN(deviceid >= xi2mask->nmasks);
memcpy(xi2mask->masks[deviceid], mask, min(xi2mask->mask_size, mask_size));
}
@@ -1067,8 +1068,8 @@ xi2mask_set_one_mask(XI2Mask *xi2mask, int deviceid, const unsigned char *mask,
const unsigned char*
xi2mask_get_one_mask(const XI2Mask *mask, int deviceid)
{
- if (deviceid < 0 || deviceid >= mask->nmasks)
- return NULL;
+ BUG_WARN(deviceid < 0);
+ BUG_WARN(deviceid >= mask->nmasks);
return mask->masks[deviceid];
}