Blob Blame History Raw
From 911a4f253c7213a8570028a7dc2a20b045de8e9e Mon Sep 17 00:00:00 2001
Message-ID: <911a4f253c7213a8570028a7dc2a20b045de8e9e.1687934951.git.pmatilai@redhat.com>
From: Fabian Vogt <fvogt@suse.de>
Date: Mon, 26 Jun 2023 16:28:07 +0200
Subject: [PATCH] Actually return an error in parseScript if parsing fails

The return value is stored in the "res" variable which is set to the return
value of parseLines early in the function. Past that point, any "goto exit;"
caused the function to return success. This was introduced by 52ce88851abb
("Port parseScript() to use parseLines(), no functional changes"). To fix it,
reintroduce the nextPart variable.
---
 build/parseScript.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/build/parseScript.c b/build/parseScript.c
index f8b693ac6..6f3dc2fe8 100644
--- a/build/parseScript.c
+++ b/build/parseScript.c
@@ -95,7 +95,7 @@ int parseScript(rpmSpec spec, int parsePart)
     int index;
     char * reqargs = NULL;
 
-    int res = PART_ERROR; /* assume failure */
+    int nextPart, res = PART_ERROR; /* assume failure */
     int rc, argc;
     int arg;
     const char **argv = NULL;
@@ -367,7 +367,7 @@ int parseScript(rpmSpec spec, int parsePart)
 	goto exit;
     }
 
-    if ((res = parseLines(spec, STRIP_NOTHING, NULL, &sb)) == PART_ERROR)
+    if ((nextPart = parseLines(spec, STRIP_NOTHING, NULL, &sb)) == PART_ERROR)
 	goto exit;
 
     if (sb) {
@@ -479,6 +479,8 @@ int parseScript(rpmSpec spec, int parsePart)
 	}
     }
 
+    res = nextPart;
+
 exit:
     free(reqargs);
     freeStringBuf(sb);
-- 
2.41.0