summaryrefslogtreecommitdiff
authorRan Benita <ran234@gmail.com>2012-10-30 16:21:56 (GMT)
committer Ran Benita <ran234@gmail.com>2012-10-30 16:25:08 (GMT)
commit998c957a3c7c861093f3f71f34989c258ed3073b (patch) (side-by-side diff)
treedea5dd7d7c1b6e784584f89edadf1f9b76d3e456
parent860fb171a925de7efda70d618cf2fec6a98f0869 (diff)
downloadlibxkbcommon-998c957a3c7c861093f3f71f34989c258ed3073b.zip
libxkbcommon-998c957a3c7c861093f3f71f34989c258ed3073b.tar.gz
action: don't allow private actions with a known type
Some obscure bug having to do with Private actions; see the comments. This was prompted by: https://bugs.freedesktop.org/show_bug.cgi?id=56491 Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/text.c2
-rw-r--r--src/xkbcomp/action.c21
2 files changed, 21 insertions, 2 deletions
diff --git a/src/text.c b/src/text.c
index bb56b12..8edc0e3 100644
--- a/src/text.c
+++ b/src/text.c
@@ -279,7 +279,7 @@ ModNameToIndex(const struct xkb_keymap *keymap, xkb_atom_t name,
}
const char *
-ActionTypeText(unsigned type)
+ActionTypeText(enum xkb_action_type type)
{
const char *name = LookupValue(actionTypeNames, type);
return name ? name : "Private";
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index f83c220..d0e18dd 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -748,7 +748,26 @@ HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
return false;
}
- act->type = (enum xkb_action_type) type;
+ /*
+ * It's possible for someone to write something like this:
+ * actions = [ Private(type=3,data[0]=1,data[1]=3,data[2]=3) ]
+ * where the type refers to some existing action type, e.g. LockMods.
+ * This assumes that this action's struct is layed out in memory
+ * exactly as described in the XKB specification and libraries.
+ * We, however, have changed these structs in various ways, so this
+ * assumption is no longer true. Since this is a lousy "feature", we
+ * make actions like these no-ops for now.
+ */
+ if (type < ACTION_TYPE_PRIVATE) {
+ log_info(keymap->ctx,
+ "Private actions of type %s are not supported; Ignored\n",
+ ActionTypeText(type));
+ act->type = ACTION_TYPE_NONE;
+ }
+ else {
+ act->type = (enum xkb_action_type) type;
+ }
+
return true;
}
else if (field == ACTION_FIELD_DATA) {