Skip to content

swf: avm1: Ignore bad ActionTry opcodes and bad ConstantPool strings #11957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion swf/src/avm1/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ impl<'a> Reader<'a> {
let count = self.read_u16()?;
let mut strings = Vec::with_capacity(count as usize);
for _ in 0..count {
strings.push(self.read_str()?);
let string = self.read_str();
if let Ok(string) = string {
strings.push(string);
}
}
Ok(ConstantPool { strings })
}
Expand Down Expand Up @@ -350,6 +353,15 @@ impl<'a> Reader<'a> {
}

fn read_try(&mut self, length: &mut usize) -> Result<Try<'a>> {
// All Try opcodes must be at least 7 bytes long. If it's shorter, it's a bogus opcode; return an empty Try.
if *length < 7 {
return Ok(Try {
try_body: &[],
catch_body: None,
finally_body: None,
});
}

let flags = TryFlags::from_bits_truncate(self.read_u8()?);
let try_size: usize = self.read_u16()?.into();
let catch_size: usize = self.read_u16()?.into();
Expand Down