Commit 7e5cf41
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 <[email protected]>
[ Added test, removed Changelog --RR ]1 parent 6c7c78e commit 7e5cf41
File tree
7 files changed
+27
-23
lines changed- channeld
- common
- lightningd
- tests
- tools
- wallet/test
7 files changed
+27
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1571 | 1571 | | |
1572 | 1572 | | |
1573 | 1573 | | |
1574 | | - | |
| 1574 | + | |
1575 | 1575 | | |
1576 | 1576 | | |
1577 | | - | |
| 1577 | + | |
1578 | 1578 | | |
1579 | 1579 | | |
1580 | 1580 | | |
1581 | 1581 | | |
1582 | 1582 | | |
1583 | 1583 | | |
1584 | | - | |
| 1584 | + | |
1585 | 1585 | | |
1586 | | - | |
1587 | | - | |
1588 | | - | |
1589 | | - | |
1590 | | - | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
1591 | 1591 | | |
1592 | | - | |
1593 | | - | |
1594 | | - | |
1595 | | - | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
1596 | 1598 | | |
1597 | 1599 | | |
1598 | 1600 | | |
| |||
1629 | 1631 | | |
1630 | 1632 | | |
1631 | 1633 | | |
1632 | | - | |
| 1634 | + | |
1633 | 1635 | | |
1634 | 1636 | | |
1635 | 1637 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
219 | | - | |
220 | | - | |
| 219 | + | |
| 220 | + | |
221 | 221 | | |
| 222 | + | |
222 | 223 | | |
223 | 224 | | |
224 | 225 | | |
| |||
235 | 236 | | |
236 | 237 | | |
237 | 238 | | |
| 239 | + | |
238 | 240 | | |
239 | 241 | | |
240 | 242 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
90 | | - | |
| 89 | + | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2309 | 2309 | | |
2310 | 2310 | | |
2311 | 2311 | | |
2312 | | - | |
| 2312 | + | |
2313 | 2313 | | |
2314 | 2314 | | |
2315 | 2315 | | |
2316 | 2316 | | |
2317 | 2317 | | |
2318 | 2318 | | |
2319 | 2319 | | |
2320 | | - | |
| 2320 | + | |
2321 | 2321 | | |
2322 | 2322 | | |
2323 | 2323 | | |
| |||
2364 | 2364 | | |
2365 | 2365 | | |
2366 | 2366 | | |
2367 | | - | |
| 2367 | + | |
2368 | 2368 | | |
2369 | 2369 | | |
2370 | 2370 | | |
| |||
2439 | 2439 | | |
2440 | 2440 | | |
2441 | 2441 | | |
2442 | | - | |
| 2442 | + | |
2443 | 2443 | | |
2444 | 2444 | | |
2445 | 2445 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7016 | 7016 | | |
7017 | 7017 | | |
7018 | 7018 | | |
7019 | | - | |
7020 | 7019 | | |
7021 | 7020 | | |
7022 | 7021 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| 233 | + | |
233 | 234 | | |
234 | 235 | | |
235 | 236 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
303 | | - | |
| 303 | + | |
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
| |||
0 commit comments