psbt: Require ECDSA signatures to be validly encoded

Needed for later validation of sighash types.
This commit is contained in:
Ava Chow committed 2025-05-14 14:00:23 -07:00
1 parent 53eb5593f0
commit 5a5d26d612
1 file changed
+5
+5
View File
@@ -520,6 +520,11 @@ struct PSBTInput
std::vector<unsigned char> sig;
s >> sig;
// Check that the signature is validly encoded
if (sig.empty() || !CheckSignatureEncoding(sig, SCRIPT_VERIFY_DERSIG | SCRIPT_VERIFY_STRICTENC, nullptr)) {
throw std::ios_base::failure("Signature is not a valid encoding");
}
// Add to list
partial_sigs.emplace(pubkey.GetID(), SigPair(pubkey, std::move(sig)));
break;