mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
binpac: BIT-1361: Improve boundary checks of records that use &length
Specifying &length on a record no longer skips generating boundary checks for individual fields. E.g. a record field that specifies a &length that extends beyond the &length of the record containing it should throw binpac::ExceptionOutOfBound, the usual way of handling out-of-bounds conditions.
This commit is contained in:
parent
8648820497
commit
ded5abb01e
1 changed files with 7 additions and 0 deletions
|
@ -206,6 +206,13 @@ int RecordType::StaticSize(Env* env) const
|
||||||
void RecordType::SetBoundaryChecked()
|
void RecordType::SetBoundaryChecked()
|
||||||
{
|
{
|
||||||
Type::SetBoundaryChecked();
|
Type::SetBoundaryChecked();
|
||||||
|
|
||||||
|
if ( StaticSize(env()) < 0 || attr_length_expr_ )
|
||||||
|
// Don't assume sufficient bounds checking has been done on fields
|
||||||
|
// if the record is of variable size or if its size is set from &length
|
||||||
|
// (whose value is not necessarily trustworthy).
|
||||||
|
return;
|
||||||
|
|
||||||
foreach (i, RecordFieldList, record_fields_)
|
foreach (i, RecordFieldList, record_fields_)
|
||||||
{
|
{
|
||||||
RecordField *f = *i;
|
RecordField *f = *i;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue