diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/plist/tests | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/plist/tests')
-rw-r--r-- | third_party/rust/plist/tests/data/binary.plist | bin | 0 -> 422 bytes | |||
-rw-r--r-- | third_party/rust/plist/tests/data/binary_NSKeyedArchiver.plist | bin | 0 -> 488 bytes | |||
-rw-r--r-- | third_party/rust/plist/tests/data/binary_circular_array.plist | bin | 0 -> 451 bytes | |||
-rw-r--r-- | third_party/rust/plist/tests/data/binary_zero_offset_size.plist | bin | 0 -> 276 bytes | |||
-rw-r--r-- | third_party/rust/plist/tests/data/book.plist | 14 | ||||
-rw-r--r-- | third_party/rust/plist/tests/data/utf16_bplist.plist | bin | 0 -> 1378 bytes | |||
-rw-r--r-- | third_party/rust/plist/tests/data/xml.plist | 36 | ||||
-rw-r--r-- | third_party/rust/plist/tests/data/xml_error.plist | 17 | ||||
-rw-r--r-- | third_party/rust/plist/tests/fuzzer.rs | 87 |
9 files changed, 154 insertions, 0 deletions
diff --git a/third_party/rust/plist/tests/data/binary.plist b/third_party/rust/plist/tests/data/binary.plist Binary files differnew file mode 100644 index 0000000000..c9c1d5861f --- /dev/null +++ b/third_party/rust/plist/tests/data/binary.plist diff --git a/third_party/rust/plist/tests/data/binary_NSKeyedArchiver.plist b/third_party/rust/plist/tests/data/binary_NSKeyedArchiver.plist Binary files differnew file mode 100644 index 0000000000..3f86b812de --- /dev/null +++ b/third_party/rust/plist/tests/data/binary_NSKeyedArchiver.plist diff --git a/third_party/rust/plist/tests/data/binary_circular_array.plist b/third_party/rust/plist/tests/data/binary_circular_array.plist Binary files differnew file mode 100644 index 0000000000..57d4575e5c --- /dev/null +++ b/third_party/rust/plist/tests/data/binary_circular_array.plist diff --git a/third_party/rust/plist/tests/data/binary_zero_offset_size.plist b/third_party/rust/plist/tests/data/binary_zero_offset_size.plist Binary files differnew file mode 100644 index 0000000000..83ede66d50 --- /dev/null +++ b/third_party/rust/plist/tests/data/binary_zero_offset_size.plist diff --git a/third_party/rust/plist/tests/data/book.plist b/third_party/rust/plist/tests/data/book.plist new file mode 100644 index 0000000000..048ca6bb3c --- /dev/null +++ b/third_party/rust/plist/tests/data/book.plist @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>Title</key> + <string>Great Expectations</string> + <key>Author</key> + <string>Charles Dickens</string> + <key>Excerpt</key> + <string>Whether I should have made out this object so soon, if there had been no fine lady sitting at it, I cannot say. In an armchair, with an elbow resting on the table and her head leaning on that hand, sat the strangest lady I have ever seen, or shall ever see.</string> + <key>CopiesSold</key> + <integer>123456789</integer> +</dict> +</plist> diff --git a/third_party/rust/plist/tests/data/utf16_bplist.plist b/third_party/rust/plist/tests/data/utf16_bplist.plist Binary files differnew file mode 100644 index 0000000000..a50477c4d0 --- /dev/null +++ b/third_party/rust/plist/tests/data/utf16_bplist.plist diff --git a/third_party/rust/plist/tests/data/xml.plist b/third_party/rust/plist/tests/data/xml.plist new file mode 100644 index 0000000000..a4016a245a --- /dev/null +++ b/third_party/rust/plist/tests/data/xml.plist @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>Author</key> + <string>William Shakespeare</string> + <key>Lines</key> + <array> + <string>It is a tale told by an idiot,</string> + <string>Full of sound and fury, signifying nothing.</string> + </array> + <key>Death</key> + <integer>1564</integer> + <key>Height</key> + <real>1.6</real> + <key>Data</key> + <data> + AAAAvgAAAA + MAAAAeAAAA + </data> + <key>Birthdate</key> + <date>1981-05-16T11:32:06Z</date> + <key>Blank</key> + <string></string> + <key>BiggestNumber</key> + <integer>18446744073709551615</integer> + <key>SmallestNumber</key> + <integer>-9223372036854775808</integer> + <key>HexademicalNumber</key> + <integer>0xDEADBEEF</integer> + <key>IsTrue</key> + <true/> + <key>IsNotFalse</key> + <false/> +</dict> +</plist> diff --git a/third_party/rust/plist/tests/data/xml_error.plist b/third_party/rust/plist/tests/data/xml_error.plist new file mode 100644 index 0000000000..8fe6a96ae4 --- /dev/null +++ b/third_party/rust/plist/tests/data/xml_error.plist @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>Author</key> + <string>William Shakespeare</string> + <key>Lines</key> + <array> + <string>It is a tale told by an idiot,</string> + <string>Full of sound and fury, signifying nothing.</string> + </array> + <key>Death</key> + <integer>1564</integer> + <key>Height</key> + <real>1.6</real> + <key>Data</ke + BADNESS
\ No newline at end of file diff --git a/third_party/rust/plist/tests/fuzzer.rs b/third_party/rust/plist/tests/fuzzer.rs new file mode 100644 index 0000000000..df5d81af05 --- /dev/null +++ b/third_party/rust/plist/tests/fuzzer.rs @@ -0,0 +1,87 @@ +extern crate plist; + +use plist::{Error, Value}; +use std::io::Cursor; + +#[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); +} + +#[test] +fn empty_offset_table() { + let data = b"bplist00;\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00<)\x9fXTX("; + test_fuzzer_data_err(data); +} + +#[test] +fn binary_circular_reference() { + let data = b"bplist00\xd6\x01\x02\x03\x04\x05\x06\x07\x0a\x0b\x0c\x0d\x0eULinesUDeathVHeightYBirthdateVAutbplist00\xd6\x01\x02\x03\x04\x05\x06\x07\x0a\x0b\x0c\x0d\x0eULinesUDeathVHeightYBirthdateVAuthorTData\xa2\x08\x09_\x10\x1eIt is nifying nothing.\x11\x06\x1c#?\xf9\x99\x99\x99\x99\x99\x9a3\xc1\xc2v\x00e\x00\x00\x00_\x10\x13William ShakespeareO\x10\x0f\x00\x00\x00\xbe\x00\x00\x00\x03\x00\x00\x00\x1e\x00\x00\x00\x08\x15\x1b!(58>Ab\x90\x93\x9c\xa5\xbb\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xcd"; + test_fuzzer_data_err(data); +} + +#[test] +fn binary_zero_offset_size() { + let data = include_bytes!("data/binary_zero_offset_size.plist"); + test_fuzzer_data_err(data); +} + +#[test] +fn binary_nan_date() { + let data = b"bplist00\xd6\x01\x02\x01\x04\x05\x06\x07\x0a\x0b\x0c\x0d\x0eULinesUDeathVHeightYBthridateVAuthorTData\xa2\x08\x09_\x10\x1eIt is a tale told by an idiot,_\x10+Full of sound and fury, signifying nothing.\x11\x06\x1c#?\xf9\x99\x99\x99\x99\x99\x9a3\xff\xff\xff\xffe\x00\x00\x00_\x13\x10William ShakespeareO\x10\xe5\x00\x00\x00\xbe\x00\x00\x00\x03\x00\x00\x00\x1e\x00\x00\x00\x08\x15\x1b!(14>Ab\x90\x93\x9c\xa5\xbb\xd4\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xcd"; + test_fuzzer_data_err(data); +} + +#[test] +fn binary_circular_array() { + let data = include_bytes!("data/binary_circular_array.plist"); + test_fuzzer_data_err(data); +} + +// Issue 20 - not found by fuzzing but this is a convenient place to put the test. +#[test] +fn issue_20_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); +} + +#[test] +fn issue_22_binary_with_byte_ref_size() { + let data = b"bplist00\xd1\x01\x02TTestQ1\x08\x0b\x10\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12"; + test_fuzzer_data_ok(data); +} + +#[test] +fn overflow_instant_add() { + let data = b"bplist00\x10\x01\x00\x00\x00\x00\x00\x003~\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x00\x00\x00\x00\x00\x00\n\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00"; + + test_fuzzer_data_err(data); +} + +#[test] +fn overflow_instant_sub() { + let data = b"bplist00\x10\x01\x00\x00\x00\x00\x00\x003\xfe\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x00\x00\x00\x00\x00\x00\n\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00"; + + test_fuzzer_data_err(data); +} + +fn test_fuzzer_data(data: &[u8]) -> Result<Value, Error> { + let cursor = Cursor::new(data); + Value::from_reader(cursor) +} + +fn test_fuzzer_data_ok(data: &[u8]) { + test_fuzzer_data(data).unwrap(); +} + +fn test_fuzzer_data_err(data: &[u8]) { + assert!(test_fuzzer_data(data).is_err()); +} |