diff options
| author | Edward Barnard | 2017-03-03 13:50:34 +0000 |
|---|---|---|
| committer | Edward Barnard | 2017-03-03 14:05:31 +0000 |
| commit | 62cae5d6ea74e2a9d95ed4b68a1b74b78f49d31e (patch) | |
| tree | cb8f8409e0b19f57af9845ad3dc4d068fdcf4292 /tests | |
| parent | 4a358659148be6f216a2ed8ea2004b2e744b8fb1 (diff) | |
| download | rust-plist-62cae5d6ea74e2a9d95ed4b68a1b74b78f49d31e.tar.bz2 | |
Limit individual allocation sizes to the size of the plist being read.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/fuzzer.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/fuzzer.rs b/tests/fuzzer.rs new file mode 100644 index 0000000..701df5e --- /dev/null +++ b/tests/fuzzer.rs @@ -0,0 +1,22 @@ +extern crate plist; + +use std::io::Cursor; +use plist::Plist; + +#[test] +fn too_large_allocation() { + let data = b"bplist00\"&L^^^^^^^^-^^^^^^^^^^^"; + test_fuzzer_data_err(data); +} + +#[test] +fn too_large_allocation_2() { + let data = b"bplist00;<)\x9fX\x0a<h\x0a:hhhhG:hh\x0amhhhhhhx#hhT)\x0a*"; + test_fuzzer_data_err(data); +} + +fn test_fuzzer_data_err(data: &[u8]) { + let cursor = Cursor::new(data); + let res = Plist::read(cursor); + assert!(res.is_err()); +} |
