Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some panic cases found by afl.rs #972

Closed
Koral77 opened this issue Apr 4, 2023 · 1 comment
Closed

Some panic cases found by afl.rs #972

Koral77 opened this issue Apr 4, 2023 · 1 comment

Comments

@Koral77
Copy link

Koral77 commented Apr 4, 2023

I have used afl.rs to fuzz all public API of the crate. And I found several cases may cause panic. The version I fuzz on is newest version. The code to replay these panics are as follows:

These 4 cases are about range start index out of range for slice error:

let _local0 = regex::Regex::new("\0\0\0\0$");
let _local1_param0_helper1 = _local0.unwrap();
let _local1 = regex::Regex::find_at(&(_local1_param0_helper1), "\r\0\u{1}\u{e}a", 2449958197290798336);
let _local2_param0_helper1 = _local1.unwrap();
regex::Match::end(&(_local2_param0_helper1));
let _local0 = regex::RegexBuilder::new("$");
let _local1 = regex::RegexBuilder::build(&(&_local0));
let _local2_param0_helper1 = _local1.unwrap();
regex::Regex::shortest_match_at(&(_local2_param0_helper1), "{S", 8897841259371199355);
let _local0 = regex::Regex::new("$$$$$$$$$$");
let _local1_param0_helper1 = _local0.unwrap();
let _local1 = regex::Regex::find_at(&(_local1_param0_helper1), "$$$$$$$$$$$", 2604246222170760228);
let _local2_param0_helper1 = _local1.unwrap();
regex::Match::end(&(_local2_param0_helper1));
let _local0 = regex::Regex::new("(\0\0\0\0\0\0\u{10}|\0\0\0\0\0)\0\0\0\0\0\0\0\0\0\u{10}|\0\0\0\0\0\0\0");
let _local1_param0_helper1 = _local0.unwrap();
let _local1 = regex::Regex::find_at(&(_local1_param0_helper1), 
"\0\u{4}\0*****\u{17}***************\0\0\0\0\0\0\0\0\0\0", 35184372153856);
let _local2_param0_helper1 = _local1.unwrap();
regex::Match::end(&(_local2_param0_helper1));

These 3 cases are about out-of-bound error:

let _local0 = regex::Regex::new("[\\\\-^]\0\0\0\0\0\0\0\0\0\0\u{1}\0\0\0\0\u{3}\0\0\0\0\u{1e}\0\u{3}r\u{1}\0\u{f}\0\u{3}r|\u{17}\u{10}\0\0r|\0\0\0%\u{17}\u{10}\0\0r|\0\0");
let _local1_param0_helper1 = _local0.unwrap();
let _local1 = regex::Regex::find_at(&(_local1_param0_helper1), 
"\0%r|\0r|\0\u{2}\0\u{3}\0\0|\u{17}\u{10}\0\0r|\0\0\u{1}\0\0\0\0\0\u{3}r|\u{17}\u{10}\0\0r\0\0\0\0\0#Y@\u{1}\u{1}\u{1}\u{1}\u{1}\u{1}\u{1}\u{1}\u{1}\u{1}\u{1}\u{1}", 
15924992);
let _local2_param0_helper1 = _local1.unwrap();
regex::Match::end(&(_local2_param0_helper1));
let _local0 = regex::RegexSet::empty();
let _local1 = regex::RegexSet::matches(&(_local0), "\u{19}\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t2");
regex::SetMatches::matched(&(_local1), 9153857652018186505);
let _local0 = regex::bytes::RegexSet::empty();
let _local1 = regex::bytes::RegexSet::matches(&(_local0), &[137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, 138]);
regex::bytes::SetMatches::matched(&(_local1), 9910603678816504201);

This case is about arithmetic overflow:

let _local0 = regex::Regex::new("E\0|\u{741}");
let _local1_param0_helper1 = _local0.unwrap();
let _local1 = regex::Regex::capture_locations(&(_local1_param0_helper1));
regex::CaptureLocations::get(&(_local1) ,9238929028971069751);

I also put these replay codes and more data that may cause panic on replays.

I hope you can check if these are real bugs need to be fixed. Thanks a lot.

@BurntSushi
Copy link
Member

Duplicate of #738 and #950.

Only your last one is an example of a real bug, and that corresponds to #950. The remaining examples are just passing out-of-bounds indices to APIs that are supposed to panic. The documentation does need to be improved to specifically call that out.

@BurntSushi BurntSushi closed this as not planned Won't fix, can't repro, duplicate, stale Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants