Skip to content

Commit 99de510

Browse files
author
Pavel Kovalenko
committed
Fix potential buffer overflow in xrGameSpyServer::OnMessage.
1 parent 9bef2c2 commit 99de510

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/xrGame/xrGameSpyServer.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,18 @@ u32 xrGameSpyServer::OnMessage(NET_Packet& P, ClientID sender) // Non-Zero
167167
{
168168
case M_GAMESPY_CDKEY_VALIDATION_CHALLENGE_RESPOND:
169169
{
170-
string128 ResponseStr;
171-
P.r_stringZ(ResponseStr);
172-
170+
string128 ResponseStr = "";
171+
u32 bytesRemain = P.r_elapsed();
172+
if (bytesRemain == 0 || bytesRemain > sizeof(ResponseStr))
173+
{
174+
xr_string clientIp = CL->m_cAddress.to_string();
175+
Msg("! WARNING: Validation challenge respond from client [%s] is %s. DoS attack?",
176+
clientIp.c_str(), bytesRemain == 0 ? "empty" : "too long");
177+
DisconnectClient(CL, "");
178+
// XXX nitrocaster: block IP address after X such attempts
179+
return 0;
180+
}
181+
P.r_stringZ(ResponseStr);
173182
if (!CL->m_bCDKeyAuth)
174183
{
175184
#ifndef MASTER_GOLD

0 commit comments

Comments
 (0)