From 413af1955538b06803458c628099f1ba9da1966b Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Fri, 4 Nov 2022 16:51:32 +0100 Subject: Remove trailing whitespaces --- plugins-root/check_icmp.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'plugins-root') diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index f8f15351..abd88c4e 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c @@ -1,39 +1,39 @@ /***************************************************************************** -* +* * Monitoring check_icmp plugin -* +* * License: GPL * Copyright (c) 2005-2008 Monitoring Plugins Development Team * Original Author : Andreas Ericsson -* +* * Description: -* +* * This file contains the check_icmp plugin -* +* * Relevant RFC's: 792 (ICMP), 791 (IP) -* +* * This program was modeled somewhat after the check_icmp program, * which was in turn a hack of fping (www.fping.org) but has been * completely rewritten since to generate higher precision rta values, * and support several different modes as well as setting ttl to control. * redundant routes. The only remainders of fping is currently a few * function names. -* -* +* +* * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. -* +* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. -* +* * You should have received a copy of the GNU General Public License * along with this program. If not, see . -* -* +* +* *****************************************************************************/ /* progname may change */ -- cgit v1.2.3-74-g34f1 From 7d074091dba8c1d4081971bf62e694d0b1a03d41 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Fri, 4 Nov 2022 16:53:57 +0100 Subject: Remove hardcoded DBL_MAX definition --- plugins-root/check_icmp.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'plugins-root') diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index abd88c4e..0d10d22d 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c @@ -95,10 +95,6 @@ const char *email = "devel@monitoring-plugins.org"; # define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 #endif -#ifndef DBL_MAX -# define DBL_MAX 9.9999999999e999 -#endif - typedef unsigned short range_t; /* type for get_range() -- unimplemented */ typedef struct rta_host { -- cgit v1.2.3-74-g34f1 From 9a73a94258689cd9337fe7a7937fe85e4670aaeb Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Fri, 4 Nov 2022 17:08:36 +0100 Subject: Replace DBL_MAX with INFITY to check if value was set --- plugins-root/check_icmp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'plugins-root') diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index 0d10d22d..7f3c4b5b 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c @@ -55,6 +55,7 @@ const char *email = "devel@monitoring-plugins.org"; #include #include #include +#include #include #include #include @@ -1220,7 +1221,7 @@ finish(int sig) host->rta / 1000, (float)warn.rta / 1000, (float)crit.rta / 1000, (targets > 1) ? host->name : "", host->pl, warn.pl, crit.pl, (targets > 1) ? host->name : "", (float)host->rtmax / 1000, - (targets > 1) ? host->name : "", (host->rtmin < DBL_MAX) ? (float)host->rtmin / 1000 : (float)0); + (targets > 1) ? host->name : "", (host->rtmin < INFINITY) ? (float)host->rtmin / 1000 : (float)0); host = host->next; } @@ -1323,7 +1324,7 @@ add_target_ip(char *arg, struct sockaddr_storage *in) memcpy(host_sin6->sin6_addr.s6_addr, sin6->sin6_addr.s6_addr, sizeof host_sin6->sin6_addr.s6_addr); } - host->rtmin = DBL_MAX; + host->rtmin = INFINITY; if(!list) list = cursor = host; else cursor->next = host; -- cgit v1.2.3-74-g34f1 From e5db81bb29544b1be6500ad4a4dec5b4002c9962 Mon Sep 17 00:00:00 2001 From: Aksel Sjögren Date: Tue, 29 Nov 2022 13:55:32 +0100 Subject: 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(-) (limited to 'plugins-root') diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index f8f15351..1f87b75f 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); -- cgit v1.2.3-74-g34f1 From f79eb4f2caf168e0599be3702244771791e23934 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Wed, 1 Feb 2023 00:57:42 +0100 Subject: Link plugins against libcrypto to make hashes available --- plugins-root/Makefile.am | 2 +- plugins/Makefile.am | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'plugins-root') diff --git a/plugins-root/Makefile.am b/plugins-root/Makefile.am index 7cd2675a..40aa020d 100644 --- a/plugins-root/Makefile.am +++ b/plugins-root/Makefile.am @@ -26,7 +26,7 @@ EXTRA_PROGRAMS = pst3 EXTRA_DIST = t pst3.c -BASEOBJS = ../plugins/utils.o ../lib/libmonitoringplug.a ../gl/libgnu.a +BASEOBJS = ../plugins/utils.o ../lib/libmonitoringplug.a ../gl/libgnu.a $(LIB_CRYPTO) NETOBJS = ../plugins/netutils.o $(BASEOBJS) $(EXTRA_NETOBJS) NETLIBS = $(NETOBJS) $(SOCKETLIBS) diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 3fde54d6..ab59eb73 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -51,10 +51,10 @@ noinst_LIBRARIES = libnpcommon.a libnpcommon_a_SOURCES = utils.c netutils.c sslutils.c runcmd.c \ popen.c utils.h netutils.h popen.h common.h runcmd.c runcmd.h -BASEOBJS = libnpcommon.a ../lib/libmonitoringplug.a ../gl/libgnu.a +BASEOBJS = libnpcommon.a ../lib/libmonitoringplug.a ../gl/libgnu.a $(LIB_CRYPTO) NETOBJS = $(BASEOBJS) $(EXTRA_NETOBLS) NETLIBS = $(NETOBJS) $(SOCKETLIBS) -SSLOBJS = $(BASEOBJS) $(NETLIBS) $(SSLLIBS) +SSLOBJS = $(BASEOBJS) $(NETLIBS) $(SSLLIBS) $(LIB_CRYPTO) TESTS_ENVIRONMENT = perl -I $(top_builddir) -I $(top_srcdir) -- cgit v1.2.3-74-g34f1 From d3a4bad51d72a3c5bcc06ceb5e0a823dcc24bf49 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 19 Feb 2023 14:31:21 +0100 Subject: check_icmp: Fix compiler warning This fixes a compiler warning with no real world impact. The compiler complains about a missing return, which is correct, but in that scenario the program would crash anyways, so this has no impact. --- plugins-root/check_icmp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'plugins-root') diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index 7f3c4b5b..317cd535 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c @@ -1430,20 +1430,21 @@ set_source_ip(char *arg) static in_addr_t get_ip_address(const char *ifname) { + // TODO: Rewrite this so the function return an error and we exit somewhere else + struct sockaddr_in ip; #if defined(SIOCGIFADDR) struct ifreq ifr; - struct sockaddr_in ip; strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1); ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; if(ioctl(icmp_sock, SIOCGIFADDR, &ifr) == -1) crash("Cannot determine IP address of interface %s", ifname); memcpy(&ip, &ifr.ifr_addr, sizeof(ip)); - return ip.sin_addr.s_addr; #else errno = 0; crash("Cannot get interface IP address on this platform."); #endif + return ip.sin_addr.s_addr; } /* -- cgit v1.2.3-74-g34f1 From 423284edfa980fc3fdb51ab20af96685a988ba97 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 19 Feb 2023 14:34:29 +0100 Subject: check_icmp: Fix compiler warning This fixes a compiler warning which complains about an uninitialized value for a variable which is then returned. This had no real world impact, since the program would crash in the branch where result is not set. The variable is initialized to "-1" which would be the error for inet_pton. --- plugins-root/check_icmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins-root') diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c index 317cd535..e59e92d3 100644 --- a/plugins-root/check_icmp.c +++ b/plugins-root/check_icmp.c @@ -1339,7 +1339,7 @@ add_target_ip(char *arg, struct sockaddr_storage *in) static int add_target(char *arg) { - int error, result; + int error, result = -1; struct sockaddr_storage ip; struct addrinfo hints, *res, *p; struct sockaddr_in *sin; -- cgit v1.2.3-74-g34f1