Skip to content

Commit ea0fed4

Browse files
committed
f Don't assert but return error
1 parent 9a4c0da commit ea0fed4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lightning/src/ln/onion_utils.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,9 @@ fn construct_onion_packet_with_init_noise<HD: Writeable, P: Packet>(
285285
let mut payload_len = LengthCalculatingWriter(0);
286286
payload.write(&mut payload_len).expect("Failed to calculate length");
287287
pos += payload_len.0 + 32;
288-
assert!(pos <= packet_data.len());
288+
if pos > packet_data.len() {
289+
return Err(());
290+
}
289291

290292
res.resize(pos, 0u8);
291293
chacha.process_in_place(&mut res);

0 commit comments

Comments
 (0)