Skip to content

Commit

Permalink
xkbcomp: fix crash when parsing an xkb_geometry section
Browse files Browse the repository at this point in the history
xkb_geometry sections are ignored; previously the had done so by
returning NULL for the section's XkbFile, however some sections of the
code do not expect this. Instead, create an XkbFile for it, it will
never be processes and discarded later.

Caught with the afl fuzzer.

Signed-off-by: Ran Benita <ran234@gmail.com>
  • Loading branch information
bluetech committed Jul 30, 2018
1 parent e3cacae commit 917636b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 7 additions & 2 deletions src/xkbcomp/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,13 @@ CompileKeymap(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge)
file = (XkbFile *) file->common.next) {
if (file->file_type < FIRST_KEYMAP_FILE_TYPE ||
file->file_type > LAST_KEYMAP_FILE_TYPE) {
log_err(ctx, "Cannot define %s in a keymap file\n",
xkb_file_type_to_string(file->file_type));
if (file->file_type == FILE_TYPE_GEOMETRY) {
log_vrb(ctx, 1,
"Geometry sections are not supported; ignoring\n");
} else {
log_err(ctx, "Cannot define %s in a keymap file\n",
xkb_file_type_to_string(file->file_type));
}
continue;
}

Expand Down
9 changes: 1 addition & 8 deletions src/xkbcomp/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,7 @@ XkbMapConfig : OptFlags FileType OptMapName OBRACE
DeclList
CBRACE SEMI
{
if ($2 == FILE_TYPE_GEOMETRY) {
free($3);
FreeStmt($5);
$$ = NULL;
}
else {
$$ = XkbFileCreate($2, $3, $5, $1);
}
$$ = XkbFileCreate($2, $3, $5, $1);
}
;

Expand Down

1 comment on commit 917636b

@msmeissn
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.