From 81b7b03d4ff7424e61b073b81cf4edf627c8694b Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Fri, 5 Aug 2022 13:15:57 -0400 Subject: [PATCH] Fix fuzzer-found underflow --- lightning/src/onion_message/packet.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lightning/src/onion_message/packet.rs b/lightning/src/onion_message/packet.rs index a3414d844..d4ba28c84 100644 --- a/lightning/src/onion_message/packet.rs +++ b/lightning/src/onion_message/packet.rs @@ -69,7 +69,7 @@ impl LengthReadable for Packet { let public_key = Readable::read(r)?; let mut hop_data = Vec::new(); - let hop_data_len = r.total_bytes() as usize - 66; // 1 (version) + 33 (pubkey) + 32 (HMAC) = 66 + let hop_data_len = r.total_bytes().saturating_sub(66) as usize; // 1 (version) + 33 (pubkey) + 32 (HMAC) = 66 let mut read_idx = 0; while read_idx < hop_data_len { let mut read_buffer = [0; READ_BUFFER_SIZE]; -- 2.39.5