Update to 0.1.20
This commit is contained in:
parent
015032f71a
commit
3766487173
@ -1,44 +0,0 @@
|
||||
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) {
|
||||
- if (parsed->doctype_name) {
|
||||
+ if (parsed->doctype_name && parsed->comps_doc) {
|
||||
COMPS_OBJECT_DESTROY(parsed->comps_doc->doctype_name);
|
||||
parsed->comps_doc->doctype_name = (COMPS_Str*)
|
||||
COMPS_OBJECT_INCREF(parsed->doctype_name);
|
||||
} else {
|
||||
//parsed->comps_doc->doctype_name = comps_str(comps_default_doctype_name);
|
||||
}
|
||||
- if (parsed->doctype_sysid) {
|
||||
+ if (parsed->doctype_sysid && parsed->comps_doc) {
|
||||
COMPS_OBJECT_DESTROY(parsed->comps_doc->doctype_sysid);
|
||||
parsed->comps_doc->doctype_sysid = (COMPS_Str*)
|
||||
COMPS_OBJECT_INCREF(parsed->doctype_sysid);
|
||||
} else {
|
||||
//parsed->comps_doc->doctype_sysid = comps_str(comps_default_doctype_sysid);
|
||||
}
|
||||
- if (parsed->doctype_pubid) {
|
||||
+ if (parsed->doctype_pubid && parsed->comps_doc) {
|
||||
COMPS_OBJECT_DESTROY(parsed->comps_doc->doctype_pubid);
|
||||
parsed->comps_doc->doctype_pubid = (COMPS_Str*)
|
||||
COMPS_OBJECT_INCREF(parsed->doctype_pubid);
|
||||
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 = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
+ <!DOCTYPE variants PUBLIC "-//Red Hat, Inc.//DTD Variants info//EN" "variants.dtd">
|
||||
+ <variants>
|
||||
+ </variants>"""
|
||||
+ comps6 = libcomps.Comps()
|
||||
+ ret = comps6.fromxml_str(str(VALID_XML_HEADER_NO_COMPS))
|
||||
+ # return code 1 is non fatal error
|
||||
+ self.assertTrue(ret == 1, comps6.get_last_errors())
|
||||
+
|
@ -1,91 +0,0 @@
|
||||
From 9023f90c3640c795efc8a1ae083c931f5316e448 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
|
||||
Date: Tue, 22 Aug 2023 12:01:35 +0200
|
||||
Subject: [PATCH 1/2] Move return value check before parsed values are used
|
||||
|
||||
It is not sufficient to check the return value after the function output
|
||||
is used. We need check it sooner to avoid a Segmentation fault.
|
||||
|
||||
For: https://github.com/rpm-software-management/libcomps/issues/103
|
||||
---
|
||||
libcomps/src/python/src/pycomps.c | 9 +++++----
|
||||
1 file changed, 5 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/libcomps/src/python/src/pycomps.c b/libcomps/src/python/src/pycomps.c
|
||||
index ee6f691..ffc9e71 100644
|
||||
--- a/libcomps/src/python/src/pycomps.c
|
||||
+++ b/libcomps/src/python/src/pycomps.c
|
||||
@@ -347,6 +347,11 @@ PyObject* PyCOMPS_fromxml_str(PyObject *self, PyObject *args, PyObject *kwds) {
|
||||
parsed_ret = comps_parse_str(parsed, tmps, options);
|
||||
if (options)
|
||||
free(options);
|
||||
+ if (parsed_ret == -1) {
|
||||
+ comps_parse_parsed_destroy(parsed);
|
||||
+ PyErr_SetString(PyCOMPSExc_ParserError, "Fatal parser error");
|
||||
+ return NULL;
|
||||
+ }
|
||||
Py_CLEAR(self_comps->p_groups);
|
||||
Py_CLEAR(self_comps->p_categories);
|
||||
Py_CLEAR(self_comps->p_environments);
|
||||
@@ -361,10 +366,6 @@ PyObject* PyCOMPS_fromxml_str(PyObject *self, PyObject *args, PyObject *kwds) {
|
||||
parsed->log = NULL;
|
||||
parsed->comps_doc = NULL;
|
||||
comps_parse_parsed_destroy(parsed);
|
||||
- if (parsed_ret == -1) {
|
||||
- PyErr_SetString(PyCOMPSExc_ParserError, "Fatal parser error");
|
||||
- return NULL;
|
||||
- }
|
||||
|
||||
return PyLong_FromLong((long)parsed_ret);
|
||||
}
|
||||
|
||||
From 15091c2ae0e70dfd5b92ea6631d323d76273175b Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
|
||||
Date: Tue, 22 Aug 2023 12:18:02 +0200
|
||||
Subject: [PATCH 2/2] Update unittests for `fromxml_str()`
|
||||
|
||||
Remove output checks after the parsing raises and exception.
|
||||
|
||||
It also adds one more test with completely invalid xml input.
|
||||
---
|
||||
libcomps/src/python/tests/__test.py | 17 +++++++++--------
|
||||
1 file changed, 9 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/libcomps/src/python/tests/__test.py b/libcomps/src/python/tests/__test.py
|
||||
index 4152c7d..63a30e2 100644
|
||||
--- a/libcomps/src/python/tests/__test.py
|
||||
+++ b/libcomps/src/python/tests/__test.py
|
||||
@@ -718,24 +718,25 @@ def test_xml(self):
|
||||
ret = comps2.fromxml_f(fname)
|
||||
self.assertTrue(ret == 0, comps2.get_last_errors())
|
||||
|
||||
- compsdoc = comps2.xml_str()
|
||||
- compsdoc = compsdoc[0:-5] # make some error
|
||||
self.assertTrue(len(comps2.groups) == 3)
|
||||
self.assertTrue(len(comps2.categories) == 2)
|
||||
self.assertTrue(len(comps2.environments) == 0)
|
||||
|
||||
- comps3 = libcomps.Comps()
|
||||
- self.assertRaises(libcomps.ParserError, comps3.fromxml_str, compsdoc)
|
||||
-
|
||||
- self.assertTrue(len(comps3.groups) == 3)
|
||||
- self.assertTrue(len(comps3.categories) == 2)
|
||||
- self.assertTrue(len(comps3.environments) == 0)
|
||||
x = self.comps.xml_str(xml_options={})
|
||||
y = comps2.xml_str()
|
||||
|
||||
self.assertTrue(x == y)
|
||||
os.remove(fname)
|
||||
|
||||
+ compsdoc = comps2.xml_str()
|
||||
+ compsdoc = compsdoc[0:-5] # make some error
|
||||
+ comps3 = libcomps.Comps()
|
||||
+ self.assertRaises(libcomps.ParserError, comps3.fromxml_str, compsdoc)
|
||||
+
|
||||
+ INVALID_COMPS_XML = "invalid xml"
|
||||
+ comps4 = libcomps.Comps()
|
||||
+ self.assertRaises(libcomps.ParserError, comps4.fromxml_str, str(INVALID_COMPS_XML))
|
||||
+
|
||||
#@unittest.skip("")
|
||||
def test_fedora(self):
|
||||
comps = libcomps.Comps()
|
@ -1,20 +1,14 @@
|
||||
%define __cmake_in_source_build 1
|
||||
|
||||
Name: libcomps
|
||||
Version: 0.1.19
|
||||
Release: 5%{?dist}
|
||||
Version: 0.1.20
|
||||
Release: 1%{?dist}
|
||||
Summary: Comps XML file manipulation library
|
||||
|
||||
License: GPL-2.0-or-later
|
||||
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++
|
||||
BuildRequires: cmake
|
||||
BuildRequires: gcc
|
||||
@ -57,7 +51,7 @@ Documentation files for python bindings libcomps library.
|
||||
Summary: Python 3 bindings for libcomps library
|
||||
BuildRequires: python3-devel
|
||||
BuildRequires: python3-setuptools
|
||||
BuildRequires: make
|
||||
BuildRequires: make
|
||||
%{?python_provide:%python_provide python3-%{name}}
|
||||
Requires: %{name}%{?_isa} = %{version}-%{release}
|
||||
Obsoletes: platform-python-%{name} < %{version}-%{release}
|
||||
@ -122,6 +116,12 @@ popd
|
||||
%{python3_sitearch}/%{name}-%{version}-py%{python3_version}.egg-info
|
||||
|
||||
%changelog
|
||||
* Thu Oct 05 2023 Jan Kolarik <jkolarik@redhat.com> - 0.1.20-1
|
||||
- Update to 0.1.20
|
||||
- Fixes of xml parsing
|
||||
- Fix non-optimized builds by removing inline keyword
|
||||
- Use Py_hash_t instead of long
|
||||
|
||||
* Wed Oct 04 2023 Mattia Verga <mattia.verga@proton.me> - 0.1.19-5
|
||||
- Backport additional patch to fix segfault in fromxml_str
|
||||
|
||||
|
2
sources
2
sources
@ -1 +1 @@
|
||||
SHA512 (libcomps-0.1.19.tar.gz) = a85a0d0e3ea4f944464908a7a95da52f7d28978e0894af2e113d7929cf7bc96685e4b54e4ddff184af6ce1cfa08391fe94a1f6ec97992b3640d693d0ef07ee2e
|
||||
SHA512 (libcomps-0.1.20.tar.gz) = 02708343a9ab2ee290eb1e0ac6056658f95b84e5008c4abc1e5225c83f80edf109b40da4b44c461db5f1cc8d0620f0b6c452c101203c42f1764eb575741936a7
|
||||
|
Loading…
Reference in New Issue
Block a user