lightningd: handle bad failure message.

We used to core dump if unwrap_onionreply() returned NULL!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-05-19 20:33:39 +09:30 committed by Christian Decker
parent 55510ea27a
commit f4d92813a0

View File

@ -1187,10 +1187,15 @@ static int peer_failed_htlc(struct peer *peer, const u8 *msg)
shared_secrets[i] = hend->path_secrets[i];
}
reply = unwrap_onionreply(msg, shared_secrets, numhops, reason);
failcode = fromwire_peektype(reply->msg);
log_info(peer->log, "htlc %"PRIu64" failed with code 0x%04x (%s)",
id, failcode, onion_type_name(failcode));
if (!reply) {
log_info(peer->log, "htlc %"PRIu64" failed with bad reply (%s)",
id, tal_hex(msg, msg));
failcode = WIRE_PERMANENT_NODE_FAILURE;
} else {
failcode = fromwire_peektype(reply->msg);
log_info(peer->log, "htlc %"PRIu64" failed with code 0x%04x (%s)",
id, failcode, onion_type_name(failcode));
}
payment_failed(peer->ld, hend, NULL, failcode);
}
tal_free(hend);