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

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