servo / rust-url

URL parser for Rust
https://docs.rs/url/
Apache License 2.0
1.27k stars 318 forks source link

Program Crash in fuzzing (assert failed in parse_path) #841

Open xizheyin opened 1 year ago

xizheyin commented 1 year ago

Describe the bug I have enhanced my testing tool and retested the library, only to find that the bug I previously reported has not been fully fixed. Moreover, there is a new test sequence that triggers the same assertion. Previous issue is here

version

[dependencies]
url = "2.4.0"

source code

fn main() {
    let _param0 = "\u{16}file:///11C//////\0";
    let _param2 = "..#fB????b\0\0\0?,\u{16}fil";
    let _param3 = "e\n//\u{1f}1\u{1e}01\n\n\n\n\n\n\n\n\n\n";
    let _param4 = "\n\n\n\n/:..#\u{10}o:/11;/k:";
    let _param5 = "..#,\u{16}\u{16}f\u{1f}Tl..\u{1b}, ??D@";
    /*println!(
        "_param0 = {:?}, _param2 = {:?}, _param3 = {:?}, _param4 = {:?}",
        _param0, _param2, _param3, _param4
    );*/
    let mut _local0 = if let Ok(x) = url::Url::parse(_param0) {
        x
    } else {
        use std::process;
        process::exit(0);
    };
    //let _ = url::quirks::domain_to_unicode(_param1);
    //let _ = url::Url::has_authority(&(_local0));
    let _ = url::quirks::set_pathname(&mut (_local0), _param2);
    let _ = url::quirks::username(&(_local0));
    let _ = url::quirks::pathname(&(_local0));
    let _ = url::quirks::set_hostname(&mut (_local0), _param3);
    let _ = url::quirks::host(&(_local0));
    let _ = url::quirks::set_pathname(&mut (_local0), _param4);
    let _ = url::Url::join(&(_local0), _param5);
}

error information

thread 'main' panicked at 'assertion failed: self.serialization.as_bytes()[segment_start - 1] == b\'/\'', /home/yxz/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/url-2.4.0/src/parser.rs:1236:21