Skip to content

Commit 917636b

Browse files
committed
xkbcomp: fix crash when parsing an xkb_geometry section
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>
1 parent e3cacae commit 917636b

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

Diff for: src/xkbcomp/keymap.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,13 @@ CompileKeymap(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge)
241241
file = (XkbFile *) file->common.next) {
242242
if (file->file_type < FIRST_KEYMAP_FILE_TYPE ||
243243
file->file_type > LAST_KEYMAP_FILE_TYPE) {
244-
log_err(ctx, "Cannot define %s in a keymap file\n",
245-
xkb_file_type_to_string(file->file_type));
244+
if (file->file_type == FILE_TYPE_GEOMETRY) {
245+
log_vrb(ctx, 1,
246+
"Geometry sections are not supported; ignoring\n");
247+
} else {
248+
log_err(ctx, "Cannot define %s in a keymap file\n",
249+
xkb_file_type_to_string(file->file_type));
250+
}
246251
continue;
247252
}
248253

Diff for: src/xkbcomp/parser.y

+1-8
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,7 @@ XkbMapConfig : OptFlags FileType OptMapName OBRACE
273273
DeclList
274274
CBRACE SEMI
275275
{
276-
if ($2 == FILE_TYPE_GEOMETRY) {
277-
free($3);
278-
FreeStmt($5);
279-
$$ = NULL;
280-
}
281-
else {
282-
$$ = XkbFileCreate($2, $3, $5, $1);
283-
}
276+
$$ = XkbFileCreate($2, $3, $5, $1);
284277
}
285278
;
286279

0 commit comments

Comments
 (0)