Accepting request 796245 from GNOME:Next

- Add as-glib-PR359.patch: Fix crash with invalid children of <ul>.

OBS-URL: https://build.opensuse.org/request/show/796245
OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/appstream-glib?expand=0&rev=141
This commit is contained in:
Bjørn Lie 2020-04-22 11:16:03 +00:00 committed by Git OBS Bridge
parent ad70ddccbf
commit f32925ba76
3 changed files with 62 additions and 0 deletions

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Wed Apr 22 09:30:51 UTC 2020 - Dominique Leuenberger <dimstar@opensuse.org>
- Add as-glib-PR359.patch: Fix crash with invalid children of <ul>.
-------------------------------------------------------------------
Wed Apr 15 17:12:57 UTC 2020 - dimstar@opensuse.org

View File

@ -26,6 +26,8 @@ Group: System/Libraries
URL: http://people.freedesktop.org/~hughsient/appstream-glib/
Source0: %{name}-%{version}.tar.xz
Source1: openSUSE-appstream-process
# PATCH-FIX-UPSTREAM as-glib-PR359.patch dimstar@opensuse.org -- Fix crash with invalid children of <ul>
Patch0: as-glib-PR359.patch
BuildRequires: docbook-xsl-stylesheets
BuildRequires: gcab >= 0.6
BuildRequires: gobject-introspection-devel

55
as-glib-PR359.patch Normal file
View File

@ -0,0 +1,55 @@
From d4bfa8389932029ae85a7bad4a762d69a47fbbb4 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fvogt@suse.de>
Date: Wed, 22 Apr 2020 11:22:03 +0200
Subject: [PATCH] Fix crash with invalid children of <ul/>
It segfaulted when building the error message as data_c->name was invalid.
data_c was a valid tag, so only the data_c->tag union member was active.
Fix the crash by calling the proper function instead and add a test case.
---
libappstream-glib/as-node.c | 2 +-
libappstream-glib/as-self-test.c | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/libappstream-glib/as-node.c b/libappstream-glib/as-node.c
index 7fd68515..66d582a8 100644
--- a/libappstream-glib/as-node.c
+++ b/libappstream-glib/as-node.c
@@ -1891,7 +1891,7 @@ as_node_get_localized_unwrap_type_li (const AsNode *node,
AS_NODE_ERROR,
AS_NODE_ERROR_INVALID_MARKUP,
"Tag %s in %s invalid",
- data_c->name,
+ as_tag_data_get_name (data_c),
as_tag_data_get_name (data));
return FALSE;
}
diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c
index 47ad937f..66166410 100644
--- a/libappstream-glib/as-self-test.c
+++ b/libappstream-glib/as-self-test.c
@@ -2810,6 +2810,7 @@ as_test_node_xml_func (void)
AsNode *n2;
AsNode *root;
GString *xml;
+ GHashTable *hashtable;
/* invalid XML */
root = as_node_from_xml ("<moo>", 0, &error);
@@ -2920,6 +2921,16 @@ as_test_node_xml_func (void)
g_assert_cmpstr (xml->str, ==, "<!-- 1st -->\n<!-- 2nd -->\n<foo/>\n");
g_string_free (xml, TRUE);
as_node_unref (root);
+
+ /* invalid child of ul */
+ root = as_node_from_xml ("<ul><ul></ul></ul>", 0, &error);
+ g_assert_no_error (error);
+ g_assert (root != NULL);
+ hashtable = as_node_get_localized_unwrap (root, &error);
+ g_assert_error (error, AS_NODE_ERROR, AS_NODE_ERROR_INVALID_MARKUP);
+ g_assert_cmpstr (error->message, ==, "Tag ul in ul invalid");
+ g_clear_error (&error);
+ g_assert (hashtable == NULL);
}
static void