Nmap Development mailing list archives
Re: [nmap-svn] r34420 - nmap
From: Daniel Miller <bonsaiviking () gmail com>
Date: Thu, 16 Apr 2015 15:28:01 -0500
On Thu, Apr 16, 2015 at 11:20 AM, <commit-mailer () nmap org> wrote:
Author: paulino Date: Thu Apr 16 16:20:18 2015 New Revision: 34420 Log: Prints a friendly error message when --resume is used with other options. Fixes #84 Modified: nmap/main.cc Modified: nmap/main.cc ============================================================================== --- nmap/main.cc (original) +++ nmap/main.cc Thu Apr 16 16:20:18 2015 @@ -175,6 +175,7 @@ char *cptr; int ret; int i; + int resume; set_program_name(argv[0]); @@ -216,14 +217,22 @@ return ret; } - if (argc == 3 && strcmp("--resume", argv[1]) == 0) { - /* OK, they want to resume an aborted scan given the log file specified. - Lets gather our state from the log file */ - if (gather_logfile_resumption_state(argv[2], &myargc, &myargv) == -1) { - fatal("Cannot resume from (supposed) log file %s", argv[2]); + /* Don't allow users to use --resume with other options */ + for (i=0; i<argc; i++) { + if ( strcmp("--resume", argv[i]) == 0) { + resume = 1; + if(argc!=3) { + fatal("Cannot use --resume with other options. Usage: nmap --resume <filename>"); + } + if (gather_logfile_resumption_state(argv[i+1], &myargc, &myargv) == -1) { + fatal("Cannot resume from (supposed) log file %s", argv[i+1]); + } } - return nmap_main(myargc, myargv); } - return nmap_main(argc, argv); + if (resume == 1) { + return nmap_main(myargc, myargv); + } else { + return nmap_main(argc, argv); + } }
Paulino, While this meets the intent of the bug report, it would be a lot cleaner to just add '--resume' as a valid option in the getopt parsing in nmap.cc, and then perform the fatal() call there. That way it's clear to anyone trying to determine what '--resume' does by looking at the option parsing code; we could even have a comment that mentions that the actual implementation is in nmap_main.cc Dan
_______________________________________________ Sent through the dev mailing list https://nmap.org/mailman/listinfo/dev Archived at http://seclists.org/nmap-dev/
Current thread:
- Re: [nmap-svn] r34420 - nmap Daniel Miller (Apr 16)
- Re: [nmap-svn] r34420 - nmap Paulino Calderon Pale (Apr 16)