Perry Hooker
2013-05-15 23:11:38 UTC
I've run in to some problems using nping 0.6.25 with the command-line option to set the source IP address (-S, --source-ip) on CentOS 6.2. Specifically, when I specify a numeric source IP address, e.g.
$ nping -c 1 -S 192.168.1.1 127.0.0.1
I get the error message
WARNING: No targets specified, so 0 hosts pinged.
However, the command
$ nping -c 1 -S random 127.0.0.1
functions as expected.
An examination of the
case 'S':
clause in ArgParser.cc reveals that the value of argc is reset to 0 by the call to atoIP. This causes the grab_next_host_spec method in netutil.cc to return NULL before parsing the target argument. Changing the line in grab_next_host_spec function from
return( (optind < argc) ? fakeargv[optind++] : NULL);
to
return fakeargv[optind++];
seems to work around the problem, but I'm unclear as to why this does NOT result in an infinite loop during parsing of target host specifications (at the end of the parseArguments method in ArgParser.cc). Removing the line
fakeargv[argc] = NULL;
in nmap.cc doesn't seem to change this behavior. I'm also not sure why the value of argc is modified in the first place. I suspect it's related to the getopt family of functions, but I'm not sure. Guidance / corrections to my reasoning much appreciated.
rphv
$ nping -c 1 -S 192.168.1.1 127.0.0.1
I get the error message
WARNING: No targets specified, so 0 hosts pinged.
However, the command
$ nping -c 1 -S random 127.0.0.1
functions as expected.
An examination of the
case 'S':
clause in ArgParser.cc reveals that the value of argc is reset to 0 by the call to atoIP. This causes the grab_next_host_spec method in netutil.cc to return NULL before parsing the target argument. Changing the line in grab_next_host_spec function from
return( (optind < argc) ? fakeargv[optind++] : NULL);
to
return fakeargv[optind++];
seems to work around the problem, but I'm unclear as to why this does NOT result in an infinite loop during parsing of target host specifications (at the end of the parseArguments method in ArgParser.cc). Removing the line
fakeargv[argc] = NULL;
in nmap.cc doesn't seem to change this behavior. I'm also not sure why the value of argc is modified in the first place. I suspect it's related to the getopt family of functions, but I'm not sure. Guidance / corrections to my reasoning much appreciated.
rphv