diff --git a/rehlds/engine/host.cpp b/rehlds/engine/host.cpp index a99ea29..8114beb 100644 --- a/rehlds/engine/host.cpp +++ b/rehlds/engine/host.cpp @@ -503,6 +503,12 @@ void SV_DropClient(client_t *cl, qboolean crash, const char *fmt, ...) g_psvs.stats.cumulative_sessiontime = g_psvs.stats.cumulative_sessiontime + connection_time; } +#ifdef REHLDS_FIXES + // prevent message reading after disconnect + if (cl == host_client) + msg_readcount = net_message.cursize; +#endif // REHLDS_FIXES + Netchan_Clear(&cl->netchan); Steam_NotifyClientDisconnect(cl); diff --git a/rehlds/engine/info.cpp b/rehlds/engine/info.cpp index 8e06f29..dfec4f9 100644 --- a/rehlds/engine/info.cpp +++ b/rehlds/engine/info.cpp @@ -272,10 +272,13 @@ qboolean Info_IsKeyImportant(const char *key) return true; if (!Q_strcmp(key, "cl_lc")) return true; +#ifndef REHLDS_FIXES + // keys starts from '*' already checked if (!Q_strcmp(key, "*hltv")) return true; if (!Q_strcmp(key, "*sid")) return true; +#endif return false; } diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index 4beead4..444bdf6 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -2198,7 +2198,11 @@ void SV_ConnectClient_internal(void) client_t *client; netadr_t adr; int nClientSlot; +#ifdef REHLDS_FIXES + char userinfo[MAX_INFO_STRING]; +#else char userinfo[1024]; +#endif char protinfo[1024]; char cdkey[64]; const char *s; @@ -2246,7 +2250,12 @@ void SV_ConnectClient_internal(void) } s = Cmd_Argv(4); +#ifdef REHLDS_FIXES + // truncate to 255 before sanity checks + if (Q_strlen(s) > MAX_INFO_STRING - 1 || !Info_IsValid(s)) +#else if (Q_strlen(s) > 256 || !Info_IsValid(s)) +#endif { SV_RejectConnection(&adr, "Invalid userinfo in connect command\n"); return; @@ -4442,7 +4451,14 @@ qboolean SV_SendClientDatagram(client_t *client) } else { +#ifdef REHLDS_FIXES + if (msg.cursize + client->datagram.cursize > msg.maxsize) + Con_DPrintf("Warning: Ignoring unreliable datagram for %s, would overflow on msg\n", client->name); + else + SZ_Write(&msg, client->datagram.data, client->datagram.cursize); +#else SZ_Write(&msg, client->datagram.data, client->datagram.cursize); +#endif } SZ_Clear(&client->datagram);