Browse Source

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.
pr-2587
lisa neigut 6 years ago
committed by Rusty Russell
parent
commit
d8738452ed
  1. 10
      tools/generate-wire.py

10
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) {{

Loading…
Cancel
Save