[invoice] Ignore InvalidLength fields
authorMatt Corallo <git@bluematt.me>
Tue, 24 Aug 2021 23:15:07 +0000 (23:15 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 31 Aug 2021 21:29:51 +0000 (21:29 +0000)
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

index ac7e7e835e08d07d3a7f4af38d590d48dc4f0f0b..777ac660f8e6b764d6ac5a191af3bcbb3636bc1d 100644 (file)
@@ -419,7 +419,7 @@ fn parse_tagged_parts(data: &[u5]) -> Result<Vec<RawTaggedField>, 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)}