[Nagiosplug-devel] [ nagiosplug-Bugs-892205 ] check_ping does not handle old-style arguments

SourceForge.net noreply at sourceforge.net
Mon Feb 9 00:38:03 CET 2004


Bugs item #892205, was opened at 2004-02-07 01:28
Message generated for change (Comment added) made by tonvoon
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=892205&group_id=29880

Category: Argument proccessing
Group: CVS
>Status: Closed
Resolution: None
Priority: 5
Submitted By: Patrick McCormick (patrickmc)
>Assigned to: Ton Voon (tonvoon)
Summary: check_ping does not handle old-style arguments

Initial Comment:
My system is Solaris 7, x86, compiling with gcc 2.95.2.
 This is not a platform-specific issue.

With this old-fashioned command line, check ping will fail:

% ./check_ping somehost 90 100 5000.0 10000.0 -p 5 -v
<wpl> (somehost) must be an integer percentage
Could not parse arguments
Usage: check_ping -H <host_address> -w <wrta>,<wpl>% -c
<crta>,<cpl>%
  [-p packets] [-t timeout] [-L] [-4|-6]
       check_ping (-h | --help) for detailed help
       check_ping (-V | --version) for version information

It should properly detect that "somehost" is the host
to scan.  The code wants to do this, but there are bugs.

1. the "char **addresses" global is allocated, but not
initialized, so the check:

if (addresses[0] == NULL) {

will fail when it should succeed.

2. If you fix this (by setting addresses[0] = NULL
after the malloc) then the problem is that n_addresses
is not incremented here:

addresses[0] = argv[c++];

3. The malloc and realloc do not allocate enough space:

addresses = malloc ((size_t)max_addr);
addresses = realloc (addresses, (size_t)max_addr);

this should be (sizeof(char*) * max_addr).


----------------------------------------------------------------------

>Comment By: Ton Voon (tonvoon)
Date: 2004-02-09 08:37

Message:
Logged In: YES 
user_id=664364

Applied patch 892211 raised by Patrick. Closed.

----------------------------------------------------------------------

Comment By: Patrick McCormick (patrickmc)
Date: 2004-02-07 01:32

Message:
Logged In: YES 
user_id=363812

On cygwin, I get no output at all from the above check_ping
line, just a quick return.  By chance, addresses[0] is NULL,
but we bump into problem #2 above, and exit because
n_addresses = 0.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=892205&group_id=29880




More information about the Devel mailing list