common: don't crash on bad sphinx payload.

It's cleanest to eliminate the SPHINX_INVALID_PAYLOAD altogether.

lightning_channeld: FATAL SIGNAL (version v0.7.3-242-gb1583bb-modded)
0x55a8169eed08 send_backtrace
	common/daemon.c:41
0x55a8169fc3eb status_failed
	common/status.c:206
0x55a8169fc657 status_backtrace_exit
	common/subdaemon.c:25
0x55a8169eedbb crashdump
	common/daemon.c:57
0x7f0eaff8446f ???
	???:0
0x7f0eaff843eb ???
	???:0
0x7f0eaff63898 ???
	???:0
0x55a8169fb29f route_step_decode
	common/sphinx.c:759
0x55a8169fb60a process_onionpacket
	common/sphinx.c:834
0x55a8169d9b34 get_shared_secret
	channeld/channeld.c:605
0x55a8169d9d35 handle_peer_add_htlc
	channeld/channeld.c:649
0x55a8169dd88d peer_in
	channeld/channeld.c:1838
0x55a8169e11a8 main
	channeld/channeld.c:3233
0x7f0eaff651e2 ???

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2019-12-04 16:24:17 +10:30
committed by Christian Decker
parent f8d8348c9f
commit bb538a1862
3 changed files with 10 additions and 20 deletions

View File

@@ -962,7 +962,8 @@ static bool peer_accepted_htlc(struct channel *channel, u64 id,
/* FIXME: Have channeld hand through just the route_step! */
/* channeld tests this, so it should pass. */
/* channeld calls both parse_onionpacket and process_onionpacket,
* so they should succeed.. */
op = parse_onionpacket(tmpctx, hin->onion_routing_packet,
sizeof(hin->onion_routing_packet),
failcode);
@@ -974,7 +975,6 @@ static bool peer_accepted_htlc(struct channel *channel, u64 id,
return false;
}
/* If it's crap, not channeld's fault, just fail it */
rs = process_onionpacket(tmpctx, op, hin->shared_secret->data,
hin->payment_hash.u.u8,
sizeof(hin->payment_hash));
@@ -986,12 +986,6 @@ static bool peer_accepted_htlc(struct channel *channel, u64 id,
return false;
}
/* Unknown realm isn't a bad onion, it's a normal failure. */
if (rs->type == SPHINX_INVALID_PAYLOAD) {
*failcode = WIRE_INVALID_REALM;
goto out;
}
hook_payload = tal(hin, struct htlc_accepted_hook_payload);
hook_payload->route_step = tal_steal(hook_payload, rs);