File pacemaker#3361-0001-Low-libcrmcommon-Don-t-try-to-parse-XML-from-bad-.bz.patch of Package pacemaker

From f5bc32650abf0ebe2d3ad8e4f1d85e5a2965c841 Mon Sep 17 00:00:00 2001
From: Reid Wahl <nrwahl@protonmail.com>
Date: Fri, 9 Feb 2024 12:34:44 -0800
Subject: [PATCH 1/2] Low: libcrmcommon: Don't try to parse XML from bad .bz2
 file

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
---
 lib/common/xml.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Index: pacemaker-2.1.7+20231219.0f7f88312/lib/common/xml.c
===================================================================
--- pacemaker-2.1.7+20231219.0f7f88312.orig/lib/common/xml.c
+++ pacemaker-2.1.7+20231219.0f7f88312/lib/common/xml.c
@@ -1036,19 +1036,21 @@ filename2xml(const char *filename)
     } else {
         char *input = decompress_file(filename);
 
-        output = xmlCtxtReadDoc(ctxt, (pcmkXmlStr) input, NULL, NULL,
-                                PCMK__XML_PARSE_OPTS_WITHOUT_RECOVER);
-
-        if (output == NULL) {
+        if (input != NULL) {
             output = xmlCtxtReadDoc(ctxt, (pcmkXmlStr) input, NULL, NULL,
-                                    PCMK__XML_PARSE_OPTS_WITH_RECOVER);
-            if (output) {
-                crm_warn("Successfully recovered from XML errors "
-                         "(note: a future release will treat this as a fatal failure)");
-            }
-        }        
+                                    PCMK__XML_PARSE_OPTS_WITHOUT_RECOVER);
+
+            if (output == NULL) {
+                output = xmlCtxtReadDoc(ctxt, (pcmkXmlStr) input, NULL, NULL,
+                                        PCMK__XML_PARSE_OPTS_WITH_RECOVER);
+                if (output) {
+                    crm_warn("Successfully recovered from XML errors "
+                             "(note: a future release will treat this as a fatal failure)");
+                }
+            }        
 
-        free(input);
+            free(input);
+        }
     }
 
     if (output && (xml = xmlDocGetRootElement(output))) {
openSUSE Build Service is sponsored by