From a0f101cb5cffcb019ce81401d1d184f20a11f4c0 Mon Sep 17 00:00:00 2001 From: david Date: Tue, 31 Mar 2009 04:32:38 +0000 Subject: [PATCH] Don't use strtok to parse the argument to --script. Because strtok inserts null characters it was effectively truncating the option argument value after it was done with it. So --script=a,b,c would become --script=a in log files. --- NmapOps.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/NmapOps.cc b/NmapOps.cc index 6020d15b0..63828a413 100644 --- a/NmapOps.cc +++ b/NmapOps.cc @@ -563,12 +563,17 @@ void NmapOps::setSpoofMACAddress(u8 *mac_data) { #ifndef NOLUA void NmapOps::chooseScripts(char* argument) { - char *ap; + char *p; - ap = strtok(argument, ","); - while(ap != NULL) { - chosenScripts.push_back(std::string(ap)); - ap = strtok(NULL, ","); + for (;;) { + p = strchr(argument, ','); + if (p == NULL) { + chosenScripts.push_back(std::string(argument)); + break; + } else { + chosenScripts.push_back(std::string(argument, p - argument)); + argument = p + 1; + } } } #endif