mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
binpac: BIT-1829: fix &length suppressing boundary checks for array elements
It should only suppress the parsing-loop boundary check in the case where array elaments are a single byte in length and thus covered by the boundary check (generated as a result of &length) that is placed before the parsing-loop.
This commit is contained in:
parent
39547dccec
commit
9c61eefe0d
1 changed files with 11 additions and 0 deletions
|
@ -683,6 +683,17 @@ int ArrayType::StaticSize(Env *env) const
|
|||
void ArrayType::SetBoundaryChecked()
|
||||
{
|
||||
Type::SetBoundaryChecked();
|
||||
|
||||
if ( attr_length_expr_ )
|
||||
{
|
||||
// When using &length on an array, only treat its elements as
|
||||
// already-bounds-checked if they are a single byte in length.
|
||||
if ( elemtype_->StaticSize(env()) == 1 )
|
||||
elemtype_->SetBoundaryChecked();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
elemtype_->SetBoundaryChecked();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue