teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone

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

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