diff --git a/backport-xpath-Fix-build-without-LIBXML_XPATH_ENABLED.patch b/backport-xpath-Fix-build-without-LIBXML_XPATH_ENABLED.patch new file mode 100644 index 0000000000000000000000000000000000000000..d428ec3c0456a528af63c9e010afb0de5512c5d3 --- /dev/null +++ b/backport-xpath-Fix-build-without-LIBXML_XPATH_ENABLED.patch @@ -0,0 +1,219 @@ +From 01723fc68f8be8ee9b986f3266c81013f8f66d03 Mon Sep 17 00:00:00 2001 +From: Nick Wellnhofer +Date: Mon, 8 May 2023 23:12:33 +0200 +Subject: [PATCH] xpath: Fix build without LIBXML_XPATH_ENABLED + +Move static function declaration into XPATH block. Also move comparison +functions. + +Fixes #537. + +--- + xpath.c | 184 ++++++++++++++++++++++++++++---------------------------- + 1 file changed, 92 insertions(+), 92 deletions(-) + +diff --git a/xpath.c b/xpath.c +index a832722..cbdff93 100644 +--- a/xpath.c ++++ b/xpath.c +@@ -153,6 +153,98 @@ + * any use of the macros IS_ASCII_CHARACTER and IS_ASCII_DIGIT) + */ + ++#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) ++ ++/************************************************************************ ++ * * ++ * Floating point stuff * ++ * * ++ ************************************************************************/ ++ ++double xmlXPathNAN = 0.0; ++double xmlXPathPINF = 0.0; ++double xmlXPathNINF = 0.0; ++ ++/** ++ * xmlXPathInit: ++ * ++ * Initialize the XPath environment ++ */ ++ATTRIBUTE_NO_SANITIZE("float-divide-by-zero") ++void ++xmlXPathInit(void) { ++ /* MSVC doesn't allow division by zero in constant expressions. */ ++ double zero = 0.0; ++ xmlXPathNAN = 0.0 / zero; ++ xmlXPathPINF = 1.0 / zero; ++ xmlXPathNINF = -xmlXPathPINF; ++} ++ ++/** ++ * xmlXPathIsNaN: ++ * @val: a double value ++ * ++ * Returns 1 if the value is a NaN, 0 otherwise ++ */ ++int ++xmlXPathIsNaN(double val) { ++#ifdef isnan ++ return isnan(val); ++#else ++ return !(val == val); ++#endif ++} ++ ++/** ++ * xmlXPathIsInf: ++ * @val: a double value ++ * ++ * Returns 1 if the value is +Infinite, -1 if -Infinite, 0 otherwise ++ */ ++int ++xmlXPathIsInf(double val) { ++#ifdef isinf ++ return isinf(val) ? (val > 0 ? 1 : -1) : 0; ++#else ++ if (val >= xmlXPathPINF) ++ return 1; ++ if (val <= -xmlXPathPINF) ++ return -1; ++ return 0; ++#endif ++} ++ ++#endif /* SCHEMAS or XPATH */ ++ ++#ifdef LIBXML_XPATH_ENABLED ++ ++/* ++ * TODO: when compatibility allows remove all "fake node libxslt" strings ++ * the test should just be name[0] = ' ' ++ */ ++#ifdef DEBUG_XPATH_EXPRESSION ++#define DEBUG_STEP ++#define DEBUG_EXPR ++#define DEBUG_EVAL_COUNTS ++#endif ++ ++static xmlNs xmlXPathXMLNamespaceStruct = { ++ NULL, ++ XML_NAMESPACE_DECL, ++ XML_XML_NAMESPACE, ++ BAD_CAST "xml", ++ NULL, ++ NULL ++}; ++static xmlNsPtr xmlXPathXMLNamespace = &xmlXPathXMLNamespaceStruct; ++#ifndef LIBXML_THREAD_ENABLED ++/* ++ * Optimizer is disabled only when threaded apps are detected while ++ * the library ain't compiled for thread safety. ++ */ ++static int xmlXPathDisableOptimizer = 0; ++#endif ++ + static void + xmlXPathNodeSetClear(xmlNodeSetPtr set, int hasNsNodes); + +@@ -483,98 +575,6 @@ int wrap_cmp( xmlNodePtr x, xmlNodePtr y ); + #include "timsort.h" + #endif /* WITH_TIM_SORT */ + +-#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) +- +-/************************************************************************ +- * * +- * Floating point stuff * +- * * +- ************************************************************************/ +- +-double xmlXPathNAN = 0.0; +-double xmlXPathPINF = 0.0; +-double xmlXPathNINF = 0.0; +- +-/** +- * xmlXPathInit: +- * +- * Initialize the XPath environment +- */ +-ATTRIBUTE_NO_SANITIZE("float-divide-by-zero") +-void +-xmlXPathInit(void) { +- /* MSVC doesn't allow division by zero in constant expressions. */ +- double zero = 0.0; +- xmlXPathNAN = 0.0 / zero; +- xmlXPathPINF = 1.0 / zero; +- xmlXPathNINF = -xmlXPathPINF; +-} +- +-/** +- * xmlXPathIsNaN: +- * @val: a double value +- * +- * Returns 1 if the value is a NaN, 0 otherwise +- */ +-int +-xmlXPathIsNaN(double val) { +-#ifdef isnan +- return isnan(val); +-#else +- return !(val == val); +-#endif +-} +- +-/** +- * xmlXPathIsInf: +- * @val: a double value +- * +- * Returns 1 if the value is +Infinite, -1 if -Infinite, 0 otherwise +- */ +-int +-xmlXPathIsInf(double val) { +-#ifdef isinf +- return isinf(val) ? (val > 0 ? 1 : -1) : 0; +-#else +- if (val >= xmlXPathPINF) +- return 1; +- if (val <= -xmlXPathPINF) +- return -1; +- return 0; +-#endif +-} +- +-#endif /* SCHEMAS or XPATH */ +- +-#ifdef LIBXML_XPATH_ENABLED +- +-/* +- * TODO: when compatibility allows remove all "fake node libxslt" strings +- * the test should just be name[0] = ' ' +- */ +-#ifdef DEBUG_XPATH_EXPRESSION +-#define DEBUG_STEP +-#define DEBUG_EXPR +-#define DEBUG_EVAL_COUNTS +-#endif +- +-static xmlNs xmlXPathXMLNamespaceStruct = { +- NULL, +- XML_NAMESPACE_DECL, +- XML_XML_NAMESPACE, +- BAD_CAST "xml", +- NULL, +- NULL +-}; +-static xmlNsPtr xmlXPathXMLNamespace = &xmlXPathXMLNamespaceStruct; +-#ifndef LIBXML_THREAD_ENABLED +-/* +- * Optimizer is disabled only when threaded apps are detected while +- * the library ain't compiled for thread safety. +- */ +-static int xmlXPathDisableOptimizer = 0; +-#endif +- + /************************************************************************ + * * + * Error handling routines * +-- +2.33.0 + diff --git a/libxml2.spec b/libxml2.spec index 7b6dcccb817aac6df7e861b2cccc7094391215da..3e66049b476cc39bd5a6eb65508cce1232e024b9 100644 --- a/libxml2.spec +++ b/libxml2.spec @@ -1,7 +1,7 @@ Summary: Library providing XML and HTML support Name: libxml2 Version: 2.9.14 -Release: 12 +Release: 13 License: MIT Group: Development/Libraries Source: https://download.gnome.org/sources/%{name}/2.9/%{name}-%{version}.tar.xz @@ -223,6 +223,7 @@ Patch6198: backport-entities-Don-t-allow-null-name-in-xmlNewEntity.patch Patch6199: backport-save-Check-for-NULL-node-name-in-xhtmlIsEmpty.patch Patch6200: backport-valid-Check-for-NULL-node-name-in-xmlSnprintfElement.patch Patch6201: backport-CVE-2024-34459.patch +Patch6202: backport-xpath-Fix-build-without-LIBXML_XPATH_ENABLED.patch BuildRoot: %{_tmppath}/%{name}-%{version}-root BuildRequires: python3-devel @@ -378,6 +379,12 @@ rm -fr %{buildroot} %changelog +* Sat May 18 2024 zhuofeng - 2.9.14-13 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:backport upstream patches + * Thu May 16 2024 cenhuilin - 2.9.14-12 - Type:CVE - CVE:CVE-2024-34459