Skip to content

Commit

Permalink
Merge pull request #157 from feed-rs/fuzz-fixes
Browse files Browse the repository at this point in the history
Test for fuzz debug_assert
  • Loading branch information
markpritchard committed Sep 27, 2022
2 parents b5abf17 + c8b3bd9 commit ba7c6d0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions feed-rs/src/parser/fuzz.rs
@@ -0,0 +1,16 @@
use crate::parser::parse;

#[test]
fn fuzz_parse() {
let data: Vec<u8> = 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());
}
3 changes: 3 additions & 0 deletions feed-rs/src/parser/mod.rs
Expand Up @@ -239,3 +239,6 @@ fn parse_xml<R: BufRead>(source: R, uri: Option<&str>) -> ParseFeedResult<model:
// Couldn't find a recognised feed within the provided XML stream
Err(ParseFeedError::ParseError(ParseErrorKind::NoFeedRoot))
}

#[cfg(test)]
mod fuzz;

0 comments on commit ba7c6d0

Please sign in to comment.