Blame SOURCES/0007-xkbcomp-fix-crash-when-parsing-an-xkb_geometry-secti.patch

a2d0a1
From da964532709cceb3a1e69c6eb8eb89a384649858 Mon Sep 17 00:00:00 2001
a2d0a1
From: Ran Benita <ran234@gmail.com>
a2d0a1
Date: Sun, 11 Mar 2018 17:07:06 +0200
a2d0a1
Subject: [PATCH 07/10] xkbcomp: fix crash when parsing an xkb_geometry section
a2d0a1
a2d0a1
xkb_geometry sections are ignored; previously the had done so by
a2d0a1
returning NULL for the section's XkbFile, however some sections of the
a2d0a1
code do not expect this. Instead, create an XkbFile for it, it will
a2d0a1
never be processes and discarded later.
a2d0a1
a2d0a1
Caught with the afl fuzzer.
a2d0a1
a2d0a1
Signed-off-by: Ran Benita <ran234@gmail.com>
a2d0a1
(cherry picked from commit 917636b1d0d70205a13f89062b95e3a0fc31d4ff)
a2d0a1
---
a2d0a1
 src/xkbcomp/keymap.c | 9 +++++++--
a2d0a1
 src/xkbcomp/parser.y | 9 +--------
a2d0a1
 2 files changed, 8 insertions(+), 10 deletions(-)
a2d0a1
a2d0a1
diff --git a/src/xkbcomp/keymap.c b/src/xkbcomp/keymap.c
a2d0a1
index 45098c2..e95e50c 100644
a2d0a1
--- a/src/xkbcomp/keymap.c
a2d0a1
+++ b/src/xkbcomp/keymap.c
a2d0a1
@@ -241,8 +241,13 @@ CompileKeymap(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge)
a2d0a1
          file = (XkbFile *) file->common.next) {
a2d0a1
         if (file->file_type < FIRST_KEYMAP_FILE_TYPE ||
a2d0a1
             file->file_type > LAST_KEYMAP_FILE_TYPE) {
a2d0a1
-            log_err(ctx, "Cannot define %s in a keymap file\n",
a2d0a1
-                    xkb_file_type_to_string(file->file_type));
a2d0a1
+            if (file->file_type == FILE_TYPE_GEOMETRY) {
a2d0a1
+                log_vrb(ctx, 1,
a2d0a1
+                        "Geometry sections are not supported; ignoring\n");
a2d0a1
+            } else {
a2d0a1
+                log_err(ctx, "Cannot define %s in a keymap file\n",
a2d0a1
+                        xkb_file_type_to_string(file->file_type));
a2d0a1
+            }
a2d0a1
             continue;
a2d0a1
         }
a2d0a1
a2d0a1
diff --git a/src/xkbcomp/parser.y b/src/xkbcomp/parser.y
a2d0a1
index b5b0c2c..cedb8fa 100644
a2d0a1
--- a/src/xkbcomp/parser.y
a2d0a1
+++ b/src/xkbcomp/parser.y
a2d0a1
@@ -273,14 +273,7 @@ XkbMapConfig    :       OptFlags FileType OptMapName OBRACE
a2d0a1
                             DeclList
a2d0a1
                         CBRACE SEMI
a2d0a1
                         {
a2d0a1
-                            if ($2 == FILE_TYPE_GEOMETRY) {
a2d0a1
-                                free($3);
a2d0a1
-                                FreeStmt($5);
a2d0a1
-                                $$ = NULL;
a2d0a1
-                            }
a2d0a1
-                            else {
a2d0a1
-                                $$ = XkbFileCreate($2, $3, $5, $1);
a2d0a1
-                            }
a2d0a1
+                            $$ = XkbFileCreate($2, $3, $5, $1);
a2d0a1
                         }
a2d0a1
                 ;
a2d0a1
a2d0a1
--
a2d0a1
2.20.1