gossip: Fix a memcmp with unset memory in broadcast queue

`tal_fmt` overallocates the returned string under some circumstances,
meaning that the trailer of the formatted string is unset, but still
considered in `tal_len`. The solution then is to truncate the
formatted string to the real string length. Only necessary here, since
we mix strings and `tal_len`.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker
2018-01-11 14:57:00 +01:00
committed by Rusty Russell
parent 4fe83cd405
commit 3a42e52bcd
2 changed files with 8 additions and 3 deletions

View File

@@ -554,6 +554,7 @@ const struct short_channel_id *handle_channel_announcement(
tag = type_to_string(pending, struct short_channel_id,
&pending->short_channel_id);
tal_resize(&tag, strlen(tag));
/* BOLT #7:
*
@@ -635,6 +636,7 @@ bool handle_pending_cannouncement(struct routing_state *rstate,
list_del_from(&rstate->pending_cannouncement, &pending->list);
tag = type_to_string(pending, struct short_channel_id, scid);
tal_resize(&tag, strlen(tag));
/* BOLT #7:
*