-
Notifications
You must be signed in to change notification settings - Fork 52
Closed
Labels
Description
We got a crash on miniscript_string target due to validation of numbers. For older(), after(), thresh() and maybe other fragments, Bitcoin Core accept the usage of the + sign, e.g. (l:older(+1), u:after(+1)), because of ParseInt64 function. However, rust-miniscript checks the character itself, so it only accepts "1", "2", "3"..."9".
if !('1'..='9').contains(&ch) {
return Err(Error::Unexpected("Number must start with a digit 1-9".to_string()));
}There is a test to ensure it doesn't accept those ones:
fn test_parse_num() {
assert!(parse_num("0").is_ok());
assert!(parse_num("00").is_err());
assert!(parse_num("0000").is_err());
assert!(parse_num("06").is_err());
assert!(parse_num("+6").is_err());
assert!(parse_num("-6").is_err());
}narcelio