File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -818,4 +818,25 @@ mod tests {
818818 TcpError :: MssRemaining
819819 ) ;
820820 }
821+
822+ #[ test]
823+ fn test_invalid_tcp_option_len ( ) {
824+ // Build a minimal segment with header_len = 24 (OPTIONS_OFFSET + 4 bytes of options).
825+ let mut buf = [ 0u8 ; 100 ] ;
826+ let header_len: u8 = OPTIONS_OFFSET + 4 ;
827+ {
828+ let mut seg = TcpSegment :: from_bytes_unchecked ( buf. as_mut ( ) ) ;
829+ seg. set_header_len_rsvd_ns ( header_len, false ) ;
830+ }
831+ // Write an unknown option kind (0xFF) with opt_len = 0 (invalid, < 2).
832+ let opts_start = usize:: from ( OPTIONS_OFFSET ) ;
833+ buf[ opts_start] = 0xFF ;
834+ buf[ opts_start + 1 ] = 0 ;
835+
836+ let seg = TcpSegment :: from_bytes_unchecked ( buf. as_ref ( ) ) ;
837+ assert_eq ! (
838+ seg. parse_mss_option_unchecked( header_len. into( ) ) ,
839+ Err ( TcpError :: MssOption )
840+ ) ;
841+ }
821842}
You can’t perform that action at this time.
0 commit comments