From dc4e67dffcd0f78c876427bb269a55960c3422b0 Mon Sep 17 00:00:00 2001 From: colin Date: Tue, 21 Jun 2011 18:05:25 +0000 Subject: [PATCH] Fixed broken --exclude in nmap. --exclude 1.2.3.4,5.6.7.8 now works. --- targets.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/targets.cc b/targets.cc index 321633793..b5a30c1c0 100644 --- a/targets.cc +++ b/targets.cc @@ -186,9 +186,21 @@ int load_exclude_file(addrset *excludelist, FILE *fp) { /* Load a comma-separated exclude list from a string, the argument to --exclude. */ int load_exclude_string(addrset *excludelist, const char *s) { - if (!addrset_add_spec(excludelist, s, o.af(), 1)){ - fatal("Invalid address specification: %s", s); - } + const char *begin, *p; + + p = s; + while (*p != '\0') { + begin = p; + while (*p != '\0' && *p != ',') + p++; + const char * addr = std::string(begin, p - begin).c_str(); + if (!addrset_add_spec(excludelist,addr, o.af(), 1)){ + fatal("Invalid address specification: %s", addr); + } + if (*p == '\0') + break; + p++; + }; return 1; }