From 6a939fa1bacd90b64a8e09939ee06223330f7567 Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Tue, 5 May 2015 14:56:31 +0200 Subject: Fixes segfaults when running via monitoring worker (off-by-one) Grabed from https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=198318 --- plugins-root/check_dhcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins-root') diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c index b874c555..5508d5f9 100644 --- a/plugins-root/check_dhcp.c +++ b/plugins-root/check_dhcp.c @@ -1182,7 +1182,7 @@ int call_getopt(int argc, char **argv){ } } - return i; + return i+1; } -- cgit v1.2.3-74-g34f1 From 466cb79e5224327c29fc6b84a1cec99c2b190c5a Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Fri, 2 Oct 2015 12:18:13 +0200 Subject: check_dhcp: Fix option parsing The call_getopt() function didn't always return the correct number of processed arguments. However, since check_dhcp doesn't support non-option arguments, the caller doesn't need this number anyway. Closes #1345. --- plugins-root/check_dhcp.c | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) (limited to 'plugins-root') diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c index 5508d5f9..25d4ed40 100644 --- a/plugins-root/check_dhcp.c +++ b/plugins-root/check_dhcp.c @@ -229,7 +229,7 @@ struct in_addr requested_address; int process_arguments(int, char **); int call_getopt(int, char **); -int validate_arguments(void); +int validate_arguments(int, int); void print_usage(void); void print_help(void); @@ -1059,29 +1059,19 @@ int get_results(void){ /* process command-line arguments */ int process_arguments(int argc, char **argv){ - int c; + int arg_index; if(argc<1) return ERROR; - c=0; - while((c+=(call_getopt(argc-c,&argv[c]))) 0) + usage(_("Got unexpected non-option argument")); return OK; } -- cgit v1.2.3-74-g34f1