Nmap Development mailing list archives

[PATCH] Remove duplicate input file code in nmap.cc


From: Kris Katterjohn <kjak () ispwest com>
Date: Sun, 01 Oct 2006 21:22:08 -0500

The attached patch removes duplicate input file code by having getopt()
return 'i' on "iL" so that the same input file code used under 'i' is
used for "iL". It's a lot simpler than I just made it out to be :)

It's a diff against 4.20ALPHA8

Thanks,
Kris Katterjohn
--- x/nmap.cc   2006-09-25 01:47:25.000000000 -0500
+++ y/nmap.cc   2006-10-01 21:14:25.000000000 -0500
@@ -521,7 +521,7 @@ int nmap_main(int argc, char *argv[]) {
       {"oS", required_argument, 0, 0},
       {"oH", required_argument, 0, 0},  
       {"oX", required_argument, 0, 0},  
-      {"iL", required_argument, 0, 0},  
+      {"iL", required_argument, 0, 'i'},  
       {"iR", required_argument, 0, 0},
       {"sI", required_argument, 0, 0},  
       {"source_port", required_argument, 0, 'g'},
@@ -753,19 +753,6 @@ int nmap_main(int argc, char *argv[]) {
        exit(0);
       } else if (strcmp(long_options[option_index].name, "badsum") == 0) {
        o.badsum = 1;
-      }
-      else if (strcmp(long_options[option_index].name, "iL") == 0) {
-       if (inputfd) {
-         fatal("Only one input filename allowed");
-       }
-       if (!strcmp(optarg, "-")) {
-         inputfd = stdin;
-       } else {    
-         inputfd = fopen(optarg, "r");
-         if (!inputfd) {
-           fatal("Failed to open input file %s for reading", optarg);
-         }  
-       }
       } else if (strcmp(long_options[option_index].name, "iR") == 0) {
        o.generate_random_ips = 1;
        o.max_ips_to_scan = strtoul(optarg, &endptr, 10);

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://SecLists.Org

Current thread: