From d8738452ed0d73a3af8ee563d4a488521fda24c5 Mon Sep 17 00:00:00 2001 From: lisa neigut Date: Sun, 24 Mar 2019 16:23:34 -0700 Subject: [PATCH] tlv: it's ok to be odd fail if a message type is even and it's not included. otherwise, continue with the next message type. --- tools/generate-wire.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/generate-wire.py b/tools/generate-wire.py index ead9ffcc5..870272351 100755 --- a/tools/generate-wire.py +++ b/tools/generate-wire.py @@ -863,9 +863,13 @@ tlv__type_impl_fromwire_template = """static struct {tlv_name} *fromwire__{tlv_n \t\t}} \t\tswitch((enum {tlv_name}_type)msg_type) {{ {cases}\t\tdefault: -\t\t\t// FIXME: print a warning / message? -\t\t\t*p+= msg_len; -\t\t\tplen -= msg_len; +\t\t\tif (msg_type % 2 == 0) {{ // it's ok to be odd +\t\t\t\tfromwire_fail(p, plen); +\t\t\t\ttal_free({tlv_name}); +\t\t\t\treturn NULL; +\t\t\t}} +\t\t\t*p += msg_len; +\t\t\t*plen -= msg_len; \t\t}} \t}} \tif (!*p) {{