File expat-CVE-2024-8176-22-c25f0ce.patch of Package expat
From c25f0cef93b561428b5327dbba61e994deb8b792 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Berkay=20Eren=20=C3=9Cr=C3=BCn?= <berkay.ueruen@siemens.com>
Date: Tue, 28 Jan 2025 11:13:15 +0100
Subject: [PATCH] Handle unreachable return locations
At some points we check m_reenter flag for return. However this flag can
never be true at these points. Therefore body of the check is never
executed. This commit excludes the body from test coverage, removes the
nextPtr update (since we faced an error, no need to update it) and
lastly makes them return XML_ERROR_UNEXPECTED_STATE as a safety net.
---
expat/lib/xmlparse.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
Index: expat-2.4.4/lib/xmlparse.c
===================================================================
--- expat-2.4.4.orig/lib/xmlparse.c
+++ expat-2.4.4/lib/xmlparse.c
@@ -2855,8 +2855,7 @@ externalEntityInitProcessor3(XML_Parser
return XML_ERROR_ABORTED;
case XML_PARSING:
if (parser->m_reenter) {
- *endPtr = next;
- return XML_ERROR_NONE;
+ return XML_ERROR_UNEXPECTED_STATE; // LCOV_EXCL_LINE
}
/* Fall through */
default:
@@ -4293,8 +4292,7 @@ doCdataSection(XML_Parser parser, const
return XML_ERROR_ABORTED;
case XML_PARSING:
if (parser->m_reenter) {
- *nextPtr = next;
- return XML_ERROR_NONE;
+ return XML_ERROR_UNEXPECTED_STATE; // LCOV_EXCL_LINE
}
/* Fall through */
default:;
@@ -5910,8 +5908,7 @@ epilogProcessor(XML_Parser parser, const
return XML_ERROR_ABORTED;
case XML_PARSING:
if (parser->m_reenter) {
- *nextPtr = next;
- return XML_ERROR_NONE;
+ return XML_ERROR_UNEXPECTED_STATE; // LCOV_EXCL_LINE
}
/* Fall through */
default:;