diff options
| author | Edward Barnard | 2017-04-19 09:31:26 +0100 |
|---|---|---|
| committer | Edward Barnard | 2017-04-19 09:31:26 +0100 |
| commit | 7079d594fa45495b411949d65d1d3a8f5dfecdcd (patch) | |
| tree | ae500b3fd6453b76ff3a85593ecd429f8d2ba27e /tests | |
| parent | 1df5db005ea9959c4e19107997f446dc17095be4 (diff) | |
| download | rust-plist-7079d594fa45495b411949d65d1d3a8f5dfecdcd.tar.bz2 | |
Fix reading small binary plists with data stored in the 6 byte trailer padding. Closes #20.v0.1.3
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/fuzzer.rs | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/tests/fuzzer.rs b/tests/fuzzer.rs index 65ce8eb..827b8c5 100644 --- a/tests/fuzzer.rs +++ b/tests/fuzzer.rs @@ -1,7 +1,7 @@ extern crate plist; use std::io::Cursor; -use plist::Plist; +use plist::{Plist, Result}; #[test] fn too_large_allocation() { @@ -27,8 +27,22 @@ fn binary_circular_reference() { test_fuzzer_data_err(data); } -fn test_fuzzer_data_err(data: &[u8]) { +// Issue 20 - not found by fuzzing but this is a convenient place to put the test. +#[test] +fn binary_with_data_in_trailer() { + let data = b"bplist00\xd0\x08\0\0\0\0\0\0\x01\x01\0\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\t"; + test_fuzzer_data_ok(data); +} + +fn test_fuzzer_data(data: &[u8]) -> Result<Plist> { let cursor = Cursor::new(data); - let res = Plist::read(cursor); - assert!(res.is_err()); + Plist::read(cursor) +} + +fn test_fuzzer_data_ok(data: &[u8]) { + assert!(test_fuzzer_data(data).is_ok()); +} + +fn test_fuzzer_data_err(data: &[u8]) { + assert!(test_fuzzer_data(data).is_err()); } |
