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

SourceForge.net noreply at sourceforge.net
Fri Feb 6 17:29:47 CET 2004


Bugs item #892205, was opened at 2004-02-06 17:28
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=892205&group_id=29880

Category: Argument proccessing
Group: CVS
Status: Open
Resolution: None
Priority: 5
Submitted By: Patrick McCormick (patrickmc)
Assigned to: Nobody/Anonymous (nobody)
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).


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

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