logo       

[PATCH] Test for getopt_long_only() return value -1: msg#00075

security.nmap.devel

Subject: [PATCH] Test for getopt_long_only() return value -1

The attached patch checks for a return value of -1 instead of EOF from
getopt_long_only() in nmap.cc. While EOF is typically -1, it's not
guaranteed (and a quick glance at nbase/getopt.c shows it returns "-1").

It's a diff against 4.21ALPHA1

Thanks,
Kris Katterjohn
--- x/nmap.cc 2006-12-10 18:34:36.000000000 -0600
+++ y/nmap.cc 2006-12-16 13:24:32.000000000 -0600
@@ -613,7 +613,7 @@ int nmap_main(int argc, char *argv[]) {

/* OK, lets parse these args! */
optind = 1; /* so it can be called multiple times */
- while((arg =
getopt_long_only(argc,fakeargv,"6Ab:D:d::e:Ffg:hIi:M:m:nO::o:P:p:qRrS:s:T:Vv",
long_options, &option_index)) != EOF) {
+ while((arg =
getopt_long_only(argc,fakeargv,"6Ab:D:d::e:Ffg:hIi:M:m:nO::o:P:p:qRrS:s:T:Vv",
long_options, &option_index)) != -1) {
switch(arg) {
case 0:
#ifndef NOLUA

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise