mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2025-12-20 12:50:04 +01:00
fix a sign problem with valuator data.
Without this patch, any negative valuator value is wrong when returned
from XQueryDeviceState(). This is a regression from at least xserver
1.4.
Valuator data is set in dix/getevents.c:set_valuators() by copying
signed int values into an unsigned int field
DeviceEvent.valuators.data.
That data is converted into a double with an implicit cast by
assignment to axisVal[i] in Xi/exevents.c:UpdateDeviceState().
That double is converted back to a signed int in
queryst.c:ProcXQueryDeviceState(). If the original value in
set_valuators() is negative, the double value will be > 2^31 and the
conversion back to a signed int is undefined. (Although I
consistently see the value -2^31.)
Fix this by changing the definition of DeviceEvent.valuators.data from
uint32_t to int32_t.
Signed-off-by: Joe Shaw <joeshaw@litl.com>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit e354ccac36)
This commit is contained in:
parent
9d939ea0f4
commit
2fce4783f4
2 changed files with 2 additions and 2 deletions
|
|
@ -177,7 +177,7 @@ set_valuators(DeviceIntPtr dev, DeviceEvent* event, int first_valuator,
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&event->valuators.data[first_valuator],
|
memcpy(&event->valuators.data[first_valuator],
|
||||||
valuators, num_valuators * sizeof(uint32_t));
|
valuators, num_valuators * sizeof(int32_t));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ struct _DeviceEvent
|
||||||
struct {
|
struct {
|
||||||
uint8_t mask[(MAX_VALUATORS + 7)/8]; /**< Valuator mask */
|
uint8_t mask[(MAX_VALUATORS + 7)/8]; /**< Valuator mask */
|
||||||
uint8_t mode[(MAX_VALUATORS + 7)/8]; /**< Valuator mode (Abs or Rel)*/
|
uint8_t mode[(MAX_VALUATORS + 7)/8]; /**< Valuator mode (Abs or Rel)*/
|
||||||
uint32_t data[MAX_VALUATORS]; /**< Valuator data */
|
int32_t data[MAX_VALUATORS]; /**< Valuator data */
|
||||||
int32_t data_frac[MAX_VALUATORS]; /**< Fractional part for data */
|
int32_t data_frac[MAX_VALUATORS]; /**< Fractional part for data */
|
||||||
} valuators;
|
} valuators;
|
||||||
struct {
|
struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue