avm1: Ignore unknown value type in `ActionPush`

Newest Flash Player exits on unknown value types. However, older versions
(at least FP9) just ignore them and continue to the next value.
Follow the lenient behavior in order to support more content (e.g. #8389
doesn't work on newest Flash Player).

Fixes #8389.
This commit is contained in:
relrelb 2022-10-28 17:27:27 +03:00 committed by relrelb
parent 68471723b3
commit c5f4f555bb
1 changed files with 22 additions and 18 deletions

View File

@ -311,12 +311,6 @@ impl<'a> Reader<'a> {
let end_pos = (self.input.as_ptr() as usize + length) as *const u8;
let mut values = Vec::with_capacity(4);
while self.input.as_ptr() < end_pos {
values.push(self.read_push_value()?);
}
Ok(Push { values })
}
fn read_push_value(&mut self) -> Result<Value<'a>> {
let value = match self.read_u8()? {
0 => Value::Str(self.read_str()?),
1 => Value::Float(self.read_f32()?),
@ -328,9 +322,19 @@ impl<'a> Reader<'a> {
7 => Value::Int(self.read_i32()?),
8 => Value::ConstantPool(self.read_u8()?.into()),
9 => Value::ConstantPool(self.read_u16()?),
_ => return Err(Error::invalid_data("Invalid value type in ActionPush")),
type_ => {
// Newest Flash Player exits on unknown value types. However, older versions
// (at least FP9) just ignore them and continue to the next value.
// We follow the lenient behavior in order to support more content (e.g. #8389
// doesn't work on newest Flash Player).
// TODO: Return an error if we ever add player version emulation.
log::warn!("Invalid value type in ActionPush: {}", type_);
continue;
}
};
Ok(value)
values.push(value);
}
Ok(Push { values })
}
fn read_set_target(&mut self) -> Result<SetTarget<'a>> {