diff options
author | Pierre Le Marre <dev@wismill.eu> | 2023-07-04 09:23:24 +0200 |
---|---|---|
committer | Wismill <dev@wismill.eu> | 2023-07-14 09:22:24 +0200 |
commit | 7a815ad30718a7551bed36f217c1475aa6187161 (patch) | |
tree | 1a95d4f296f80b486ec405c4c534c81dfc641021 | |
parent | 0da68bc648de409b61d691fc9a3c31ada8a00958 (diff) | |
download | libxkbcommon-7a815ad30718a7551bed36f217c1475aa6187161.tar.gz libxkbcommon-7a815ad30718a7551bed36f217c1475aa6187161.tar.bz2 libxkbcommon-7a815ad30718a7551bed36f217c1475aa6187161.zip |
Fix parsing of numeric keysyms in ExprResolveKeySym
`ExprResolveKeySym` in `expr.c` does not parse non-digit numeric
keysyms.
Fixed by checking upper bound; also add warning messages.
-rw-r--r-- | src/xkbcomp/expr.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c index dbdf734..bbdf038 100644 --- a/src/xkbcomp/expr.c +++ b/src/xkbcomp/expr.c @@ -29,6 +29,7 @@ #include "xkbcomp-priv.h" #include "text.h" #include "expr.h" +#include "keysym.h" typedef bool (*IdentLookupFunc)(struct xkb_context *ctx, const void *priv, xkb_atom_t field, enum expr_value_type type, @@ -656,11 +657,26 @@ ExprResolveKeySym(struct xkb_context *ctx, const ExprDef *expr, if (!ExprResolveInteger(ctx, expr, &val)) return false; - if (val < 0 || val >= 10) + if (val < XKB_KEYSYM_MIN) { + log_warn(ctx, "unrecognized keysym \"-0x%x\" (%d)\n", + (unsigned int) -val, val); return false; + } + + /* Special case for digits 0..9 */ + if (val < 10) { + *sym_rtrn = XKB_KEY_0 + (xkb_keysym_t) val; + return true; + } + + if (val <= XKB_KEYSYM_MAX) { + *sym_rtrn = (xkb_keysym_t) val; + return true; + } + + log_warn(ctx, "unrecognized keysym \"0x%x\" (%d)\n", val, val); + return false; - *sym_rtrn = XKB_KEY_0 + (xkb_keysym_t) val; - return true; } bool |