cln/tests
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
..
data pytest: save pre-movement dbs, and accounting dbs. 2025-08-14 19:49:09 +09:30
fuzz fuzz-tests: Add coverage increasing inputs to seed corpora 2025-08-06 13:53:49 +09:30
plugins libplugin: allow sync interface to be used at all times. 2025-08-19 13:37:50 +09:30
vectors pytest: Remove onion test vectors containing legacy onions. 2022-03-18 09:20:11 +10:30
__init__.py feat: add pytest config 2025-08-11 11:06:22 +09:30
autogenerate-rpc-examples.py docs: Added fetchbip353 example in autogenerate script 2025-08-17 09:47:19 +09:30
benchmark.py pytest: always provide payment_secret when making payments. 2021-07-14 14:38:00 -05:00
conftest.py pytest: use --developer instead of environment variable. 2023-09-21 20:08:24 +09:30
fixtures.py pytest: don't add bookeeper-db option if bookkeeper is disabled. 2025-02-24 19:38:37 +10:30
pytest.ini feat: add pytest config 2025-08-11 11:06:22 +09:30
rkls_github_canned_server.py fix: replace deprecated flask.escape with markupsafe.escape 2025-08-11 11:06:22 +09:30
test_askrene.py askrene: rework the caller of the MCF solver 2025-08-08 14:07:51 +09:30
test_bookkeeper.py lightningd: fix name of chainmoves journal entry. 2025-08-21 13:21:17 +09:30
test_cln_lsps.py lsps: Add test for Lsps0 2025-05-02 13:34:21 -07:00
test_cln_rs.py cln-bip353: add plugin that fetches payment instructions from human readable addresses 2025-08-14 18:41:23 +09:30
test_clnrest.py clnrest: add more valid request and response types 2025-07-25 08:18:44 -07:00
test_closing.py onchaind: don't consider our anchors to be payments into the wallet. 2025-08-14 19:49:09 +09:30
test_coinmoves.py lightningd: fix name of chainmoves journal entry. 2025-08-21 13:21:17 +09:30
test_connection.py openingd: test that channel open seems possible before bothering peer. 2025-08-18 16:19:22 +09:30
test_db.py wallet: fix incorrect channel_htlcs id migration. 2025-05-17 13:05:04 -05:00
test_gossip.py pytest: fix flake in test_gossip_force_broadcast_channel_msgs caused by ping timeout. 2025-05-16 22:40:45 +09:30
test_invoices.py BOLT11: Make payment secret field ('s') mandatory 2025-07-07 11:18:37 +09:30
test_misc.py pytest: restore bookkeeper to recover tests. 2025-08-19 13:37:50 +09:30
test_mkfunding.py pytest: add tests for devtools/mkfunding 2023-01-09 14:50:30 -06:00
test_onion.py lightningd: remove support for legacy onion format. 2022-03-18 09:20:11 +10:30
test_opening.py openingd: test that channel open seems possible before bothering peer. 2025-08-18 16:19:22 +09:30
test_pay.py htlc_wire: fix crash when adding an HTLC 2025-08-27 14:14:31 +09:30
test_plugin.py libplugin: allow sync interface to be used at all times. 2025-08-19 13:37:50 +09:30
test_reckless.py pytest: test python plugin installation via uv 2025-08-12 09:28:21 +09:30
test_renepay.py pytest: fix race in test_renepay where we didn't wait for all channels. 2025-04-16 08:02:14 +09:30
test_restart.py splice: tx_abort no longer reestablishes 2024-11-21 14:15:36 +10:30
test_runes.py pytest: fix up bolt11 tests to include s field. 2025-07-07 11:18:37 +09:30
test_splice.py bkpr: add bookkeeping assertions to splice in + out tests 2024-11-17 14:25:29 +10:30
test_splicing.py pytest: fix flake in test_route_by_old_scid 2025-08-15 17:13:31 +09:30
test_splicing_disconnect.py pytest: fix test_splice_disconnect_commit 2025-01-27 11:07:04 +10:30
test_splicing_insane.py splice: Allow splice_update to return signatures 2024-11-12 06:42:52 +10:30
test_wallet.py pytest: fix flake in test_peer_anchor_push 2025-05-15 17:20:07 +09:30
test_xpay.py xpay: add option to pay bip353. 2025-08-18 14:57:46 +09:30
utils.py lightningd: add listchainmoves and listchannelmoves commands. 2025-08-19 13:37:50 +09:30
valgrind-suppressions.txt pytest: Use valgrind target suppressions instead of skipping tests 2022-03-10 10:21:41 +10:30