Blame SOURCES/libkcapi-1.1.1-kcapi-hasher_Fix_command-line_parsing.patch

b09f25
From 912ab6d55ef5af594d22d01a39cf7e035c797335 Mon Sep 17 00:00:00 2001
b09f25
From: Ondrej Mosnacek <omosnace@redhat.com>
b09f25
Date: Wed, 11 Jul 2018 09:42:26 +0200
b09f25
Subject: [PATCH] kcapi-hasher: Fix command-line parsing
b09f25
b09f25
I made a mistake in commit 3be3e18d4a2e ("kcapi-hasher: Allow picking
b09f25
basename via cmdline"), which apparently broke command-line parsing when
b09f25
the '-n' options is not used. This patch fixes the issue by resetting
b09f25
the right variable and also silences error messages when checking for
b09f25
the '-n' option.
b09f25
b09f25
Fedora BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1599831
b09f25
---
b09f25
 apps/kcapi-hasher.c | 4 +++-
b09f25
 1 file changed, 3 insertions(+), 1 deletion(-)
b09f25
b09f25
diff --git a/apps/kcapi-hasher.c b/apps/kcapi-hasher.c
b09f25
index ae88211..90707a6 100644
b09f25
--- a/apps/kcapi-hasher.c
b09f25
+++ b/apps/kcapi-hasher.c
b09f25
@@ -841,10 +841,12 @@ int main(int argc, char *argv[])
b09f25
 	}
b09f25
 	basen = basename(basec);
b09f25
 
b09f25
+	opterr = 0;
b09f25
 	if (getopt_long(argc, argv, opts_name_short, opts_name, &opt_index) == 'n')
b09f25
 		basen = optarg;
b09f25
 	else
b09f25
-		opt_index = 0;
b09f25
+		optind = 1;
b09f25
+	opterr = 1;
b09f25
 
b09f25
 	params_self = &PARAMS_SELF_FIPSCHECK;
b09f25
 	if (0 == strncmp(basen, "sha256sum", 9)) {