1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-23 01:49:53 +03:00

Cedar/Connection.c: Fix buffer overflow when inserting NAT-T information

This commit is contained in:
domosekai 2021-07-04 05:53:24 +00:00
parent dc296f1eff
commit f6adcd6bfc

View File

@ -909,20 +909,24 @@ void SendKeepAlive(CONNECTION *c, TCPSOCK *ts)
if (s->UseUdpAcceleration && udp_accel != NULL) if (s->UseUdpAcceleration && udp_accel != NULL)
{ {
UINT required_size = 0;
if (udp_accel->MyPortNatT != 0) if (udp_accel->MyPortNatT != 0)
{ {
size = MAX(size, (StrLen(UDP_NAT_T_PORT_SIGNATURE_IN_KEEP_ALIVE) + sizeof(USHORT))); required_size += StrLen(UDP_NAT_T_PORT_SIGNATURE_IN_KEEP_ALIVE) + sizeof(USHORT);
insert_natt_port = true; insert_natt_port = true;
} }
if (IsZeroIP(&udp_accel->MyIpNatT) == false) if (IsZeroIP(&udp_accel->MyIpNatT) == false)
{ {
size = MAX(size, (StrLen(UDP_NAT_T_IP_SIGNATURE_IN_KEEP_ALIVE) + sizeof(udp_accel->MyIpNatT.address))); required_size += StrLen(UDP_NAT_T_IP_SIGNATURE_IN_KEEP_ALIVE) + sizeof(udp_accel->MyIpNatT.address);
insert_natt_ip = true; insert_natt_ip = true;
} }
size = MAX(size, required_size);
} }
buf = MallocFast(size); buf = MallocFast(size);