From 13a31a8cb9772842f1d2d2d11a087cbf33b70627 Mon Sep 17 00:00:00 2001 From: david Date: Tue, 26 Jul 2011 20:48:03 +0000 Subject: [PATCH] Make str2AVal not modify its argument. This is nice for its own sake, but it's really so that the error message makes sense. The string had had a bunch of '\0' bytes inserted and the string in the error message didn't match the argument. --- osscan.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/osscan.cc b/osscan.cc index 9a964d997..3bbf3320d 100644 --- a/osscan.cc +++ b/osscan.cc @@ -680,10 +680,10 @@ error: return -1; } -static std::vector str2AVal(char *str) { +static std::vector str2AVal(const char *str) { int i = 1; int count = 1; - char *q = str, *p=str; + const char *q = str, *p=str; std::vector AVs; if (!*str) @@ -703,17 +703,17 @@ static std::vector str2AVal(char *str) { if (!q) { fatal("Parse error with AVal string (%s) in nmap-os-db file", str); } - *q = '\0'; - av.attribute = string_pool_insert(p); + av.attribute = string_pool_substr(p, q); p = q+1; - if (i != count - 1) { + if (i < count - 1) { q = strchr(p, '%'); if (!q) { fatal("Parse error with AVal string (%s) in nmap-os-db file", str); } - *q = '\0'; + av.value = string_pool_substr(p, q); + } else { + av.value = string_pool_insert(p); } - av.value = string_pool_insert(p); p = q + 1; AVs.push_back(av); }