Browse Source

tlv: fail if parsed length doesn't match packet length

pr-2587
lisa neigut 6 years ago
committed by Rusty Russell
parent
commit
d0f50c8690
  1. 3
      tools/generate-wire.py

3
tools/generate-wire.py

@ -850,6 +850,7 @@ tlv__type_impl_towire_template = """static void towire__{tlv_name}(const tal_t *
tlv__type_impl_fromwire_template = """static struct {tlv_name} *fromwire__{tlv_name}(const tal_t *ctx, const u8 **p, size_t *plen, const u16 *len) {{
\tu8 msg_type, msg_len;
\tsize_t start_len = *plen;
\tif (*plen < *len)
\t\treturn NULL;
@ -873,7 +874,7 @@ tlv__type_impl_fromwire_template = """static struct {tlv_name} *fromwire__{tlv_n
\t\t\t*plen -= msg_len;
\t\t}}
\t}}
\tif (!*p) {{
\tif (!*p || start_len - *plen != *len) {{
\t\ttal_free({tlv_name});
\t\treturn NULL;
\t}}

Loading…
Cancel
Save