From 8a1c538f88ffc3f387ce3f54ded2d49ab9c9aa31 Mon Sep 17 00:00:00 2001 From: Sergi Delgado Segura Date: Tue, 20 Jul 2021 11:05:47 +0200 Subject: [PATCH] Enforces sig_rec length in message_signing --- lightning/src/util/message_signing.rs | 5 +++++ 1 file changed, 5 insertions(+) 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; -- 2.39.5