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:
Jon Siwek 2015-03-31 13:48:15 -05:00 committed by Tim Wojtulewicz
parent 8648820497
commit ded5abb01e

View file

@ -206,6 +206,13 @@ int RecordType::StaticSize(Env* env) const
void RecordType::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_)
{
RecordField *f = *i;