From 08913edee370f19b970a73e445c05def437cd6a3 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 1 Sep 2021 09:47:47 +0930 Subject: [PATCH] Thanks to MacOS for having stack smashing detection! Reported-by: @larsschenk Reported-by: @nickfarrow Fixes: #4728 Signed-off-by: Rusty Russell --- common/initial_commit_tx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/initial_commit_tx.c b/common/initial_commit_tx.c index 0330a7801cf0..4c59db2858d6 100644 --- a/common/initial_commit_tx.c +++ b/common/initial_commit_tx.c @@ -101,7 +101,8 @@ struct bitcoin_tx *initial_commit_tx(const tal_t *ctx, enum side lessor = !opener; u32 sequence; void *dummy_local = (void *)LOCAL, *dummy_remote = (void *)REMOTE; - const void *output_order[NUM_SIDES]; + /* There is a direct, and possibly an anchor output for each side. */ + const void *output_order[2 * NUM_SIDES]; const u8 *funding_wscript = bitcoin_redeem_2of2(tmpctx, &funding_key[LOCAL], &funding_key[REMOTE]); @@ -286,6 +287,7 @@ struct bitcoin_tx *initial_commit_tx(const tal_t *ctx, } assert(n <= tx->wtx->num_outputs); + assert(n <= ARRAY_SIZE(output_order)); /* BOLT #3: *