Fix xmllint error code (RHEL-126768)

Resolves: RHEL-126768
This commit is contained in:
David King 2026-01-26 15:00:45 +00:00
parent 119e7297e5
commit c879317c75
2 changed files with 94 additions and 1 deletions

View File

@ -0,0 +1,88 @@
From 387a952bdb7a4364100f009043e94e1bf44c6197 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Mon, 12 Feb 2024 16:45:16 +0100
Subject: [PATCH] xmllint: Return error code if XPath returns empty nodeset
Return an error code as before but make it possible to distinguish from
real errors.
Fixes #690.
---
doc/xmllint.xml | 11 ++++++++++-
xmllint.c | 24 +++++++++++++-----------
2 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/doc/xmllint.xml b/doc/xmllint.xml
index b81da3aa7..8bc665216 100644
--- a/doc/xmllint.xml
+++ b/doc/xmllint.xml
@@ -575,7 +575,9 @@
result. In case of a nodeset result, each node in the
node set is serialized in full in the output. In case
of an empty node set the "XPath set is empty" result
- will be shown and an error exit code will be returned.
+ will be shown and exit code 11 will be returned..
+ This feature is EXPERIMENTAL. Implementation details can
+ change without futher notice.
</para>
</listitem>
</varlistentry>
@@ -945,6 +947,13 @@
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><errorcode>11</errorcode></term>
+ <listitem>
+ <para>XPath result is empty</para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</refsect1>
diff --git a/xmllint.c b/xmllint.c
index 21dbe7d24..5c26c3fe8 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -86,17 +86,18 @@
#endif
typedef enum {
- XMLLINT_RETURN_OK = 0, /* No error */
- XMLLINT_ERR_UNCLASS = 1, /* Unclassified */
- XMLLINT_ERR_DTD = 2, /* Error in DTD */
- XMLLINT_ERR_VALID = 3, /* Validation error */
- XMLLINT_ERR_RDFILE = 4, /* CtxtReadFile error */
- XMLLINT_ERR_SCHEMACOMP = 5, /* Schema compilation */
- XMLLINT_ERR_OUT = 6, /* Error writing output */
- XMLLINT_ERR_SCHEMAPAT = 7, /* Error in schema pattern */
- XMLLINT_ERR_RDREGIS = 8, /* Error in Reader registration */
- XMLLINT_ERR_MEM = 9, /* Out of memory error */
- XMLLINT_ERR_XPATH = 10 /* XPath evaluation error */
+ XMLLINT_RETURN_OK = 0, /* No error */
+ XMLLINT_ERR_UNCLASS = 1, /* Unclassified */
+ XMLLINT_ERR_DTD = 2, /* Error in DTD */
+ XMLLINT_ERR_VALID = 3, /* Validation error */
+ XMLLINT_ERR_RDFILE = 4, /* CtxtReadFile error */
+ XMLLINT_ERR_SCHEMACOMP = 5, /* Schema compilation */
+ XMLLINT_ERR_OUT = 6, /* Error writing output */
+ XMLLINT_ERR_SCHEMAPAT = 7, /* Error in schema pattern */
+ XMLLINT_ERR_RDREGIS = 8, /* Error in Reader registration */
+ XMLLINT_ERR_MEM = 9, /* Out of memory error */
+ XMLLINT_ERR_XPATH = 10, /* XPath evaluation error */
+ XMLLINT_ERR_XPATH_EMPTY = 11 /* XPath result is empty */
} xmllintReturnCode;
#ifdef LIBXML_DEBUG_ENABLED
static int shell = 0;
@@ -2019,6 +2020,7 @@ static void doXPathDump(xmlXPathObjectPtr cur) {
xmlOutputBufferPtr buf;
if ((cur->nodesetval == NULL) || (cur->nodesetval->nodeNr <= 0)) {
+ progresult = XMLLINT_ERR_XPATH_EMPTY;
if (!quiet) {
fprintf(stderr, "XPath set is empty\n");
}
--
GitLab

View File

@ -1,6 +1,6 @@
Name: libxml2
Version: 2.12.5
Release: 9%{?dist}
Release: 10%{?dist}
Summary: Library providing XML and HTML support
# list.c, dict.c and few others use ISC-Veillard
@ -37,6 +37,8 @@ Patch8: libxml2-2.12.5-CVE-2025-7425.patch
Patch9: libxml2-2.12.5-CVE-2025-32415.patch
# https://issues.redhat.com/browse/RHEL-99861
Patch10: libxml2-2.12.5-CVE-2025-32414.patch
# https://issues.redhat.com/browse/RHEL-126768
Patch11: libxml2-2.12.5-xmllint-error-code.patch
BuildRequires: cmake-rpm-macros
BuildRequires: gcc
@ -177,6 +179,9 @@ popd
%{python3_sitelib}/__pycache__/drv_libxml2.*
%changelog
* Mon Jan 26 2026 David King <dking@redhat.com> - 2.12.5-10
- Fix xmllint error code (RHEL-126768)
* Tue Aug 05 2025 David King <dking@redhat.com> - 2.12.5-9
- Fix CVE-2025-32415 (RHEL-100174)
- Fix CVE-2025-32414 (RHEL-99861)