@@ -130,11 +130,6 @@ mss_fixup_ipv6(struct buffer *buf, uint16_t maxmss)
130130 }
131131}
132132
133- #if defined(__GNUC__ ) || defined(__clang__ )
134- #pragma GCC diagnostic push
135- #pragma GCC diagnostic ignored "-Wconversion"
136- #endif
137-
138133/*
139134 * change TCP MSS option in SYN/SYN-ACK packets, if present
140135 * this is generic for IPv4 and IPv6, as the TCP header is the same
@@ -143,20 +138,17 @@ mss_fixup_ipv6(struct buffer *buf, uint16_t maxmss)
143138void
144139mss_fixup_dowork (struct buffer * buf , uint16_t maxmss )
145140{
146- int hlen , olen , optlen ;
141+ int olen , optlen ;
147142 uint8_t * opt ;
148- uint16_t mssval ;
149- int accumulate ;
150- struct openvpn_tcphdr * tc ;
151143
152144 if (BLEN (buf ) < (int )sizeof (struct openvpn_tcphdr ))
153145 {
154146 return ;
155147 }
156148
157149 verify_align_4 (buf );
158- tc = (struct openvpn_tcphdr * )BPTR (buf );
159- hlen = OPENVPN_TCPH_GET_DOFF (tc -> doff_res );
150+ struct openvpn_tcphdr * tc = (struct openvpn_tcphdr * )BPTR (buf );
151+ int hlen = OPENVPN_TCPH_GET_DOFF (tc -> doff_res );
160152
161153 /* Invalid header length or header without options. */
162154 if (hlen <= (int )sizeof (struct openvpn_tcphdr ) || hlen > BLEN (buf ))
@@ -171,43 +163,37 @@ mss_fixup_dowork(struct buffer *buf, uint16_t maxmss)
171163 {
172164 break ;
173165 }
174- else if (* opt == OPENVPN_TCPOPT_NOP )
166+ if (* opt == OPENVPN_TCPOPT_NOP )
175167 {
176168 optlen = 1 ;
169+ continue ;
170+ }
171+
172+ optlen = * (opt + 1 );
173+ if (optlen <= 0 || optlen > olen )
174+ {
175+ break ;
177176 }
178- else
177+ if ( * opt == OPENVPN_TCPOPT_MAXSEG )
179178 {
180- optlen = * (opt + 1 );
181- if (optlen <= 0 || optlen > olen )
179+ if (optlen != OPENVPN_TCPOLEN_MAXSEG )
182180 {
183- break ;
181+ continue ;
184182 }
185- if (* opt == OPENVPN_TCPOPT_MAXSEG )
183+ uint16_t mssval = (uint16_t )(opt [2 ] << 8 ) + opt [3 ];
184+ if (mssval > maxmss )
186185 {
187- if (optlen != OPENVPN_TCPOLEN_MAXSEG )
188- {
189- continue ;
190- }
191- mssval = opt [2 ] << 8 ;
192- mssval += opt [3 ];
193- if (mssval > maxmss )
194- {
195- dmsg (D_MSS , "MSS: %" PRIu16 " -> %" PRIu16 , mssval , maxmss );
196- accumulate = htons (mssval );
197- opt [2 ] = (uint8_t )((maxmss >> 8 ) & 0xff );
198- opt [3 ] = (uint8_t )(maxmss & 0xff );
199- accumulate -= htons (maxmss );
200- ADJUST_CHECKSUM (accumulate , tc -> check );
201- }
186+ dmsg (D_MSS , "MSS: %" PRIu16 " -> %" PRIu16 , mssval , maxmss );
187+ opt [2 ] = (uint8_t )((maxmss >> 8 ) & 0xff );
188+ opt [3 ] = (uint8_t )(maxmss & 0xff );
189+ int32_t accumulate = htons (mssval );
190+ accumulate -= htons (maxmss );
191+ ADJUST_CHECKSUM (accumulate , tc -> check );
202192 }
203193 }
204194 }
205195}
206196
207- #if defined(__GNUC__ ) || defined(__clang__ )
208- #pragma GCC diagnostic pop
209- #endif
210-
211197static inline size_t
212198adjust_payload_max_cbc (const struct key_type * kt , size_t target )
213199{
0 commit comments