From c7cf5011bebc01702bd5540645e757c79fa6d265 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 24 Aug 2021 23:15:07 +0000 Subject: [PATCH] [invoice] Ignore InvalidLength fields BOLT 11 states that a reader "MUST skip over...`p`, `h`, `s` or `n` fields that do NOT have data_lengths of 52, 52, 52 or 53, respectively." Here we do so by simply ignoring any invalid-length field. --- lightning-invoice/src/de.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lightning-invoice/src/de.rs b/lightning-invoice/src/de.rs index ac7e7e835..777ac660f 100644 --- a/lightning-invoice/src/de.rs +++ b/lightning-invoice/src/de.rs @@ -419,7 +419,7 @@ fn parse_tagged_parts(data: &[u5]) -> Result, ParseError> { Ok(field) => { parts.push(RawTaggedField::KnownSemantics(field)) }, - Err(ParseError::Skip) => { + Err(ParseError::Skip)|Err(ParseError::Bech32Error(bech32::Error::InvalidLength)) => { parts.push(RawTaggedField::UnknownSemantics(field.into())) }, Err(e) => {return Err(e)} -- 2.39.5