mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48: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>";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue