1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-22 17:39:53 +03:00

Merge PR #1407: Cedar/Connection.c: Fix buffer overflow when inserting NAT-T information

This commit is contained in:
Davide Beatrici 2021-07-04 08:45:27 +02:00 committed by GitHub
commit 4eae5820f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);