diff --git a/CHANGELOG b/CHANGELOG index 49ceed829..76490dae3 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,10 @@ # Nmap Changelog ($Id$); -*-text-*- +o Fixed a memory bug (access of freed memory) when loading exclude + targets with --exclude. This was reported to occasionally cause a + crash. Will Cladek reported the bug and contributed an initial + patch. [David] + Nmap 4.85BETA10 [2009-06-12] o The host discovery (ping probe) defaults have been enhanced to diff --git a/targets.cc b/targets.cc index 83b13e382..75c7acfed 100644 --- a/targets.cc +++ b/targets.cc @@ -334,22 +334,10 @@ TargetGroup* load_exclude(FILE *fExclude, char *szExclude) { error("Loaded exclude target of: %s", pc); ++i; } - - /* This is a totally cheezy hack, but since I can't use strtok_r... - * If you can think of a better way to do this, feel free to change. - * As for now, we will reset strtok each time we leave parse_expr */ - { - int hack_i; - char *hack_c = strdup(szExclude); - - pc=strtok(hack_c, ","); - - for (hack_i = 0; hack_i < i; hack_i++) - pc=strtok(NULL, ","); - - free(hack_c); - } - } + pc=strtok(NULL, ","); + } + free(p_acBuf); + p_acBuf = NULL; } return excludelist; }