connectd: fix memleak report.

h->ss is allocated, but the previous not freed.  It will be freed as soon as the
`struct handshake` is freed, but a temporary "leak" got reported:

```
**BROKEN** connectd: MEMLEAK: 0x55adfcff2f48
**BROKEN** connectd:   label=connectd/handshake.c:647:struct secret
**BROKEN** connectd:   backtrace:
**BROKEN** connectd:     ccan/ccan/tal/tal.c:477 (tal_alloc_)
**BROKEN** connectd:     connectd/handshake.c:647 (act_one_initiator)
**BROKEN** connectd:     connectd/handshake.c:1023 (initiator_handshake_)
**BROKEN** connectd:     connectd/connectd.c:615 (connection_out)
**BROKEN** connectd:     ccan/ccan/io/io.c:59 (next_plan)
**BROKEN** connectd:     ccan/ccan/io/io.c:407 (do_plan)
**BROKEN** connectd:     ccan/ccan/io/io.c:423 (io_ready)
**BROKEN** connectd:     ccan/ccan/io/poll.c:453 (io_loop)
**BROKEN** connectd:     connectd/connectd.c:2215 (main)
**BROKEN** connectd:   parents:
**BROKEN** connectd:     connectd/handshake.c:402:struct handshake
**BROKEN** connectd:     connectd/connectd.c:1774:struct connecting
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-07-21 14:58:19 +09:30
parent 2e28226e18
commit 36b323e6d2

View File

@@ -481,6 +481,7 @@ static struct io_plan *act_three_initiator(struct io_conn *conn,
* 3. `se = ECDH(s.priv, re)`
* * where `re` is the ephemeral public key of the responder
*/
tal_free(h->ss);
h->ss = tal(h, struct secret);
ecdh(&h->re, h->ss);
SUPERVERBOSE("# ss=0x%s", tal_hexstr(tmpctx, h->ss, sizeof(*h->ss)));