Skip to content

Commit 55e8634

Browse files
rustyrussellcdecker
authored andcommitted
channeld: don't fail channel on unknown code in update_fail_malformed_htlc.
We will probably not add another BADONION code, but this is safer. Suggested-by: @cdecker Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 7e8dbc1 commit 55e8634

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

channeld/channeld.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,16 +1605,23 @@ static void handle_peer_fail_malformed_htlc(struct peer *peer, const u8 *msg)
16051605
* `update_fail_malformed_htlc`:
16061606
* - MUST fail the channel.
16071607
*/
1608-
/* We only handle these cases. */
1609-
if (failure_code != WIRE_INVALID_ONION_VERSION
1610-
&& failure_code != WIRE_INVALID_ONION_HMAC
1611-
&& failure_code != WIRE_INVALID_ONION_KEY) {
1608+
if (!(failure_code & BADONION)) {
16121609
peer_failed(&peer->cs,
16131610
&peer->channel_id,
16141611
"Bad update_fail_malformed_htlc failure code %u",
16151612
failure_code);
16161613
}
1617-
assert(failure_code & BADONION);
1614+
1615+
/* We only handle these cases in make_failmsg, so convert any
1616+
* (future?) unknown one. */
1617+
if (failure_code != WIRE_INVALID_ONION_VERSION
1618+
&& failure_code != WIRE_INVALID_ONION_HMAC
1619+
&& failure_code != WIRE_INVALID_ONION_KEY) {
1620+
status_unusual("Unknown update_fail_malformed_htlc code %u:"
1621+
" sending temporary_channel_failure",
1622+
failure_code);
1623+
failure_code = WIRE_TEMPORARY_CHANNEL_FAILURE;
1624+
}
16181625

16191626
e = channel_fail_htlc(peer->channel, LOCAL, id, &htlc);
16201627
switch (e) {

0 commit comments

Comments
 (0)