core-lightning/wire
Rusty Russell 2ac775f9f4 lightningd: fix crash with -O3 -flto.
It's foolish to ban passing NULL, 0 to memcpy, memset et al, but
it's been done.  At high level of optimization, GCC assumes this doesn't
happen, and yep, assumes "if (ctx)" inside tal_free() must be true.

So when a psbt is NULL, and psbt_get_bytes returns NULL, a crash ensues:

```
lightningd: FATAL SIGNAL 6 (version v0.12.0rc2-6-g47efa5d-modded)
0x5557dfc42fef send_backtrace
	common/daemon.c:33
0x5557dfc42fef crashdump
	common/daemon.c:46
0x7fe93ef5851f ???
	./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x7fe93efaca7c __pthread_kill_implementation
	./nptl/pthread_kill.c:44
0x7fe93efaca7c __pthread_kill_internal
	./nptl/pthread_kill.c:78
0x7fe93efaca7c __GI___pthread_kill
	./nptl/pthread_kill.c:89
0x7fe93ef58475 __GI_raise
	../sysdeps/posix/raise.c:26
0x7fe93ef3e7f2 __GI_abort
	./stdlib/abort.c:79
0x5557dfbb0c28 call_error
	ccan/ccan/tal/tal.c:93
0x5557dfbb0c34 check_bounds
	ccan/ccan/tal/tal.c:165
0x5557dfbb0c34 to_tal_hdr
	ccan/ccan/tal/tal.c:178
0x5557dfc7a1d3 tal_free
	ccan/ccan/tal/tal.c:482
0x5557dfc609d3 tal_free
	ccan/ccan/tal/tal.c:477
0x5557dfc609d3 towire_wally_psbt
	bitcoin/psbt.c:743
0x5557dfbc5dfc towire_dualopend_got_offer_reply
	openingd/dualopend_wiregen.c:358
0x5557dfbc5dfc openchannel2_hook_cb
	lightningd/dual_open_control.c:671
0x5557dfc22f4f plugin_hook_callback
	lightningd/plugin_hook.c:210
0x5557dfc1dfbe plugin_response_handle
	lightningd/plugin.c:591
0x5557dfc1dfbe plugin_read_json_one
	lightningd/plugin.c:702
0x5557dfc1dfbe plugin_read_json
	lightningd/plugin.c:747
0x5557dfc71756 next_plan
	ccan/ccan/io/io.c:59
0x5557dfc775d5 io_ready
	ccan/ccan/io/io.c:417
0x5557dfc775d5 io_loop
	ccan/ccan/io/poll.c:453
0x5557dfbdb1ce io_loop
	ccan/ccan/io/poll.c:380
0x5557dfbdb1ce io_loop_with_timers
	lightningd/io_loop_with_timers.c:22
0x5557dfbb37d1 main
	lightningd/lightningd.c:1195
0x7fe93ef3fd8f __libc_start_call_main
	../sysdeps/nptl/libc_start_call_main.h:58
0x7fe93ef3fe3f __libc_start_main_impl
	../csu/libc-start.c:392
0x5557dfbb6e84 ???
	???:0
0xffffffffffffffff ???
	???:0
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2022-09-12 14:00:41 +02:00
..
test doc: update BOLTs to bc86304b4b0af5fd5ce9d24f74e2ebbceb7e2730 2022-09-12 09:34:52 +09:30
.gitignore reorganize .gitignore entries across subdirs. 2021-05-18 09:43:50 +09:30
bolt12_exp_wire.csv offers: import latest variant from draft. 2022-03-25 13:55:44 +10:30
bolt12_wire.csv offers: import latest variant from draft. 2022-03-25 13:55:44 +10:30
channel_type_wire.csv common/channel_type: wrapper for generated 'struct channel_type'. 2021-09-13 15:53:23 +02:00
extracted_bolt12_01_recurrence.patch bolt12: remove deprecated chains fields 2021-12-01 05:44:28 +10:30
extracted_onion_01_offers.patch bolt11: support payment_metadata. 2022-04-02 09:40:18 +10:30
extracted_onion_02_modernonion.patch connectd: restore obs2 onion support. 2022-03-29 10:55:12 +10:30
extracted_onion_03_onionmsg-payload-as-bytearr.patch offers: import latest variant from draft, part 2. 2022-03-25 13:55:44 +10:30
extracted_onion_exp_badonion_blinding.patch wire/Makefile: refactor to allow non-experimental spec patches. 2021-01-13 14:45:36 +01:00
extracted_onion_exp_enctlv.patch bolt11: support payment_metadata. 2022-04-02 09:40:18 +10:30
extracted_peer_03_openchannelv2.patch doc: update BOLTs to bc86304b4b0af5fd5ce9d24f74e2ebbceb7e2730 2022-09-12 09:34:52 +09:30
extracted_peer_04_opt_will_fund.patch wire: fix patch file to match actual peer_wire.csv. 2021-09-02 14:04:32 +09:30
extracted_peer_05_newonion.patch spec: import latest onionmessage spec, based on routeblinding. 2021-12-01 05:44:28 +10:30
extracted_peer_exp_add_htlc-plus-blinding.patch wire/Makefile: refactor to allow non-experimental spec patches. 2021-01-13 14:45:36 +01:00
extracted_peer_exp_quiescence-protocol.patch EXPERIMENTAL: import spec for quiescence. 2021-06-01 12:08:51 -05:00
extracted_peer_exp_upgradable.patch channeld: import updated channel_upgrade spec. 2021-10-08 16:07:21 +02:00
extracted_peer-shutdown-wrong_funding.patch protocol: add TLV for shutdown message, use 100 as "wrong_funding" outpoint. 2021-03-16 13:08:40 +10:30
fromwire.c check: make sure all files outside contrib/ include "config.h" first. 2021-12-06 10:05:39 +10:30
Makefile wire: generate printwire_ routines for bolt12 CSV. 2022-03-25 13:55:44 +10:30
onion_defs.h
onion_wire.csv doc: increase BOLT level to 03468e17563650fb9bfe58b2da4d1e5d28e92009 2022-09-12 09:34:52 +09:30
onion_wire.h Makefile: use completely separate spec-derived files for EXPERIMENTAL_FEATURES 2020-09-08 09:42:00 +09:30
peer_wire.c doc: update BOLTs to bc86304b4b0af5fd5ce9d24f74e2ebbceb7e2730 2022-09-12 09:34:52 +09:30
peer_wire.csv doc: update BOLTs to bc86304b4b0af5fd5ce9d24f74e2ebbceb7e2730 2022-09-12 09:34:52 +09:30
peer_wire.h channeld: take over gossip_rcvd_filter.c and is_msg_gossip_broadcast. 2022-06-17 14:14:02 +09:30
tlvstream.c wire/tlvstream: const. 2022-04-02 09:40:18 +10:30
tlvstream.h doc: update c-lightning to Core Lightning almost everywhere. 2022-04-07 06:53:26 +09:30
towire.c lightningd: fix crash with -O3 -flto. 2022-09-12 14:00:41 +02:00
wire_io.c check: make sure all files outside contrib/ include "config.h" first. 2021-12-06 10:05:39 +10:30
wire_io.h connectd: do decryption for peers. 2022-01-20 15:24:06 +10:30
wire_sync.c cleanup: remove unneeded includes in C files. 2021-09-17 09:43:22 +09:30
wire_sync.h
wire.h peer_exchange: set, read and log remote_addr 2022-02-22 05:45:47 +10:30