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:
Philippe Antoine 2018-03-23 10:10:01 +01:00
parent 9271b2032d
commit ecf2788740

View file

@ -166,14 +166,16 @@ 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' )
if ( nulTerm == NULL )
reporter->Error("string without NUL terminator: \"%s\"", exp_s);
else
reporter->Error("string with embedded NUL: \"%s\"", exp_s);