cln/lightningd
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
..
test lightningd: require local_alias in new_channel(). 2025-08-14 14:04:11 +09:30
.gitignore Ignore all the deamon inside the git history 2021-10-28 15:51:38 +02:00
anchorspend.c anchorspend: fix weight estimation. 2025-05-06 12:27:53 +09:30
anchorspend.h channeld: use anchors on peer's commitment(s) if we can't broadcast our own. 2023-10-27 11:19:56 +10:30
bitcoind.c lightningd: allow bitcoind_getrawblockbyheight callback to free call struct. 2025-04-01 13:29:28 -05:00
bitcoind.h lightningd: mangle parameter names in bitcoind_getrawblockbyheight_ so mocks don't get shadow warning. 2025-04-02 11:22:54 +10:30
chaintopology.c wallet: record all coin movements into chain_moves or channel_moves tables. 2025-08-19 13:37:50 +09:30
chaintopology.h ccan/htable: update to explicit DUPS/NODUPS types. 2025-01-21 09:18:25 +10:30
channel.c lightningd: speed mapping from coinmoves table to channel for listcoinmoves. 2025-08-19 13:37:50 +09:30
channel.h lightningd: speed mapping from coinmoves table to channel for listcoinmoves. 2025-08-19 13:37:50 +09:30
channel_control.c wallet: record all coin movements into chain_moves or channel_moves tables. 2025-08-19 13:37:50 +09:30
channel_control.h lightningd: don't hand redundant block_height to block notifications. 2025-05-15 16:40:33 +09:30
channel_gossip.c lightningd: don't complain when gossipd gives us channel_update for dying channel. 2025-05-17 13:05:04 -05:00
channel_gossip.h lightningd: don't hand redundant block_height to block notifications. 2025-05-15 16:40:33 +09:30
channel_state.h channel: Fix channel state max value 2025-08-07 16:13:20 +09:30
closed_channel.c lightningd: keep closed channels in memory. 2025-04-29 13:31:23 +09:30
closed_channel.h lightningd: save shachain for closed channels. 2025-04-29 13:31:23 +09:30
closing_control.c lightningd: new internal-use commands to allow utxo spend / deposit injection. 2025-08-19 13:37:50 +09:30
closing_control.h lightningd: make close_txs parameter to resolve_close_command const. 2024-11-25 20:23:21 +10:30
coin_mvts.c lightningd: migrate events from bookkeeper at startup. 2025-08-19 13:37:50 +09:30
coin_mvts.h lightningd: migrate events from bookkeeper at startup. 2025-08-19 13:37:50 +09:30
configs.c lightningd: remove old listconfigs output. 2025-03-12 09:26:08 +10:30
connect_control.c lightningd: fix race with crossover pings. 2025-08-14 17:35:39 +09:30
connect_control.h connectd: reconnect for non-transient connections. 2024-11-25 15:39:13 +10:30
datastore.c lightningd: fix overzealous memleak detection in json_add_datastore. 2024-12-20 15:36:07 +10:30
dual_open_control.c lightningd: speed mapping from coinmoves table to channel for listcoinmoves. 2025-08-19 13:37:50 +09:30
dual_open_control.h common: BOLT update: option_anchors_zero_fee_htlc_tx is now simply "option_anchors". 2024-06-19 15:54:24 +09:30
feerate.c lightnind: remove deprecated feerate names. 2024-03-25 15:02:35 +10:30
feerate.h lightningd: clean up feerate handling, deprecate old terms. 2023-04-10 07:31:12 +09:30
forwards.c lightningd: migrate events from bookkeeper at startup. 2025-08-19 13:37:50 +09:30
forwards.h lightningd: clean up notification infrastructure. 2024-01-26 10:30:22 +10:30
gossip_control.c lightningd: don't hand redundant block_height to block notifications. 2025-05-15 16:40:33 +09:30
gossip_control.h lightningd: don't hand redundant block_height to block notifications. 2025-05-15 16:40:33 +09:30
gossip_generation.c lightningd: store our id as a struct pubkey as well as struct node_id. 2024-07-23 09:54:47 +09:30
gossip_generation.h bitcoin/short_channel_id: pass by copy everywhere. 2024-03-20 13:51:48 +10:30
hsm_control.c pytest: create warning if we grind signature shorter than 71 bytes, don't fail. 2025-05-06 12:27:53 +09:30
hsm_control.h hsmd: rename "capabilities" flags for hsm fds to "permissions" 2023-08-08 14:31:47 +09:30
htlc_end.c common: handle taken() extra_tlvs in new_existing_htlc properly. 2025-08-14 18:57:05 +09:30
htlc_end.h lightningd: Add extra_tlvs to htlc_accepted_hook 2025-08-14 18:57:05 +09:30
htlc_set.c lightningd: generalize htlc_set. 2024-10-27 13:57:50 +11:00
htlc_set.h ccan/htable: update to explicit DUPS/NODUPS types. 2025-01-21 09:18:25 +10:30
invoice.c deprecations: update v25.11 to v25.12. 2025-06-24 09:57:24 +09:30
invoice.h sendpays: hook into the wait subsystem. 2023-10-28 15:48:26 +10:30
io_loop_with_timers.c database: pull out database code into a new module 2022-03-05 15:03:34 +10:30
io_loop_with_timers.h lightningd/io_loop_with_timers.c: Move mainloop to its own source file, have chaintopology use it. 2019-05-31 17:57:10 +02:00
jsonrpc.c lightningd: make notifications from plugins just like native ones. 2025-08-18 10:01:07 +09:30
jsonrpc.h lightningd: make notifications from plugins just like native ones. 2025-08-18 10:01:07 +09:30
lightningd.c lightningd: migrate events from bookkeeper at startup. 2025-08-19 13:37:50 +09:30
lightningd.h lightningd: migrate events from bookkeeper at startup. 2025-08-19 13:37:50 +09:30
log.c lightningd: use static buffer for common log path. 2025-05-08 14:01:38 +09:30
log.h common: don't send trace messages by default, don't ratelimit at all. 2024-12-16 09:48:51 +10:30
log_status.c lightningd/log: clean up nomenclature. 2023-07-19 19:13:57 +09:30
log_status.h lightningd/log: clean up nomenclature. 2023-07-19 19:13:57 +09:30
Makefile lightningd: fix race with crossover pings. 2025-08-14 17:35:39 +09:30
memdump.c lightningd: maintain a hash table of short_channel_id, for faster lookup. 2025-08-14 14:04:11 +09:30
memdump.h lightningd: simplify memleak code. 2022-03-10 09:40:09 +10:30
notification.c lightningd: add chainmoves and channelmoves to wait command. 2025-08-19 13:37:50 +09:30
notification.h lightningd: add chainmoves and channelmoves to wait command. 2025-08-19 13:37:50 +09:30
offer.c BOLT12: remove -offers from bolt12 quotes, update them. 2025-02-11 20:19:01 -06:00
onchain_control.c wallet: record all coin movements into chain_moves or channel_moves tables. 2025-08-19 13:37:50 +09:30
onchain_control.h onchaind: remove 'is_replay' logic 2021-12-28 04:42:42 +10:30
onion_message.c lightningd: fix use of deprecation macro. 2025-03-12 09:26:08 +10:30
onion_message.h common: remove support for pre v0.10.2 onionmessages. 2021-12-01 05:44:28 +10:30
opening_common.c lightningd: rename anchor_confirms to funding_confirms. 2025-05-15 16:40:33 +09:30
opening_common.h lightningd: pass disconnect flag to subd's errcb. 2023-10-23 15:48:50 +10:30
opening_control.c lightningd: add channel_type to openchannel & openchannel2 hooks. 2025-08-15 11:11:39 +09:30
opening_control.h common: BOLT update: option_anchors_zero_fee_htlc_tx is now simply "option_anchors". 2024-06-19 15:54:24 +09:30
options.c lightningd: migrate events from bookkeeper at startup. 2025-08-19 13:37:50 +09:30
options.h lightningd: remove old listconfigs output. 2025-03-12 09:26:08 +10:30
pay.c lightningd: migrate events from bookkeeper at startup. 2025-08-19 13:37:50 +09:30
pay.h lightningd: refactor payment failed. 2024-10-27 13:57:50 +11:00
peer_control.c lightningd: maintain a hash table of short_channel_id, for faster lookup. 2025-08-14 14:04:11 +09:30
peer_control.h lightningd: don't hand redundant block_height to block notifications. 2025-05-15 16:40:33 +09:30
peer_fd.c subdaemons: remove gossipd fd from per-peer daemons. 2022-02-08 11:15:52 +10:30
peer_fd.h lightningd: create helper routine to make socketpair for a channel. 2025-02-26 10:22:03 -06:00
peer_htlcs.c htlc_wire: fix crash when adding an HTLC 2025-08-27 14:14:31 +09:30
peer_htlcs.h lightningd: Add extra_tlvs to htlc_accepted_hook 2025-08-14 18:57:05 +09:30
ping.c lightningd: fix race with crossover pings. 2025-08-14 17:35:39 +09:30
ping.h lightningd: fix race with crossover pings. 2025-08-14 17:35:39 +09:30
plugin.c lightningd: add dev option to save hooks and notifications to/from plugins. 2025-08-18 10:01:07 +09:30
plugin.h lightningd: add dev option to save hooks and notifications to/from plugins. 2025-08-18 10:01:07 +09:30
plugin_control.c lightningd: allow builtin plugins to be stopped. 2024-11-18 11:03:26 +10:30
plugin_control.h plugins: add command field to subcommand output. 2021-06-25 09:49:33 +09:30
plugin_hook.c lightningd: add dev option to save hooks and notifications to/from plugins. 2025-08-18 10:01:07 +09:30
plugin_hook.h plugin: wire JSON id for commands which caused hooks to fire. 2022-09-16 12:31:45 +09:30
routehint.c common/amount: rename amount_sat_zero/amount_msat_zerp -> amount_sat_is_zero/amount_msat_is_zero. 2024-09-19 12:16:53 +09:30
routehint.h invoice: overhaul routehints to use topology.listincoming, cleanup. 2021-06-16 10:29:17 +09:30
runes.c use json_escape_unescape_len() 2025-08-15 15:23:57 +09:30
runes.h runes: ensure that uniqueid is a valid number. 2023-09-12 15:19:02 +09:30
signmessage.c plugins: all plugins must now support non-numeric JSON RPC id fields. 2025-03-12 09:26:08 +10:30
subd.c common: don't send trace messages by default, don't ratelimit at all. 2024-12-16 09:48:51 +10:30
subd.h lightningd: allow subd_req() to take replycb_data arg. 2024-11-13 14:44:03 +10:30
wait.c lightningd: migrate events from bookkeeper at startup. 2025-08-19 13:37:50 +09:30
wait.h lightningd: migrate events from bookkeeper at startup. 2025-08-19 13:37:50 +09:30
watch.c ccan/htable: update to explicit DUPS/NODUPS types. 2025-01-21 09:18:25 +10:30
watch.h ccan/htable: update to explicit DUPS/NODUPS types. 2025-01-21 09:18:25 +10:30