action: check range of MovePtr X,Y values
authorRan Benita <ran234@gmail.com>
Fri, 7 Feb 2014 16:48:16 +0000 (18:48 +0200)
committerRan Benita <ran234@gmail.com>
Fri, 7 Feb 2014 16:48:16 +0000 (18:48 +0200)
Signed-off-by: Ran Benita <ran234@gmail.com>
src/xkbcomp/action.c

index 2bd0bd1..1b6a66c 100644 (file)
@@ -469,15 +469,24 @@ HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action,
         if (!ExprResolveInteger(keymap->ctx, value, &val))
             return ReportMismatch(keymap, action->type, field, "integer");
 
+        if (val < INT16_MIN || val > INT16_MAX) {
+            log_err(keymap->ctx,
+                    "The %s field in the %s action must be in range %d..%d; "
+                    "Action definition ignored\n",
+                    fieldText(field), ActionTypeText(action->type),
+                    INT16_MIN, INT16_MAX);
+            return false;
+        }
+
         if (field == ACTION_FIELD_X) {
             if (absolute)
                 act->flags |= ACTION_ABSOLUTE_X;
-            act->x = val;
+            act->x = (int16_t) val;
         }
         else {
             if (absolute)
                 act->flags |= ACTION_ABSOLUTE_Y;
-            act->y = val;
+            act->y = (int16_t) val;
         }
 
         return true;