106 if (tcphlen <= (
int)
sizeof(
struct TCPHeader) || tcphlen > ip_payload_len)
112 for (olen = tcphlen -
sizeof(
struct TCPHeader), opt = (uint8_t *)(tcphdr + 1);
114 olen -= optlen, opt += optlen)
123 if (optlen <= 0 || optlen > olen)
127 auto mssRaw = (opt[2] << 8) + opt[3];
128 if (is_safe_conversion<uint16_t>(mssRaw))
130 uint16_t mssval =
static_cast<uint16_t
>(mssRaw);
131 if (mssval > max_mss)
134 int accumulate = htons(mssval);
135 opt[2] =
static_cast<uint8_t
>((max_mss >> 8) & 0xff);
136 opt[3] =
static_cast<uint8_t
>(max_mss & 0xff);
137 accumulate -= htons(max_mss);
143 OPENVPN_LOG_MSSFIX(
"Rejecting MSS fix: value out of bounds for type " << ((opt[2] << 8) + opt[3]));