mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
tlv: fail if parsed length doesn't match packet length
This commit is contained in:
parent
28c3f9ca21
commit
d0f50c8690
@ -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…
Reference in New Issue
Block a user