Skip to content

miniscript_string: Core accepts + sign for numbers #34

@brunoerg

Description

@brunoerg

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());
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions