Merge remote-tracking branch 'origin/topic/timw/1819-hashing-segfault'

* origin/topic/timw/1819-hashing-segfault:
  GH-1819: Handle recursive types when describing type in binary mode
This commit is contained in:
Tim Wojtulewicz 2021-11-09 09:45:57 -07:00
commit 8429ef746d
4 changed files with 34 additions and 3 deletions

View file

@ -1,3 +1,7 @@
4.2.0-dev.303 | 2021-11-09 09:45:57 -0700
* GH-1819: Handle recursive types when describing type in binary mode (Tim Wojtulewicz, Corelight)
4.2.0-dev.301 | 2021-11-09 09:28:18 -0700
* Remove no-op false-teredo test (Tim Wojtulewicz, Corelight)

View file

@ -1 +1 @@
4.2.0-dev.301
4.2.0-dev.303

View file

@ -1326,10 +1326,15 @@ void RecordType::DescribeFields(ODesc* d) const
d->AddCount(types->length());
for ( const auto& type : *types )
{
type->type->Describe(d);
d->SP();
d->Add(type->id);
d->SP();
if ( d->FindType(type->type.get()) )
d->Add("<recursion>");
else
type->type->Describe(d);
d->SP();
}
}
}

View file

@ -0,0 +1,22 @@
# @TEST-EXEC: zeek -b %INPUT
# global_ids() here contains some types that are recursive, in that
# arguments to functions contain chained references to the type that
# defines the function. This tests that we don't crash when
# attempting to call Describe() on those types in binary-mode.
event zeek_init()
{
local sh: string = "";
local gi = global_ids();
for (myfunc in gi)
{
if(gi[myfunc]?$value)
{
if(strstr(myfunc,"lambda") > 0)
{
sh = sha256_hash(gi[myfunc]$value);
print(sh);
}
}
}
}