From: Sergi Delgado Segura Date: Tue, 20 Jul 2021 09:05:47 +0000 (+0200) Subject: Enforces sig_rec length in message_signing X-Git-Tag: v0.0.100~25^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=8a1c538f88ffc3f387ce3f54ded2d49ab9c9aa31;p=rust-lightning Enforces sig_rec length in message_signing --- diff --git a/lightning/src/util/message_signing.rs b/lightning/src/util/message_signing.rs index 2055b4087..8beff835a 100644 --- a/lightning/src/util/message_signing.rs +++ b/lightning/src/util/message_signing.rs @@ -36,6 +36,11 @@ fn sigrec_encode(sig_rec: RecoverableSignature) -> Vec { } fn sigrec_decode(sig_rec: Vec) -> Result { + // Signature must be 64 + 1 bytes long (compact signature + recovery id) + if sig_rec.len() != 65 { + return Err(Error::InvalidSignature); + } + let rsig = &sig_rec[1..]; let rid = sig_rec[0] as i32 - 31;