diff --git a/CHANGES b/CHANGES index 47f258684c..aa1f90a175 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,17 @@ +2.6-529 | 2019-06-27 10:12:34 -0700 + + * Fix creating a StringVal from std::string. (Johanna Amann, Corelight) + + Currently, creating a StringVal from a std::string did not work with + data that contains \0 characters. This easy fix changes this - and + should also lead to a small speed increase for code using this + constructor. + + This obviously means that more data might copied now in some cases that + were previously cut off at the first 0-byte. Our test-suite did not + reveal any such cases. + 2.6-526 | 2019-06-25 12:45:31 -0700 * Make a paraglob unit test parallelizable (Jon Siwek, Corelight) diff --git a/VERSION b/VERSION index b40f65b0fa..0d6f2a5219 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.6-526 +2.6-529 diff --git a/src/Val.cc b/src/Val.cc index 017516acd8..32d64c5cdd 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -710,7 +710,7 @@ StringVal::StringVal(const char* s) : Val(TYPE_STRING) StringVal::StringVal(const string& s) : Val(TYPE_STRING) { - val.string_val = new BroString(s.c_str()); + val.string_val = new BroString(reinterpret_cast(s.data()), s.length(), 1); } StringVal* StringVal::ToUpper() diff --git a/testing/btest/Baseline/language.paraglob/out b/testing/btest/Baseline/language.paraglob/out index 18e6da7096..12fd09a970 100644 --- a/testing/btest/Baseline/language.paraglob/out +++ b/testing/btest/Baseline/language.paraglob/out @@ -5,5 +5,5 @@ F [once] [] [*.gov*, *malware*] -[z*ro] +[z*ro, zero\x00zero] [*.gov*, *malware*] diff --git a/testing/btest/language/paraglob.zeek b/testing/btest/language/paraglob.zeek index b6f61a8ef0..e608bd62e0 100644 --- a/testing/btest/language/paraglob.zeek +++ b/testing/btest/language/paraglob.zeek @@ -6,7 +6,7 @@ event zeek_init () local v1 = vector("*", "d?g", "*og", "d?", "d[!wl]g"); local v2 = vector("once", "!o*", "once"); local v3 = vector("https://*.google.com/*", "*malware*", "*.gov*"); - local v4 = vector("z*ro"); + local v4 = vector("z*ro", "zero\0zero"); local p1 = paraglob_init(v1); local p2: opaque of paraglob = paraglob_init(v2);