Nmap Development mailing list archives

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


From: Kris Katterjohn <katterjohn () gmail com>
Date: Sat, 16 Dec 2006 13:31:00 -0600

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

Current thread: