Skip to content

Should passing invalid recid to sig parsing call the callback? #751

@elichai

Description

@elichai

Hi,
Currently if you pass a recid that is recid < 0 || recid > 3 into secp256k1_ecdsa_recoverable_signature_parse_compact it will fail on ARG_CHECK which will call secp256k1_callback_call which will by default abort the program.
https://github.com/bitcoin-core/secp256k1/blob/master/src/modules/recovery/main_impl.h#L46

Is this the right thing to do? AFAIK this is the only place in our API where a parsing function can abort your program on invalid input.
This means that whoever uses the API must check the recid before passing it to the parsing function.

I think this makes sense on opaque structs which we require to go through the parsing functions first and not manually initialize them because that will be "library UB"(sometimes abort, others unexpected results, see #668 #701) but I think it makes less sense on an int used as the input to a parsing function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions