afl.rs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /// Regression tests from American Fuzzy Lop test cases.
  2. // This Source Code Form is subject to the terms of the Mozilla Public
  3. // License, v. 2.0. If a copy of the MPL was not distributed with this
  4. // file, You can obtain one at https://mozilla.org/MPL/2.0/.
  5. /// These all caused crashes at some point during development.
  6. extern crate mp4parse;
  7. use std::io::Cursor;
  8. /// https://github.com/mozilla/mp4parse-rust/issues/2
  9. ///
  10. /// Test a box with 4-byte size, smaller than the smallest header.
  11. #[test]
  12. fn fuzz_2() {
  13. let mut c = Cursor::new(b"\x00\x00\x00\x04\xa6\x00\x04\xa6".to_vec());
  14. let mut context = mp4parse::MediaContext::new();
  15. let _ = mp4parse::read_mp4(&mut c, &mut context);
  16. }
  17. /// https://github.com/mozilla/mp4parse-rust/issues/4
  18. ///
  19. /// Test a large (64 bit) box header with zero declared size.
  20. #[test]
  21. fn fuzz_4() {
  22. let mut c = Cursor::new(b"\x00\x00\x00\x01\x30\x30\x30\x30\x00\x00\x00\x00\x00\x00\x00\x00".to_vec());
  23. let mut context = mp4parse::MediaContext::new();
  24. let _ = mp4parse::read_mp4(&mut c, &mut context);
  25. }
  26. /// https://github.com/mozilla/mp4parse-rust/issues/5
  27. ///
  28. /// Declares 202116104 compatible brands but does not supply them,
  29. /// verifying read is properly bounded at the end of the stream.
  30. #[test]
  31. fn fuzz_5() {
  32. let mut c = Cursor::new(b"\x30\x30\x30\x30\x66\x74\x79\x70\x30\x30\x30\x30\x30\x30\x30\x30".to_vec());
  33. let mut context = mp4parse::MediaContext::new();
  34. let _ = mp4parse::read_mp4(&mut c, &mut context);
  35. }
  36. /// https://github.com/mozilla/mp4parse-rust/issues/6
  37. ///
  38. /// Declares an ftyp box with a single invalid (short - 3 byte) compatible
  39. /// brand and excludes the extra 3 bytes from the stream.
  40. #[test]
  41. fn fuzz_6() {
  42. let mut c = Cursor::new(b"\x00\x00\x00\x13\x66\x74\x79\x70\x30\x30\x30\x30\x30\x30\x30\x30".to_vec());
  43. let mut context = mp4parse::MediaContext::new();
  44. let _ = mp4parse::read_mp4(&mut c, &mut context);
  45. }