From 76475e98e48129f69791cfc2e66d0c7b6f98be11 Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Mon, 19 Dec 2022 11:21:56 +0000 Subject: [PATCH] Adding d/p/18_check_icmp_help from upstream --- debian/patches/18_check_icmp_help | 59 +++++++++++++++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 60 insertions(+) create mode 100644 debian/patches/18_check_icmp_help diff --git a/debian/patches/18_check_icmp_help b/debian/patches/18_check_icmp_help new file mode 100644 index 0000000..6e2f64f --- /dev/null +++ b/debian/patches/18_check_icmp_help @@ -0,0 +1,59 @@ +From e5db81bb29544b1be6500ad4a4dec5b4002c9962 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Aksel=20Sj=C3=B6gren?= +Date: Tue, 29 Nov 2022 13:55:32 +0100 +Subject: [PATCH] check_icmp: fix parsing help/version long options +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Fix parsing of the long options --help and --version. The special +handling must be done before calling getopt(). +This fixes erroneous output like: + + ./check_icmp --version + ./check_icmp: invalid option -- '-' + ./check_icmp: invalid option -- 'e' + ./check_icmp: invalid option -- 'r' + ./check_icmp: invalid option -- '-' + ./check_icmp: invalid option -- 'e' + ./check_icmp: invalid option -- 'r' + +Signed-off-by: Aksel Sjögren +--- + plugins-root/check_icmp.c | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c +index f8f153512..1f87b75f9 100644 +--- a/plugins-root/check_icmp.c ++++ b/plugins-root/check_icmp.c +@@ -451,6 +451,14 @@ main(int argc, char **argv) + packets = 5; + } + ++ /* support "--help" and "--version" */ ++ if(argc == 2) { ++ if(!strcmp(argv[1], "--help")) ++ strcpy(argv[1], "-h"); ++ if(!strcmp(argv[1], "--version")) ++ strcpy(argv[1], "-V"); ++ } ++ + /* Parse protocol arguments first */ + for(i = 1; i < argc; i++) { + while((arg = getopt(argc, argv, opts_str)) != EOF) { +@@ -555,14 +563,6 @@ main(int argc, char **argv) + /* Parse extra opts if any */ + argv=np_extra_opts(&argc, argv, progname); + +- /* support "--help" and "--version" */ +- if(argc == 2) { +- if(!strcmp(argv[1], "--help")) +- strcpy(argv[1], "-h"); +- if(!strcmp(argv[1], "--version")) +- strcpy(argv[1], "-V"); +- } +- + argv = &argv[optind]; + while(*argv) { + add_target(*argv); diff --git a/debian/patches/series b/debian/patches/series index 2e6fc7a..c91c2c7 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -6,3 +6,4 @@ 15_PRId64_PRIu64_2 16_check_pgsql_dbname_too_strict 17_check_curl_detect_ipv6 +18_check_icmp_help