File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -431,16 +431,22 @@ pub(super) fn construct_trampoline_onion_packet(
431431) -> Result < msgs:: TrampolineOnionPacket , ( ) > {
432432 let minimum_packet_length = payloads. iter ( ) . map ( |p| p. serialized_length ( ) + 32 ) . sum ( ) ;
433433
434- assert ! (
434+ debug_assert ! (
435435 minimum_packet_length < ONION_DATA_LEN ,
436436 "Trampoline onion packet must be smaller than outer onion"
437437 ) ;
438+ if minimum_packet_length >= ONION_DATA_LEN {
439+ return Err ( ( ) ) ;
440+ }
438441
439442 let packet_length = usize:: from ( length. unwrap_or ( minimum_packet_length as u16 ) ) ;
440- assert ! (
443+ debug_assert ! (
441444 packet_length >= minimum_packet_length,
442445 "Packet length cannot be smaller than the payloads require."
443446 ) ;
447+ if packet_length < minimum_packet_length {
448+ return Err ( ( ) ) ;
449+ }
444450
445451 let mut packet_data = vec ! [ 0u8 ; packet_length] ;
446452 let mut chacha = ChaCha20 :: new ( & prng_seed, & [ 0 ; 8 ] ) ;
You can’t perform that action at this time.
0 commit comments