Blame SOURCES/rpm-4.14.3-rpm2archive-parse-popt-options.patch

ea9a62
From 8f416b275a365426b07c75adfc017e0b18a85450 Mon Sep 17 00:00:00 2001
ea9a62
From: Florian Festi <ffesti@redhat.com>
ea9a62
Date: Fri, 16 Dec 2022 15:45:20 +0100
ea9a62
Subject: [PATCH] rpm2archive: Properly parse popt options
ea9a62
ea9a62
and issue an error message for unknown options. Before unknown options
ea9a62
could mess up the argument parsing leading to reading and writing from
ea9a62
stdin/stdout.
ea9a62
ea9a62
Thanks to Eva Mrakova and the Red Hat QE team for spotting this!
ea9a62
---
ea9a62
 rpm2archive.c | 8 ++++++++
ea9a62
 1 file changed, 8 insertions(+)
ea9a62
ea9a62
diff --git a/rpm2archive.c b/rpm2archive.c
ea9a62
index de1a17d2b..09da8d16b 100644
ea9a62
--- a/rpm2archive.c
ea9a62
+++ b/rpm2archive.c
ea9a62
@@ -233,6 +233,14 @@ int main(int argc, const char *argv[])
ea9a62
 
ea9a62
     optCon = poptGetContext(NULL, argc, argv, optionsTable, 0);
ea9a62
     poptSetOtherOptionHelp(optCon, "[OPTIONS]* <FILES>");
ea9a62
+    while ((rc = poptGetNextOpt(optCon)) != -1) {
ea9a62
+	if (rc < 0) {
ea9a62
+	    fprintf(stderr, "%s: %s\n",
ea9a62
+		    poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
ea9a62
+		    poptStrerror(rc));
ea9a62
+	    exit(EXIT_FAILURE);
ea9a62
+	}
ea9a62
+    }
ea9a62
     if (argc < 2 || poptGetNextOpt(optCon) == 0) {
ea9a62
 	poptPrintUsage(optCon, stderr, 0);
ea9a62
 	exit(EXIT_FAILURE);
ea9a62
-- 
ea9a62
2.38.1
ea9a62