mirror of
https://github.com/nmap/nmap.git
synced 2026-05-13 16:57:06 +00:00
Skip whole quoted program name when parsing args with --resume
This commit is contained in:
parent
7acdd4b41f
commit
aa1a94db53
1 changed files with 23 additions and 1 deletions
24
nmap.cc
24
nmap.cc
|
|
@ -2297,8 +2297,30 @@ int gather_logfile_resumption_state(char *fname, int *myargc, char ***myargv) {
|
|||
p += 5;
|
||||
else
|
||||
fatal("Unable to parse supposed log file %s. Are you sure this is an Nmap output file?", fname);
|
||||
while (*p && !isspace((int) (unsigned char) *p))
|
||||
/* Skip the program name */
|
||||
while (*p && !isspace((int) (unsigned char) *p)){
|
||||
if (*p == '"' || *p == '\'') {
|
||||
/* Quoted, so find the matching quote.
|
||||
* TODO:Doesn't handle escaped quotes, but we don't generate them either. */
|
||||
p = strchr(p+1, *p);
|
||||
if (!p) {
|
||||
fatal("Unable to parse supposed log file %s: unclosed quote.", fname);
|
||||
}
|
||||
}
|
||||
else if (!strncasecmp(p, """, 6)) {
|
||||
/* We do XML unescaping later, but this is just special case of quoted
|
||||
* program name. */
|
||||
do {
|
||||
p = strstr(p+1, "&");
|
||||
if (!p) {
|
||||
fatal("Unable to parse supposed log file %s: unclosed quote.", fname);
|
||||
}
|
||||
} while (strncasecmp(p, """, 6));
|
||||
/* Only skip to the ';', because another increment happens below. */
|
||||
p += 5;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
if (!*p)
|
||||
fatal("Unable to parse supposed log file %s. Sorry", fname);
|
||||
p++; /* Skip the space between program name and first arg */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue