Skip to content

Commit

Permalink
[rs] Fix remaining unknown bitmap type panics
Browse files Browse the repository at this point in the history
  • Loading branch information
demurgos committed Nov 10, 2019
1 parent 9d4533a commit 311ad7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions rs/src/complete/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ pub fn parse_define_bits_jpeg2(input: &[u8], swf_version: u8) -> NomResult<&[u8]
} else if test_image_start(&data, &GIF_START) {
(ast::ImageType::Gif, get_gif_image_dimensions(&data).unwrap())
} else {
panic!("UnknownBitmapType");
// UnknownBitmapType
return Err(nom::Err::Error((input, nom::error::ErrorKind::Verify)));
};

Ok((
Expand Down Expand Up @@ -320,7 +321,8 @@ pub fn parse_define_bits_jpeg3(input: &[u8], swf_version: u8) -> NomResult<&[u8]
data.to_vec(),
)
} else {
panic!("UnknownBitmapType");
// UnknownBitmapType
return Err(nom::Err::Error((input, nom::error::ErrorKind::Verify)));
};

let input: &[u8] = &[][..];
Expand Down Expand Up @@ -361,7 +363,8 @@ pub fn parse_define_bits_jpeg4(input: &[u8]) -> NomResult<&[u8], ast::tags::Defi
data.to_vec(),
)
} else {
panic!("UnknownBitmapType");
// UnknownBitmapType
return Err(nom::Err::Error((input, nom::error::ErrorKind::Verify)));
};

let input: &[u8] = &[][..];
Expand Down Expand Up @@ -1442,7 +1445,7 @@ mod tests {

// #[test]
// fn test_fuzzing() {
// let artifact: &[u8] = include_bytes!("../../fuzz/artifacts/tag/crash-e68e5e302143435eac15d06b9fa5c56bc13902d3");
// let artifact: &[u8] = include_bytes!("../../fuzz/artifacts/tag/crash-2936f4c99f00563c3e02f65fce6cacf968a0073a");
// let (swf_version, input_bytes) = artifact.split_first().unwrap();
// let _ = parse_tag(input_bytes, *swf_version);
// }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�C4B

0 comments on commit 311ad7e

Please sign in to comment.