From a028e61ae252d3231875ec4e04b7b954a84fce76 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Oct 06 2022 14:38:47 +0000 Subject: import expat-2.2.10-12.el9_0.3 --- diff --git a/SOURCES/expat-2.2.10-Ensure-raw-tagnames-are-safe-exiting-internalEntityParser.patch b/SOURCES/expat-2.2.10-Ensure-raw-tagnames-are-safe-exiting-internalEntityParser.patch new file mode 100644 index 0000000..42c4bca --- /dev/null +++ b/SOURCES/expat-2.2.10-Ensure-raw-tagnames-are-safe-exiting-internalEntityParser.patch @@ -0,0 +1,118 @@ +commit 1502af12eebfd796b1d1dbcf547c3e17200904e2 +Author: Tomas Korbar +Date: Thu Sep 29 16:09:09 2022 +0200 + + Fix CVE-2022-40674 + +diff --git a/lib/xmlparse.c b/lib/xmlparse.c +index 8e84b5a..9051ab2 100644 +--- a/lib/xmlparse.c ++++ b/lib/xmlparse.c +@@ -5555,9 +5555,14 @@ internalEntityProcessor(XML_Parser parser, const char *s, const char *end, + { + parser->m_processor = contentProcessor; + /* see externalEntityContentProcessor vs contentProcessor */ +- return doContent(parser, parser->m_parentParser ? 1 : 0, parser->m_encoding, ++ result = doContent(parser, parser->m_parentParser ? 1 : 0, parser->m_encoding, + s, end, nextPtr, + (XML_Bool)! parser->m_parsingStatus.finalBuffer); ++ if (result == XML_ERROR_NONE) { ++ if (! storeRawNames(parser)) ++ return XML_ERROR_NO_MEMORY; ++ } ++ return result; + } + } + +diff --git a/tests/runtests.c b/tests/runtests.c +index 05f3083..c886f5a 100644 +--- a/tests/runtests.c ++++ b/tests/runtests.c +@@ -5022,6 +5022,78 @@ START_TEST(test_resume_entity_with_syntax_error) { + } + END_TEST + ++void ++suspending_comment_handler(void *userData, const XML_Char *data) { ++ UNUSED_P(data); ++ XML_Parser parser = (XML_Parser)userData; ++ XML_StopParser(parser, XML_TRUE); ++} ++ ++START_TEST(test_suspend_resume_internal_entity_issue_629) { ++ const char *const text ++ = "a'>]>&e;\n" ++ "<" ++ "aaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ++ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ++ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ++ "/>" ++ ""; ++ const size_t firstChunkSizeBytes = 54; ++ ++ XML_Parser parser = XML_ParserCreate(NULL); ++ XML_SetUserData(parser, parser); ++ XML_SetCommentHandler(parser, suspending_comment_handler); ++ ++ if (XML_Parse(parser, text, (int)firstChunkSizeBytes, XML_FALSE) ++ != XML_STATUS_SUSPENDED) ++ xml_failure(parser); ++ if (XML_ResumeParser(parser) != XML_STATUS_OK) ++ xml_failure(parser); ++ if (XML_Parse(parser, text + firstChunkSizeBytes, ++ (int)(strlen(text) - firstChunkSizeBytes), XML_TRUE) ++ != XML_STATUS_OK) ++ xml_failure(parser); ++ XML_ParserFree(parser); ++} ++END_TEST ++ + /* Test suspending and resuming in a parameter entity substitution */ + static void XMLCALL + element_decl_suspender(void *userData, const XML_Char *name, +@@ -11629,6 +11701,8 @@ make_suite(void) { + tcase_add_test(tc_basic, test_partial_char_in_epilog); + tcase_add_test(tc_basic, test_hash_collision); + tcase_add_test__ifdef_xml_dtd(tc_basic, test_suspend_resume_internal_entity); ++ tcase_add_test__ifdef_xml_dtd(tc_basic, ++ test_suspend_resume_internal_entity_issue_629); + tcase_add_test__ifdef_xml_dtd(tc_basic, test_resume_entity_with_syntax_error); + tcase_add_test__ifdef_xml_dtd(tc_basic, test_suspend_resume_parameter_entity); + tcase_add_test(tc_basic, test_restart_on_error); diff --git a/SPECS/expat.spec b/SPECS/expat.spec index 8752e1e..7508f94 100644 --- a/SPECS/expat.spec +++ b/SPECS/expat.spec @@ -3,7 +3,7 @@ Summary: An XML parser library Name: expat Version: %(echo %{unversion} | sed 's/_/./g') -Release: 12%{?dist}.2 +Release: 12%{?dist}.3 Source: https://github.com/libexpat/libexpat/archive/R_%{unversion}.tar.gz#/expat-%{version}.tar.gz URL: https://libexpat.github.io/ License: MIT @@ -19,6 +19,7 @@ Patch6: expat-2.2.10-Add-missing-validation-of-encoding.patch Patch7: expat-2.2.10-Prevent-integer-overflow-in-storeRawNames.patch Patch8: expat-2.2.10-Prevent-integer-overflow-in-copyString.patch Patch9: expat-2.2.10-Prevent-stack-exhaustion-in-build_model.patch +Patch10: expat-2.2.10-Ensure-raw-tagnames-are-safe-exiting-internalEntityParser.patch %description This is expat, the C library for parsing XML, written by James Clark. Expat @@ -56,6 +57,7 @@ Install it if you need to link statically with expat. %patch7 -p1 -b .CVE-2022-25315 %patch8 -p1 -b .CVE-2022-25314 %patch9 -p1 -b .CVE-2022-25313 +%patch10 -p1 -b .CVE-2022-40674 sed -i 's/install-data-hook/do-nothing-please/' lib/Makefile.am ./buildconf.sh @@ -93,6 +95,10 @@ make check %{_libdir}/lib*.a %changelog +* Thu Sep 29 2022 Tomas Korbar - 2.2.10-12.3 +- Ensure raw tagnames are safe exiting internalEntityParser +- Resolves: CVE-2022-40674 + * Tue May 03 2022 Tomas Korbar - 2.2.10-12.2 - Improve fix for CVE-2022-25313 - Related: CVE-2022-25313