mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
generate-wire.py: allow NULL len parameter from fromwire_*
It implies tal_count() gives the length. Great for almost all callers which don't care if there are extra bytes. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -149,8 +149,7 @@ void handle_channel_announcement(
|
|||||||
const tal_t *tmpctx = tal_tmpctx(peer);
|
const tal_t *tmpctx = tal_tmpctx(peer);
|
||||||
|
|
||||||
serialized = tal_dup_arr(tmpctx, u8, announce, len, 0);
|
serialized = tal_dup_arr(tmpctx, u8, announce, len, 0);
|
||||||
/* FIXME: use NULL arg to mean tal_count() here! */
|
if (!fromwire_channel_announcement(serialized, NULL,
|
||||||
if (!fromwire_channel_announcement(serialized, &len,
|
|
||||||
&node_signature_1, &node_signature_2,
|
&node_signature_1, &node_signature_2,
|
||||||
&channel_id,
|
&channel_id,
|
||||||
&bitcoin_signature_1,
|
&bitcoin_signature_1,
|
||||||
@@ -207,8 +206,7 @@ void handle_channel_update(struct peer *peer, const u8 *update, size_t len)
|
|||||||
const tal_t *tmpctx = tal_tmpctx(peer);
|
const tal_t *tmpctx = tal_tmpctx(peer);
|
||||||
|
|
||||||
serialized = tal_dup_arr(tmpctx, u8, update, len, 0);
|
serialized = tal_dup_arr(tmpctx, u8, update, len, 0);
|
||||||
/* FIXME: use NULL arg to mean tal_count() here! */
|
if (!fromwire_channel_update(serialized, NULL, &signature, &channel_id,
|
||||||
if (!fromwire_channel_update(serialized, &len, &signature, &channel_id,
|
|
||||||
×tamp, &flags, &expiry,
|
×tamp, &flags, &expiry,
|
||||||
&htlc_minimum_msat, &fee_base_msat,
|
&htlc_minimum_msat, &fee_base_msat,
|
||||||
&fee_proportional_millionths)) {
|
&fee_proportional_millionths)) {
|
||||||
@@ -283,8 +281,7 @@ void handle_node_announcement(
|
|||||||
const tal_t *tmpctx = tal_tmpctx(peer);
|
const tal_t *tmpctx = tal_tmpctx(peer);
|
||||||
|
|
||||||
serialized = tal_dup_arr(tmpctx, u8, node_ann, len, 0);
|
serialized = tal_dup_arr(tmpctx, u8, node_ann, len, 0);
|
||||||
/* FIXME: use NULL arg to mean tal_count() here! */
|
if (!fromwire_node_announcement(serialized, NULL,
|
||||||
if (!fromwire_node_announcement(serialized, &len,
|
|
||||||
&signature, ×tamp, &ipv6, &port,
|
&signature, ×tamp, &ipv6, &port,
|
||||||
&node_id, rgb_color, alias)) {
|
&node_id, rgb_color, alias)) {
|
||||||
tal_free(tmpctx);
|
tal_free(tmpctx);
|
||||||
|
|||||||
@@ -169,7 +169,12 @@ class Message(object):
|
|||||||
print('\t{} {};'.format(f.typename, f.name));
|
print('\t{} {};'.format(f.typename, f.name));
|
||||||
|
|
||||||
print('\tconst u8 *cursor = p;\n'
|
print('\tconst u8 *cursor = p;\n'
|
||||||
|
'\tsize_t tmp_len;\n'
|
||||||
'\n'
|
'\n'
|
||||||
|
'\tif (!plen) {{\n'
|
||||||
|
'\t\ttmp_len = tal_count(p);\n'
|
||||||
|
'\t\tplen = &tmp_len;\n'
|
||||||
|
'\t}}\n'
|
||||||
'\tif (fromwire_u16(&cursor, plen) != {})\n'
|
'\tif (fromwire_u16(&cursor, plen) != {})\n'
|
||||||
'\t\treturn false;'
|
'\t\treturn false;'
|
||||||
.format(self.enum.name))
|
.format(self.enum.name))
|
||||||
|
|||||||
Reference in New Issue
Block a user