wire: rename var_int to bigsize, and insist on minimal.

The new TLV spec uses BigSize, like Bitcoin's CompactInt but
*little-endian*.  So change our name for clarity, and insist that
decoding be minimal as the spec requires.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-07-18 14:35:55 +09:30
parent 868bde5e00
commit 54790c17ea
4 changed files with 24 additions and 13 deletions

View File

@@ -1057,7 +1057,7 @@ tlv__type_impl_fromwire_template = """static struct {tlv_name} *fromwire__{tlv_n
\twhile (*plen) {{
\t\tmsg_type = fromwire_u8(p, plen);
\t\tmsg_len = fromwire_var_int(p, plen);
\t\tmsg_len = fromwire_bigsize(p, plen);
\t\tif (*plen < msg_len) {{
\t\t\tfromwire_fail(p, plen);
\t\t\tbreak;
@@ -1103,7 +1103,7 @@ print_tlv_template = """static void printwire_{tlv_name}(const char *fieldname,
\twhile (cursor) {{
\t\tmsg_type = fromwire_u8(&cursor, &plen);
\t\tmsg_size = fromwire_var_int(&cursor, &plen);
\t\tmsg_size = fromwire_bigsize(&cursor, &plen);
\t\tif (!cursor)
\t\t\tbreak;
\t\tswitch ((enum {tlv_name}_type)msg_type) {{