From 6ef57910ab380179fb5d34fa032b30d4786c67fc Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Mon, 17 Apr 2023 13:01:05 +0200 Subject: [PATCH] abuild-tar: improve invalid opt handling make sure we always print usage help text if we have an invalid option. fixes https://gitlab.alpinelinux.org/alpine/abuild/-/issues/10101 --- abuild-tar.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/abuild-tar.c b/abuild-tar.c index c509d63..aa88cb4 100644 --- a/abuild-tar.c +++ b/abuild-tar.c @@ -385,7 +385,10 @@ int main(int argc, char **argv) ENGINE_register_all_complete(); #endif - while (getopt_long(argc, argv, "", options, &ndx) != -1) { + int c; + while ((c = getopt_long(argc, argv, "", options, &ndx)) != -1) { + if (c == '?') + return usage(stderr); if (ndx == 0) digest = optarg ? optarg : "sha1"; }