Skip to content

Commit

Permalink
Add another failing gix-url test-case found by the fuzzer.
Browse files Browse the repository at this point in the history
It overflows some number in Debug mode.
  • Loading branch information
Byron committed Nov 2, 2023
1 parent d78f445 commit 9158ffc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions gix-url/tests/fixtures/fuzzed/very-long-abort2.url
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ws:// . ݆ 􊘵 %55 . /
26 changes: 14 additions & 12 deletions gix-url/tests/fuzzed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ use std::time::Duration;
#[test]
#[cfg_attr(debug_assertions, ignore = "fails due to integer overflow")]
fn abort_unfixed_in_debug_mode() {
let name = "very-long-abort";
let base = Path::new("tests").join("fixtures").join("fuzzed");
let location = base.join(Path::new(name).with_extension("url"));
let url = std::fs::read(&location).unwrap();
let start = std::time::Instant::now();
gix_url::parse(url.as_bstr()).ok();
assert!(
start.elapsed() < Duration::from_millis(100),
"URL at '{}' parsed too slowly, took {:.00}s",
location.display(),
start.elapsed().as_secs_f32()
);
for name in ["very-long-abort2", "very-long-abort"] {
let base = Path::new("tests").join("fixtures").join("fuzzed");
let location = base.join(Path::new(name).with_extension("url"));
let url = std::fs::read(&location).unwrap();
let start = std::time::Instant::now();
dbg!(name);
gix_url::parse(url.as_bstr()).ok();
assert!(
start.elapsed() < Duration::from_millis(100),
"URL at '{}' parsed too slowly, took {:.00}s",
location.display(),
start.elapsed().as_secs_f32()
);
}
}

#[test]
Expand Down

0 comments on commit 9158ffc

Please sign in to comment.