cln/tools
Lagrang3 7e5cf41b4e htlc_wire: fix crash when adding an HTLC
In line channeld/channeld_wiregen.c:832 `*added+i` is not a tal object hence
the instruction in common/htlc_wire.c:200 `tal_arr(ctx, struct tlv_field, 0);` crashes CLN.
This is fixed by stating that added_htlc is a a varsize_type.

Logs:

2025-08-16T02:25:28.640Z **BROKEN** lightningd: FATAL SIGNAL 6 (version v25.05-200-g79b959b)V
...
2025-08-16T02:25:28.640Z **BROKEN** lightningd: backtrace: ccan/ccan/tal/tal.c:95 (call_error) 0x54f6bc
2025-08-16T02:25:28.640Z **BROKEN** lightningd: backtrace: ccan/ccan/tal/tal.c:169 (check_bounds) 0x54f75a
2025-08-16T02:25:28.640Z **BROKEN** lightningd: backtrace: ccan/ccan/tal/tal.c:178 (to_tal_hdr) 0x54f782
2025-08-16T02:25:28.640Z **BROKEN** lightningd: backtrace: ccan/ccan/tal/tal.c:193 (to_tal_hdr_or_null) 0x54f7c7
2025-08-16T02:25:28.640Z **BROKEN** lightningd: backtrace: ccan/ccan/tal/tal.c:471 (tal_alloc_) 0x54ffe4
2025-08-16T02:25:28.640Z **BROKEN** lightningd: backtrace: ccan/ccan/tal/tal.c:517 (tal_alloc_arr_) 0x5500c4
2025-08-16T02:25:28.640Z **BROKEN** lightningd: backtrace: common/htlc_wire.c:200 (fromwire_len_and_tlvstream) 0x48d63d
2025-08-16T02:25:28.640Z **BROKEN** lightningd: backtrace: common/htlc_wire.c:234 (fromwire_added_htlc) 0x48dd23
2025-08-16T02:25:28.640Z **BROKEN** lightningd: backtrace: channeld/channeld_wiregen.c:832 (fromwire_channeld_got_commitsig) 0x4c61fa
2025-08-16T02:25:28.640Z **BROKEN** lightningd: backtrace: lightningd/peer_htlcs.c:2377 (peer_got_commitsig) 0x4549cb
2025-08-16T02:25:28.640Z **BROKEN** lightningd: backtrace: lightningd/channel_control.c:1552 (channel_msg) 0x4140fe
2025-08-16T02:25:28.640Z **BROKEN** lightningd: backtrace: lightningd/subd.c:560 (sd_msg_read) 0x461513
2025-08-16T02:25:28.640Z **BROKEN** lightningd: backtrace: ccan/ccan/io/io.c:60 (next_plan) 0x544885
2025-08-16T02:25:28.640Z **BROKEN** lightningd: backtrace: ccan/ccan/io/io.c:422 (do_plan) 0x544cea
2025-08-16T02:25:28.640Z **BROKEN** lightningd: backtrace: ccan/ccan/io/io.c:439 (io_ready) 0x544d9d
2025-08-16T02:25:28.640Z **BROKEN** lightningd: backtrace: ccan/ccan/io/poll.c:455 (io_loop) 0x54665d
2025-08-16T02:25:28.640Z **BROKEN** lightningd: backtrace: lightningd/io_loop_with_timers.c:22 (io_loop_with_timers) 0x42d220
2025-08-16T02:25:28.640Z **BROKEN** lightningd: backtrace: lightningd/lightningd.c:1487 (main) 0x43280f

gdb inspection:
830             *added = num_added ? tal_arr(ctx, struct added_htlc, num_added) : NULL;
831             for (size_t i = 0; i < num_added; i++)
832                     fromwire_added_htlc(&cursor, &plen, *added + i);
(gdb) p i
$3 = 1

Changelog-None: crash introduced this release.
Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
[ Added test, removed Changelog --RR ]
2025-08-27 14:14:31 +09:30
..
gen Enable Length-Prefixed TLVs through Generator 2025-02-22 11:51:54 -06:00
test tools: remove DEVELOPER. 2023-09-21 20:08:24 +09:30
.gitignore reorganize .gitignore entries across subdirs. 2021-05-18 09:43:50 +09:30
bench-gossipd.sh devtools/gossipwith: use timestamp filter message not obsolete INIT_ROUTING_SYNC. 2024-06-19 15:54:24 +09:30
build-release.sh script: Poetry migration to uv for Fedora build 2025-08-20 08:46:43 +09:30
check-bolt.c tools/check-bolt: rewrite to give more accurate diagnostics when we're out of sync. 2024-06-19 15:54:24 +09:30
check-includes.sh tools/check-includes.sh: make shellcheck happy. 2021-12-06 10:05:39 +10:30
check-manpage.sh lightningd: add --developer runtime option. 2023-09-21 20:08:24 +09:30
check-release.sh build: Release build automation ([#7776]). 2024-12-03 11:56:23 +10:30
check-setup_locale.sh setup: add setup to make checks 2020-05-19 13:35:42 +09:30
check-spelling.sh tools: Remove lockfiles from spell-checking 2025-08-14 18:57:05 +09:30
docker-entrypoint.sh Docker: run directory for post-start if present. 2023-03-23 16:43:07 +10:30
fromschema.py doc: properly handle ``preformatted blocks`` 2025-05-15 16:06:08 +09:30
generate-wire.py htlc_wire: fix crash when adding an HTLC 2025-08-27 14:14:31 +09:30
headerversions.c tools: enforce minimum sqlite3 version number. 2025-08-11 11:08:43 +09:30
hsmtool.c hsmtool: implement new "derivetoremote" method 2025-07-08 12:21:24 +09:30
Makefile hsmtool: implement new "derivetoremote" method 2025-07-08 12:21:24 +09:30
md2man.sh doc: properly handle ``preformatted blocks`` 2025-05-15 16:06:08 +09:30
mockup.sh update-mocks: handle missing deprecated_apis. 2022-07-09 09:59:52 +09:30
reckless change version 25.09rc2 for release 2025-08-21 16:12:27 +09:30
refresh-submodules.sh make: have git submodule update be recursive 2020-12-11 13:20:54 +01:00
repro-build.sh ci: Shasums updated for libsqlite in Ubuntu Noble 2025-07-29 16:28:38 -05:00
update-mocks.sh tools: make sure we don't use optimization when building mocks. 2023-10-23 15:48:50 +10:30