GH-1503: Improve &expire_func compatibility type-checking

Previously, incompatible &expire_funcs could mistakenly be used, such as
when using that attribute on the unspecified table()/set()
initializations/assignments, resulting in invalid function calls that
eventually crash Zeek.
This commit is contained in:
Jon Siwek 2021-04-12 16:27:50 -07:00
parent 0c93e2fcb8
commit 01f6264c87
6 changed files with 85 additions and 46 deletions

View file

@ -1502,7 +1502,12 @@ void TableVal::SetAttrs(detail::AttributesPtr a)
const auto& ef = attrs->Find(detail::ATTR_EXPIRE_FUNC);
if ( ef )
expire_func = ef->GetExpr();
{
if ( GetType()->AsTableType()->CheckExpireFuncCompatibility(ef) )
expire_func = ef->GetExpr();
else
expire_func = nullptr;
}
const auto& cf = attrs->Find(detail::ATTR_ON_CHANGE);