diff --git a/expat-2.2.10-prevent-integer-overflow-in-doProlog.patch b/expat-2.2.10-prevent-integer-overflow-in-doProlog.patch new file mode 100644 index 0000000..af9c73c --- /dev/null +++ b/expat-2.2.10-prevent-integer-overflow-in-doProlog.patch @@ -0,0 +1,42 @@ +From ede41d1e186ed2aba88a06e84cac839b770af3a1 Mon Sep 17 00:00:00 2001 +From: Sebastian Pipping +Date: Wed, 26 Jan 2022 02:36:43 +0100 +Subject: [PATCH 1/2] lib: Prevent integer overflow in doProlog + (CVE-2022-23990) + +The change from "int nameLen" to "size_t nameLen" +addresses the overflow on "nameLen++" in code +"for (; name[nameLen++];)" right above the second +change in the patch. +--- + expat/lib/xmlparse.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/lib/xmlparse.c b/lib/xmlparse.c +index 5ce31402..d1d17005 100644 +--- a/lib/xmlparse.c ++++ b/lib/xmlparse.c +@@ -5372,7 +5372,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, + if (dtd->in_eldecl) { + ELEMENT_TYPE *el; + const XML_Char *name; +- int nameLen; ++ size_t nameLen; + const char *nxt + = (quant == XML_CQUANT_NONE ? next : next - enc->minBytesPerChar); + int myindex = nextScaffoldPart(parser); +@@ -5388,7 +5388,13 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end, + nameLen = 0; + for (; name[nameLen++];) + ; +- dtd->contentStringLen += nameLen; ++ ++ /* Detect and prevent integer overflow */ ++ if (nameLen > UINT_MAX - dtd->contentStringLen) { ++ return XML_ERROR_NO_MEMORY; ++ } ++ ++ dtd->contentStringLen += (unsigned)nameLen; + if (parser->m_elementDeclHandler) + handleDefault = XML_FALSE; + } diff --git a/expat-2.2.3-fixtests.patch b/expat-2.2.3-fixtests.patch deleted file mode 100644 index 9b20f79..0000000 --- a/expat-2.2.3-fixtests.patch +++ /dev/null @@ -1,14 +0,0 @@ - -https://github.com/libexpat/libexpat/pull/109 - ---- libexpat-R_2_2_3/expat/tests/runtests.c.fixtests -+++ libexpat-R_2_2_3/expat/tests/runtests.c -@@ -5671,7 +5671,7 @@ static int XMLCALL - prefix_converter(void *UNUSED_P(data), const char *s) - { - /* If the first byte is 0xff, raise an error */ -- if (s[0] == -1) -+ if (s[0] == (char)-1) - return -1; - /* Just add the low bits of the first byte to the second */ - return (s[1] + (s[0] & 0x7f)) & 0x01ff; diff --git a/expat.spec b/expat.spec index 441be15..5096246 100644 --- a/expat.spec +++ b/expat.spec @@ -3,12 +3,13 @@ Summary: An XML parser library Name: expat Version: %(echo %{unversion} | sed 's/_/./g') -Release: 4%{?dist} +Release: 5%{?dist} Source: https://github.com/libexpat/libexpat/archive/R_%{unversion}.tar.gz#/expat-%{version}.tar.gz URL: https://libexpat.github.io/ License: MIT BuildRequires: autoconf, libtool, xmlto, gcc-c++ BuildRequires: make +Patch0: expat-2.2.10-prevent-integer-overflow-in-doProlog.patch %description This is expat, the C library for parsing XML, written by James Clark. Expat @@ -36,6 +37,7 @@ Install it if you need to link statically with expat. %prep %setup -q -n libexpat-R_%{unversion}/expat +%patch0 -p1 -b .CVE-2022-23990 sed -i 's/install-data-hook/do-nothing-please/' lib/Makefile.am ./buildconf.sh @@ -72,6 +74,10 @@ make check %{_libdir}/lib*.a %changelog +* Mon Feb 07 2022 Tomas Korbar - 2.2.10-5 +- CVE-2022-23990 expat: integer overflow in the doProlog function +- Resolve: rhbz#2050503 + * Mon Aug 09 2021 Mohan Boddu - 2.2.10-4 - Rebuilt for IMA sigs, glibc 2.34, aarch64 flags Related: rhbz#1991688