Skip to content

Commit ef4bfdc

Browse files
authored
Merge pull request #1010 from sr-gi/enforce_signature_length
2 parents 1f1d7c6 + 8a1c538 commit ef4bfdc

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lightning/src/util/message_signing.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ fn sigrec_encode(sig_rec: RecoverableSignature) -> Vec<u8> {
3636
}
3737

3838
fn sigrec_decode(sig_rec: Vec<u8>) -> Result<RecoverableSignature, Error> {
39+
// Signature must be 64 + 1 bytes long (compact signature + recovery id)
40+
if sig_rec.len() != 65 {
41+
return Err(Error::InvalidSignature);
42+
}
43+
3944
let rsig = &sig_rec[1..];
4045
let rid = sig_rec[0] as i32 - 31;
4146

0 commit comments

Comments
 (0)