diff options
author | Ran Benita <ran234@gmail.com> | 2018-08-05 08:45:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-05 08:45:19 +0300 |
commit | a3e110d605c469a59b692465f5bc0e5ce5214779 (patch) | |
tree | 79e063a947a43a6eb3370219b998861ffd6133ac | |
parent | 87046f56efc89d3b0771df9b4fefcda39ade3dd1 (diff) | |
parent | bb4909d2d8fa6b08155e449986a478101e2b2634 (diff) | |
download | xorg-lib-libxkbcommon-a3e110d605c469a59b692465f5bc0e5ce5214779.tar.gz |
Merge pull request #67 from fooishbar/fix-more-fuzz
Fix more fuzz-testing fallout
-rw-r--r-- | src/darray.h | 3 | ||||
-rw-r--r-- | src/keymap-priv.c | 3 | ||||
-rw-r--r-- | src/text.c | 1 | ||||
-rw-r--r-- | src/xkbcomp/compat.c | 3 | ||||
-rw-r--r-- | src/xkbcomp/expr.c | 10 | ||||
-rw-r--r-- | src/xkbcomp/parser.y | 5 |
6 files changed, 18 insertions, 7 deletions
diff --git a/src/darray.h b/src/darray.h index e9da974..c30fd7d 100644 --- a/src/darray.h +++ b/src/darray.h @@ -104,7 +104,8 @@ typedef darray (unsigned long) darray_ulong; #define darray_from_items(arr, items, count) do { \ unsigned __count = (count); \ darray_resize(arr, __count); \ - memcpy((arr).item, items, __count * sizeof(*(arr).item)); \ + if (count != 0) \ + memcpy((arr).item, items, __count * sizeof(*(arr).item)); \ } while (0) #define darray_copy(arr_to, arr_from) \ diff --git a/src/keymap-priv.c b/src/keymap-priv.c index 08945ca..fffb2fd 100644 --- a/src/keymap-priv.c +++ b/src/keymap-priv.c @@ -118,7 +118,8 @@ XkbEscapeMapName(char *name) return; while (*name) { - if (!(legal[*name / 8] & (1 << (*name % 8)))) + unsigned char c = *name; + if (!(legal[c / 8] & (1 << (c % 8)))) *name = '_'; name++; } @@ -204,6 +204,7 @@ const LookupEntry symInterpretMatchMaskNames[] = { { "AnyOf", MATCH_ANY }, { "AllOf", MATCH_ALL }, { "Exactly", MATCH_EXACTLY }, + { NULL, 0 }, }; const char * diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c index 9ae26cd..bd587c8 100644 --- a/src/xkbcomp/compat.c +++ b/src/xkbcomp/compat.c @@ -264,7 +264,8 @@ ResolveStateAndPredicate(ExprDef *expr, enum xkb_match_operation *pred_rtrn, *pred_rtrn = MATCH_EXACTLY; if (expr->expr.op == EXPR_ACTION_DECL) { const char *pred_txt = xkb_atom_text(info->ctx, expr->action.name); - if (!LookupString(symInterpretMatchMaskNames, pred_txt, pred_rtrn)) { + if (!LookupString(symInterpretMatchMaskNames, pred_txt, pred_rtrn) || + !expr->action.args) { log_err(info->ctx, "Illegal modifier predicate \"%s\"; Ignored\n", pred_txt); return false; diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c index 5d43cba..b2567de 100644 --- a/src/xkbcomp/expr.c +++ b/src/xkbcomp/expr.c @@ -42,16 +42,20 @@ ExprResolveLhs(struct xkb_context *ctx, const ExprDef *expr, *elem_rtrn = NULL; *field_rtrn = xkb_atom_text(ctx, expr->ident.ident); *index_rtrn = NULL; - return true; + return (*field_rtrn != NULL); case EXPR_FIELD_REF: *elem_rtrn = xkb_atom_text(ctx, expr->field_ref.element); *field_rtrn = xkb_atom_text(ctx, expr->field_ref.field); *index_rtrn = NULL; - return true; + return (*elem_rtrn != NULL && *field_rtrn != NULL); case EXPR_ARRAY_REF: *elem_rtrn = xkb_atom_text(ctx, expr->array_ref.element); *field_rtrn = xkb_atom_text(ctx, expr->array_ref.field); *index_rtrn = expr->array_ref.entry; + if (expr->array_ref.element != XKB_ATOM_NONE && *elem_rtrn == NULL) + return false; + if (*field_rtrn == NULL) + return false; return true; default: break; @@ -101,6 +105,8 @@ LookupModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field, return false; str = xkb_atom_text(ctx, field); + if (!str) + return false; if (istreq(str, "all")) { *val_rtrn = MOD_REAL_MASK_ALL; diff --git a/src/xkbcomp/parser.y b/src/xkbcomp/parser.y index b555bc2..296ce19 100644 --- a/src/xkbcomp/parser.y +++ b/src/xkbcomp/parser.y @@ -239,9 +239,9 @@ resolve_keysym(const char *name, xkb_keysym_t *sym_rtrn) */ XkbFile : XkbCompositeMap - { $$ = param->rtrn = $1; param->more_maps = true; } + { $$ = param->rtrn = $1; param->more_maps = !!param->rtrn; } | XkbMapConfig - { $$ = param->rtrn = $1; param->more_maps = true; YYACCEPT; } + { $$ = param->rtrn = $1; param->more_maps = !!param->rtrn; YYACCEPT; } | END_OF_FILE { $$ = param->rtrn = NULL; param->more_maps = false; } ; @@ -772,6 +772,7 @@ parse(struct xkb_context *ctx, struct scanner *scanner, const char *map) .scanner = scanner, .ctx = ctx, .rtrn = NULL, + .more_maps = false, }; /* |