Closed
Description
I have used afl.rs to fuzz all public API of thie crate. And I found several cases may cause panic. The version I fuzz on is 1.4.2, but I have checked that all the cases can be replayed on the newest version 1.4.3. These panics involve 9 APIs(some are similar). The code to replay these panics are as follows:
These 6 cases are about slicing error or out-of-bound error.
let regex_ = regex::bytes::Regex::new("0").unwrap();
let _ = regex::bytes::Regex::find_at(®ex_ ,&[48] ,3472328296227680304);
let regex_ = regex::Regex::new("0").unwrap();
let _local1 = regex::Regex::find_at(®ex_ ,"0" ,3472328296227680304);
let regex_ = regex::bytes::Regex::new("0").unwrap();
let _ = regex::bytes::Regex::shortest_match_at(®ex_ ,&[48] ,3472328296227680304);
let regex_ = regex::bytes::Regex::new("0").unwrap();
let _ = regex::bytes::Regex::is_match_at(®ex_ ,&[48] ,3472328296227680304);
let regex_ = regex::Regex::new("0").unwrap();
let _ = regex::Regex::shortest_match_at(®ex_ ,"0" ,3472328296227680304);
let regex_ = regex::Regex::new("0").unwrap();
let _ = regex::Regex::is_match_at(®ex_ ,"0" ,3472328296227680304);
These 2 cases are about arithmetic overflow.
let regex_ = regex::bytes::Regex::new("0").unwrap();
let capture_location = regex::bytes::Regex::capture_locations(®ex_);
let _ = regex::bytes::CaptureLocations::get(&capture_location ,18388250262078763056);
let regex_ = regex::Regex::new("0").unwrap();
let capture_location = regex::Regex::capture_locations(®ex_);
let _ = regex::CaptureLocations::get(&capture_location ,9236935819261915184);
This case is about unicode error(char boundary)
let regex_ = regex::Regex::new("(?-u)000|\\S000").unwrap();
let match_ = regex::Regex::find(®ex_ ,"詩00000000000").unwrap();
let _ = regex::Match::as_str(&match_);
I also put these replay codes and more data that may cause panic on replay_files.
I hope you can check if these are real bugs need to be fixed. Thanks a lot.