mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
GH-1819: Handle recursive types when describing type in binary mode
This commit is contained in:
parent
c190c85bf0
commit
e0b116154a
2 changed files with 29 additions and 2 deletions
|
@ -1326,10 +1326,15 @@ void RecordType::DescribeFields(ODesc* d) const
|
||||||
d->AddCount(types->length());
|
d->AddCount(types->length());
|
||||||
for ( const auto& type : *types )
|
for ( const auto& type : *types )
|
||||||
{
|
{
|
||||||
type->type->Describe(d);
|
|
||||||
d->SP();
|
|
||||||
d->Add(type->id);
|
d->Add(type->id);
|
||||||
d->SP();
|
d->SP();
|
||||||
|
|
||||||
|
if ( d->FindType(type->type.get()) )
|
||||||
|
d->Add("<recursion>");
|
||||||
|
else
|
||||||
|
type->type->Describe(d);
|
||||||
|
|
||||||
|
d->SP();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
22
testing/btest/core/recursive-types.zeek
Normal file
22
testing/btest/core/recursive-types.zeek
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue