Blame SOURCES/0006-Prevent-integer-overflow-on-m_groupSize-in-doProlog-.patch

35fd7a
From 06d354807ac297374973631a6418edf7e3fcbf30 Mon Sep 17 00:00:00 2001
35fd7a
From: Rob Crittenden <rcritten@redhat.com>
35fd7a
Date: Mon, 28 Feb 2022 10:43:23 -0500
35fd7a
Subject: [PATCH 6/6] Prevent integer overflow on m_groupSize in doProlog
35fd7a
 (CVE-2021-46143)
35fd7a
35fd7a
Backported from upstream https://github.com/libexpat/libexpat/pull/538
35fd7a
35fd7a
Resolves: #2058560
35fd7a
---
35fd7a
 lib/expat/xmlparse/xmlparse.c | 5 +++++
35fd7a
 1 file changed, 5 insertions(+)
35fd7a
35fd7a
diff --git a/lib/expat/xmlparse/xmlparse.c b/lib/expat/xmlparse/xmlparse.c
35fd7a
index 16ab82a..b9aa927 100644
35fd7a
--- a/lib/expat/xmlparse/xmlparse.c
35fd7a
+++ b/lib/expat/xmlparse/xmlparse.c
35fd7a
@@ -3991,6 +3991,11 @@ doProlog(XML_Parser       const xmlParserP,
35fd7a
     case XML_ROLE_GROUP_OPEN:
35fd7a
       if (prologState.level >= groupSize) {
35fd7a
         if (groupSize) {
35fd7a
+          /* Detect and prevent integer overflow */
35fd7a
+          if (groupSize > (unsigned int)(-1) / 2u) {
35fd7a
+            *errorCodeP = XML_ERROR_NO_MEMORY;
35fd7a
+            return;
35fd7a
+          }
35fd7a
           char *temp = realloc(groupConnector, groupSize *= 2);
35fd7a
           if (!temp) {
35fd7a
             *errorCodeP = XML_ERROR_NO_MEMORY;
35fd7a
-- 
35fd7a
2.31.1
35fd7a