mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 09:08:20 +00:00
Better reporter for Brostring with embedded NUL
Can be reproduced with something like curl 127.0.0.1:8002/readme.html%00lol
This commit is contained in:
parent
9271b2032d
commit
ecf2788740
1 changed files with 4 additions and 2 deletions
|
@ -166,14 +166,16 @@ void BroString::Set(const BroString& str)
|
||||||
|
|
||||||
const char* BroString::CheckString() const
|
const char* BroString::CheckString() const
|
||||||
{
|
{
|
||||||
|
void * nulTerm;
|
||||||
if ( n == 0 )
|
if ( n == 0 )
|
||||||
return "";
|
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.
|
// Either an embedded NUL, or no final NUL.
|
||||||
char* exp_s = Render();
|
char* exp_s = Render();
|
||||||
if ( b[n-1] != '\0' )
|
if ( nulTerm == NULL )
|
||||||
reporter->Error("string without NUL terminator: \"%s\"", exp_s);
|
reporter->Error("string without NUL terminator: \"%s\"", exp_s);
|
||||||
else
|
else
|
||||||
reporter->Error("string with embedded NUL: \"%s\"", exp_s);
|
reporter->Error("string with embedded NUL: \"%s\"", exp_s);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue