diff options
author | Peter Hutterer <peter.hutterer@redhat.com> | 2008-10-08 14:35:12 +1030 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@redhat.com> | 2008-10-11 12:24:54 +1030 |
commit | e6c699dedcd6f3b5db497fe2d226806ca4bbe683 (patch) | |
tree | 931c59f4a6e58c2cb9d0ec86af53db7a5420e71a | |
parent | 847eac826286e6202f42b9a2ccc160a232a710a3 (diff) |
Stricter value checking for property changes.
-rw-r--r-- | src/emuMB.c | 11 | ||||
-rw-r--r-- | src/emuWheel.c | 16 |
2 files changed, 24 insertions, 3 deletions
diff --git a/src/emuMB.c b/src/emuMB.c index 7dce38a..5de5227 100644 --- a/src/emuMB.c +++ b/src/emuMB.c @@ -391,9 +391,18 @@ EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val) EvdevPtr pEvdev = pInfo->private; if (atom == prop_mbemu) + { + if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER) + return BadMatch; + pEvdev->emulateMB.enabled = *((BOOL*)val->data); - else if (atom == prop_mbtimeout) + } else if (atom == prop_mbtimeout) + { + if (val->format != 16 || val->size != 1 || val->type != XA_INTEGER) + return BadMatch; + pEvdev->emulateMB.timeout = *((INT16*)val->data); + } return Success; } diff --git a/src/emuWheel.c b/src/emuWheel.c index b0e244f..27dec7c 100644 --- a/src/emuWheel.c +++ b/src/emuWheel.c @@ -401,6 +401,9 @@ EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val) if (atom == prop_wheel_emu) { + if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER) + return BadMatch; + pEvdev->emulateWheel.enabled = *((BOOL*)val->data); /* Don't enable with zero inertia, otherwise we may get stuck in an * infinite loop */ @@ -427,13 +430,16 @@ EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val) { int bt = *((CARD8*)val->data); + if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER) + return BadMatch; + if (bt < 0 || bt >= EVDEV_MAXBUTTONS) return BadValue; pEvdev->emulateWheel.button = bt; } else if (atom == prop_wheel_axismap) { - if (val->size != 4) - return BadValue; + if (val->format != 8 || val->size != 4 || val->type != XA_INTEGER) + return BadMatch; pEvdev->emulateWheel.X.up_button = *((CARD8*)val->data); pEvdev->emulateWheel.X.down_button = *(((CARD8*)val->data) + 1); @@ -443,6 +449,9 @@ EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val) { int inertia = *((CARD16*)val->data); + if (val->format != 16 || val->size != 1 || val->type != XA_INTEGER) + return BadMatch; + if (inertia < 0) return BadValue; @@ -451,6 +460,9 @@ EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val) { int timeout = *((CARD16*)val->data); + if (val->format != 16 || val->size != 1 || val->type != XA_INTEGER) + return BadMatch; + if (timeout < 0) return BadValue; |