@@ -364,7 +364,7 @@ impl<Config: endpoint::Config> ConnectionImpl<Config> {
364364 // use `from` instead of `into` so the location is correctly captured
365365 Poll :: Ready ( Err ( err) ) => return Err ( connection:: Error :: from ( err) ) ,
366366 Poll :: Pending => {
367- // Process stored handshake packets if the handshake space was created during the last poll crypto call
367+ // Process stored handshake packets if the handshake space was recently created
368368 if self . space_manager . handshake ( ) . is_some ( )
369369 && self . stored_packet_type == Some ( PacketNumberSpace :: Handshake )
370370 {
@@ -1620,8 +1620,12 @@ impl<Config: endpoint::Config> connection::Trait for ConnectionImpl<Config> {
16201620 //# The client MAY drop these packets, or it MAY buffer them in anticipation
16211621 //# of later packets that allow it to compute the key.
16221622
1623- self . packet_storage = packet. get_wire_bytes ( ) ;
1624- self . stored_packet_type = Some ( PacketNumberSpace :: Handshake )
1623+ let packet_bytes = packet. get_wire_bytes ( ) ;
1624+ if packet_bytes. len ( ) + self . packet_storage . len ( ) < self . limits . stored_packet_size ( )
1625+ {
1626+ self . packet_storage . extend ( packet_bytes) ;
1627+ self . stored_packet_type = Some ( PacketNumberSpace :: Handshake )
1628+ }
16251629 } else {
16261630 let path = & self . path_manager [ path_id] ;
16271631 publisher. on_packet_dropped ( event:: builder:: PacketDropped {
@@ -1666,7 +1670,6 @@ impl<Config: endpoint::Config> connection::Trait for ConnectionImpl<Config> {
16661670 //# complete.
16671671
16681672 if !self . space_manager . is_handshake_complete ( ) {
1669- // We only store one packet of application data for now.
16701673 if self . stored_packet_type . is_none ( ) {
16711674 //= https://www.rfc-editor.org/rfc/rfc9001#section-4.1.4
16721675 //# However, a TLS implementation could perform some of its processing
@@ -1684,8 +1687,14 @@ impl<Config: endpoint::Config> connection::Trait for ConnectionImpl<Config> {
16841687 //# The client MAY drop these packets, or it MAY buffer them in anticipation
16851688 //# of later packets that allow it to compute the key.
16861689
1687- self . packet_storage = packet. get_wire_bytes ( ) ;
1688- self . stored_packet_type = Some ( PacketNumberSpace :: ApplicationData ) ;
1690+ let packet_bytes = packet. get_wire_bytes ( ) ;
1691+ if packet_bytes. len ( ) < self . limits . stored_packet_size ( ) {
1692+ // We only store one packet of application data for now. This is due to the fact that
1693+ // short packets do not contain a length prefix, therefore, we would have to store additional
1694+ // length info per packet to properly parse them once the application space is created.
1695+ self . packet_storage = packet_bytes;
1696+ self . stored_packet_type = Some ( PacketNumberSpace :: ApplicationData )
1697+ }
16891698 } else {
16901699 let path = & self . path_manager [ path_id] ;
16911700 publisher. on_packet_dropped ( event:: builder:: PacketDropped {
0 commit comments