File tree 1 file changed +8
-2
lines changed
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(
431
431
) -> Result < msgs:: TrampolineOnionPacket , ( ) > {
432
432
let minimum_packet_length = payloads. iter ( ) . map ( |p| p. serialized_length ( ) + 32 ) . sum ( ) ;
433
433
434
- assert ! (
434
+ debug_assert ! (
435
435
minimum_packet_length < ONION_DATA_LEN ,
436
436
"Trampoline onion packet must be smaller than outer onion"
437
437
) ;
438
+ if minimum_packet_length >= ONION_DATA_LEN {
439
+ return Err ( ( ) ) ;
440
+ }
438
441
439
442
let packet_length = usize:: from ( length. unwrap_or ( minimum_packet_length as u16 ) ) ;
440
- assert ! (
443
+ debug_assert ! (
441
444
packet_length >= minimum_packet_length,
442
445
"Packet length cannot be smaller than the payloads require."
443
446
) ;
447
+ if packet_length < minimum_packet_length {
448
+ return Err ( ( ) ) ;
449
+ }
444
450
445
451
let mut packet_data = vec ! [ 0u8 ; packet_length] ;
446
452
let mut chacha = ChaCha20 :: new ( & prng_seed, & [ 0 ; 8 ] ) ;
You can’t perform that action at this time.
0 commit comments