summaryrefslogtreecommitdiff
path: root/src/x11
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2018-08-18 14:28:15 +0300
committerRan Benita <ran234@gmail.com>2018-08-18 14:58:03 +0300
commita9ace75f6492304a59ae7b192b05f241e2694764 (patch)
treeeee4b296d8b3815e7f351ca11d236a2a44499aa5 /src/x11
parentf8134c8503c9868d65ee6e06b211ec2eaff3f60d (diff)
downloadxorg-lib-libxkbcommon-a9ace75f6492304a59ae7b192b05f241e2694764.tar.gz
x11: fix undefined behavior when copying the coordinates of ptr movements actions
Left shift of a negative integer. For some reason the protocol representation here got really botched (in the spec it is just a nice and simple INT16). Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/x11')
-rw-r--r--src/x11/keymap.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/x11/keymap.c b/src/x11/keymap.c
index 1642011..701b614 100644
--- a/src/x11/keymap.c
+++ b/src/x11/keymap.c
@@ -218,8 +218,8 @@ translate_action(union xkb_action *action, const xcb_xkb_action_t *wire)
case XCB_XKB_SA_TYPE_MOVE_PTR:
action->type = ACTION_TYPE_PTR_MOVE;
- action->ptr.x = (wire->moveptr.xLow | (wire->moveptr.xHigh << 8));
- action->ptr.y = (wire->moveptr.yLow | (wire->moveptr.yHigh << 8));
+ action->ptr.x = (int16_t) (wire->moveptr.xLow | ((uint16_t) wire->moveptr.xHigh << 8));
+ action->ptr.y = (int16_t) (wire->moveptr.yLow | ((uint16_t) wire->moveptr.yHigh << 8));
if (!(wire->moveptr.flags & XCB_XKB_SA_MOVE_PTR_FLAG_NO_ACCELERATION))
action->ptr.flags |= ACTION_ACCEL;