diff --git a/feed-rs/src/parser/fuzz.rs b/feed-rs/src/parser/fuzz.rs new file mode 100644 index 0000000..b64bd39 --- /dev/null +++ b/feed-rs/src/parser/fuzz.rs @@ -0,0 +1,16 @@ +use crate::parser::parse; + +#[test] +fn fuzz_parse() { + let data: Vec = vec![ + 0xdb, 0x3b, 0x3c, 0x66, 0x65, 0x65, 0x64, 0x3e, 0x00, 0xfe, 0xff, 0x00, 0x00, 0x00, 0x3c, 0x1b, 0x3b, 0x64, 0x22, 0x22, 0x0d, 0x78, 0x6d, 0x6c, 0x3a, + 0x62, 0x61, 0x73, 0x65, 0x0d, 0x0d, 0x3d, 0x0a, 0x22, 0x0a, 0x0d, 0x0a, 0x0a, 0x0d, 0x66, 0x69, 0x6c, 0x65, 0x3a, 0xff, 0x3b, 0xbf, 0x5b, 0xbf, 0xbf, + 0xbc, 0xff, 0xff, 0x0a, 0x53, 0x53, 0x2b, 0x78, 0x3b, 0x22, 0x3c, 0x64, 0x3e, 0x2b, 0x00, 0x00, 0x2b, 0x3c, 0xdb, 0x3b, 0x32, 0x65, 0x64, 0x22, 0x22, + 0x0d, 0x78, 0x6d, 0x6c, 0x3a, 0x62, 0x61, 0x73, 0x65, 0x0d, 0x0d, 0x3d, 0x22, 0x75, 0x7c, 0x3f, 0x0a, 0x34, 0x0a, 0xff, 0x22, 0x34, 0x3a, 0xb5, 0x2f, + 0x3c, 0x66, 0x65, 0x64, 0x3e, 0x2b, 0x3c, 0xdb, 0x3b, 0x32, 0x65, 0x0d, 0x78, 0x6d, 0x6c, 0x3a, 0x62, 0x61, 0x73, 0x65, 0x0d, 0x0d, 0x3d, 0x22, 0x2e, + 0x2e, 0x3f, 0x0a, 0x3c, 0x3f, 0xff, 0x22, 0x34, 0x3a, 0xb5, 0x2f, 0x2f, 0xff, 0xff, 0xfe, 0x01, 0xdb, 0x3b, 0x3c, 0x66, 0x65, + ]; + + let result = parse(data.as_slice()); + assert!(result.is_err()); +} diff --git a/feed-rs/src/parser/mod.rs b/feed-rs/src/parser/mod.rs index b426f23..eab59de 100644 --- a/feed-rs/src/parser/mod.rs +++ b/feed-rs/src/parser/mod.rs @@ -239,3 +239,6 @@ fn parse_xml(source: R, uri: Option<&str>) -> ParseFeedResult