Skip to content

bug: some miniscripts are being pointed as invalid, but are valid #633

Closed
@brunoerg

Description

@brunoerg

Hi, recently I started developing bitcoinfuzz - differential fuzzing of Bitcoin implementations and libraries. One of the targets gets a string and checks whether it's a valid miniscript. The code I'm using to check it with rust-miniscript is:

#[no_mangle]
pub extern "C" fn rust_miniscript_from_str(input: *const c_char) -> bool {
    if let Ok(data) = unsafe { CStr::from_ptr(input) }.to_str() {
        if let Ok(_pol) = Miniscript::<String, Segwitv0>::from_str_insane(data) {
            return true
        } else if let Ok(_pol) = Miniscript::<String, Tap>::from_str_insane(data) {
            return true
        }
    }
    false
}

and bitcoinfuzz is crashing (rust-miniscript returning invalid) with the following miniscripts (and other ones):

nnnnnnnnnnnnnnnln:1
dv:0
lll:0
l:1

Could I be missing something in my code or is it a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions