mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 00:58:19 +00:00
Merge branch 'Reporter/MessageFix' of https://github.com/catenacyber/bro
* 'Reporter/MessageFix' of https://github.com/catenacyber/bro: Better reporter for Brostring with embedded NUL I slightly changed the code for beautification purposes and added a testcase. No functional changes.
This commit is contained in:
commit
0747080e5f
3 changed files with 15 additions and 4 deletions
|
@ -166,17 +166,19 @@ void BroString::Set(const BroString& str)
|
|||
|
||||
const char* BroString::CheckString() const
|
||||
{
|
||||
void *nulTerm;
|
||||
if ( n == 0 )
|
||||
return "";
|
||||
|
||||
if ( memchr(b, '\0', n + final_NUL) != &b[n] )
|
||||
nulTerm = memchr(b, '\0', n + final_NUL);
|
||||
if ( nulTerm != &b[n] )
|
||||
{
|
||||
// Either an embedded NUL, or no final NUL.
|
||||
char* exp_s = Render();
|
||||
if ( b[n-1] != '\0' )
|
||||
reporter->Error("string without NUL terminator: \"%s\"", exp_s);
|
||||
else
|
||||
if ( nulTerm )
|
||||
reporter->Error("string with embedded NUL: \"%s\"", exp_s);
|
||||
else
|
||||
reporter->Error("string without NUL terminator: \"%s\"", exp_s);
|
||||
|
||||
delete [] exp_s;
|
||||
return "<string-with-NUL>";
|
||||
|
|
1
testing/btest/Baseline/core.embedded-null/.stdout
Normal file
1
testing/btest/Baseline/core.embedded-null/.stdout
Normal file
|
@ -0,0 +1 @@
|
|||
error: string with embedded NUL: "hi\x00there"
|
8
testing/btest/core/embedded-null.bro
Normal file
8
testing/btest/core/embedded-null.bro
Normal file
|
@ -0,0 +1,8 @@
|
|||
# @TEST-EXEC: bro -b %INPUT 2>&1
|
||||
# @TEST-EXEC: btest-diff .stdout
|
||||
|
||||
event bro_init()
|
||||
{
|
||||
local a = "hi\x00there";
|
||||
unique_id(a);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue