teknoraver / rpms / rpm

Forked from rpms/rpm 3 months ago
Clone

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

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