From d370aac020d3a0c8ce851e324fb52edccfae3f07 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 30 Jan 2022 14:07:30 +1030 Subject: [PATCH] gossipd: fix longstanding logic error in gossip_generation. `hc` is never NULL, since it's `hc = &chan->half[direction];`; we really meant "is it initialized", and valgrind under CI finally caught it: ``` ==69243== Conditional jump or move depends on uninitialised value(s) ==69243== at 0x11C595: handle_local_channel_update (gossip_generation.c:758) ==69243== by 0x115254: recv_req (gossipd.c:986) ==69243== by 0x128F8D: handle_read (daemon_conn.c:31) ==69243== by 0x16BEE1: next_plan (io.c:59) ==69243== by 0x16CAE9: do_plan (io.c:407) ==69243== by 0x16CB2B: io_ready (io.c:417) ==69243== by 0x16EE1E: io_loop (poll.c:453) ==69243== by 0x1154DA: main (gossipd.c:1089) ==69243== ``` Signed-off-by: Rusty Russell --- gossipd/gossip_generation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gossipd/gossip_generation.c b/gossipd/gossip_generation.c index faf01bb72..70b8f854b 100644 --- a/gossipd/gossip_generation.c +++ b/gossipd/gossip_generation.c @@ -751,7 +751,7 @@ void handle_local_channel_update(struct daemon *daemon, const u8 *msg) return; /* Too early? Defer (don't worry if it's unannounced). */ - if (hc && is_chan_public(chan)) { + if (is_halfchan_defined(hc) && is_chan_public(chan)) { u32 now = time_now().ts.tv_sec; u32 next_time = hc->bcast.timestamp + GOSSIP_MIN_INTERVAL(daemon->rstate->dev_fast_gossip);