@@ -364,7 +364,7 @@ impl<Config: endpoint::Config> ConnectionImpl<Config> {
364
364
// use `from` instead of `into` so the location is correctly captured
365
365
Poll :: Ready ( Err ( err) ) => return Err ( connection:: Error :: from ( err) ) ,
366
366
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
368
368
if self . space_manager . handshake ( ) . is_some ( )
369
369
&& self . stored_packet_type == Some ( PacketNumberSpace :: Handshake )
370
370
{
@@ -1620,8 +1620,12 @@ impl<Config: endpoint::Config> connection::Trait for ConnectionImpl<Config> {
1620
1620
//# The client MAY drop these packets, or it MAY buffer them in anticipation
1621
1621
//# of later packets that allow it to compute the key.
1622
1622
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
+ }
1625
1629
} else {
1626
1630
let path = & self . path_manager [ path_id] ;
1627
1631
publisher. on_packet_dropped ( event:: builder:: PacketDropped {
@@ -1666,7 +1670,6 @@ impl<Config: endpoint::Config> connection::Trait for ConnectionImpl<Config> {
1666
1670
//# complete.
1667
1671
1668
1672
if !self . space_manager . is_handshake_complete ( ) {
1669
- // We only store one packet of application data for now.
1670
1673
if self . stored_packet_type . is_none ( ) {
1671
1674
//= https://www.rfc-editor.org/rfc/rfc9001#section-4.1.4
1672
1675
//# However, a TLS implementation could perform some of its processing
@@ -1684,8 +1687,14 @@ impl<Config: endpoint::Config> connection::Trait for ConnectionImpl<Config> {
1684
1687
//# The client MAY drop these packets, or it MAY buffer them in anticipation
1685
1688
//# of later packets that allow it to compute the key.
1686
1689
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
+ }
1689
1698
} else {
1690
1699
let path = & self . path_manager [ path_id] ;
1691
1700
publisher. on_packet_dropped ( event:: builder:: PacketDropped {
0 commit comments