From 015032f71afc3164ad61d8fd97c69d636b736469 Mon Sep 17 00:00:00 2001 From: Mattia Verga Date: Wed, 4 Oct 2023 14:08:51 +0200 Subject: [PATCH] Fix patch --- ...crash-on-valid-xml-with-but-no-comps.patch | 46 ++++--------------- libcomps.spec | 2 + 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/fix-a-crash-on-valid-xml-with-but-no-comps.patch b/fix-a-crash-on-valid-xml-with-but-no-comps.patch index 2651e91..ff73630 100644 --- a/fix-a-crash-on-valid-xml-with-but-no-comps.patch +++ b/fix-a-crash-on-valid-xml-with-but-no-comps.patch @@ -1,29 +1,7 @@ -From 51fc7782472cdfb1905aa48f405c0f192ba6c373 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= -Date: Wed, 27 Sep 2023 08:27:58 +0200 -Subject: [PATCH] xml parsing: fix a crash on valid xml with but no comps - -On input like: -``` - - - - -``` -the document is parsed but there is no `comps_doc` so we cannot work -with it. - -Also adds a unit test. ---- - libcomps/src/comps_parse.c | 6 +++--- - libcomps/src/python/tests/__test.py | 9 +++++++++ - 2 files changed, 12 insertions(+), 3 deletions(-) - -diff --git a/libcomps/src/comps_parse.c b/libcomps/src/comps_parse.c -index 18133a2..7b4bf3c 100644 ---- a/libcomps/src/comps_parse.c -+++ b/libcomps/src/comps_parse.c -@@ -176,21 +176,21 @@ int comps_parse_validate_dtd(char *filename, char *dtd_file) { +diff -U 3 -dHrN a/libcomps/src/comps_parse.c b/libcomps/src/comps_parse.c +--- a/libcomps/src/comps_parse.c 2022-09-09 13:55:00.000000000 +0200 ++++ b/libcomps/src/comps_parse.c 2023-10-04 14:00:50.722561035 +0200 +@@ -176,21 +176,21 @@ } void __comps_after_parse(COMPS_Parsed *parsed) { @@ -48,13 +26,12 @@ index 18133a2..7b4bf3c 100644 COMPS_OBJECT_DESTROY(parsed->comps_doc->doctype_pubid); parsed->comps_doc->doctype_pubid = (COMPS_Str*) COMPS_OBJECT_INCREF(parsed->doctype_pubid); -diff --git a/libcomps/src/python/tests/__test.py b/libcomps/src/python/tests/__test.py -index ba4b349..18200c5 100644 ---- a/libcomps/src/python/tests/__test.py -+++ b/libcomps/src/python/tests/__test.py -@@ -743,6 +743,15 @@ def test_xml(self): - # return code 1 is non fatal error - self.assertTrue(ret == 1, comps5.get_last_errors()) +diff -U 3 -dHrN a/libcomps/src/python/tests/__test.py b/libcomps/src/python/tests/__test.py +--- a/libcomps/src/python/tests/__test.py 2023-10-04 14:00:25.970189009 +0200 ++++ b/libcomps/src/python/tests/__test.py 2023-10-04 14:00:50.723080381 +0200 +@@ -1270,5 +1270,14 @@ + #suite = unittest.TestLoader().loadTestsFromTestCase(EnvListTest) + #MyRunner(verbosity=2).run(suite) + VALID_XML_HEADER_NO_COMPS = """ + @@ -65,6 +42,3 @@ index ba4b349..18200c5 100644 + # return code 1 is non fatal error + self.assertTrue(ret == 1, comps6.get_last_errors()) + - - #@unittest.skip("") - def test_fedora(self): diff --git a/libcomps.spec b/libcomps.spec index 03a6f95..742826e 100644 --- a/libcomps.spec +++ b/libcomps.spec @@ -10,7 +10,9 @@ URL: https://github.com/rpm-software-management/libcomps Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz # Backported +# https://github.com/rpm-software-management/libcomps/pull/104 Patch: fix-fromxml_str-segfault.patch +# https://github.com/rpm-software-management/libcomps/pull/106 Patch: fix-a-crash-on-valid-xml-with-but-no-comps.patch BuildRequires: gcc-c++