teknoraver / rpms / rpm

Forked from rpms/rpm 2 months ago
Clone

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

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