From ef2fed21e71e5a4848b353a55f5739a75d812e2c Mon Sep 17 00:00:00 2001 From: Adrian Cirstea <54354938+ShadowsAdi@users.noreply.github.com> Date: Sun, 3 Mar 2024 03:32:44 +0200 Subject: [PATCH 01/14] Implement `SV_AddResources` hook --- rehlds/engine/server.h | 1 + rehlds/engine/sv_main.cpp | 5 +++++ rehlds/public/rehlds/rehlds_api.h | 5 +++++ rehlds/rehlds/rehlds_api_impl.h | 6 ++++++ 4 files changed, 17 insertions(+) diff --git a/rehlds/engine/server.h b/rehlds/engine/server.h index c59332e1..034eba87 100644 --- a/rehlds/engine/server.h +++ b/rehlds/engine/server.h @@ -468,6 +468,7 @@ void SV_QueryMovevarsChanged(void); void SV_SendServerinfo(sizebuf_t *msg, client_t *client); void SV_SendServerinfo_internal(sizebuf_t *msg, client_t *client); void SV_SendResources(sizebuf_t *msg); +void SV_SendResources_internal(sizebuf_t *msg); void SV_WriteClientdataToMessage(client_t *client, sizebuf_t *msg); void SV_WriteSpawn(sizebuf_t *msg); void SV_SendUserReg(sizebuf_t *msg); diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index 870a5fab..a28c5523 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -1199,6 +1199,11 @@ void SV_SendServerinfo_internal(sizebuf_t *msg, client_t *client) } void SV_SendResources(sizebuf_t *msg) +{ + g_RehldsHookchains.m_SV_SendResources.callChain(SV_SendResources_internal, msg); +} + +void SV_SendResources_internal(sizebuf_t *msg) { unsigned char nullbuffer[32]; Q_memset(nullbuffer, 0, sizeof(nullbuffer)); diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index bc835819..3f8eb909 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -259,6 +259,10 @@ typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_ClientPrintf typedef IHookChain IRehldsHook_SV_AllowPhysent; typedef IHookChainRegistry IRehldsHookRegistry_SV_AllowPhysent; +//SV_SendResources hook +typedef IVoidHookChain IRehldsHook_SV_SendResources; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_SendResources; + class IRehldsHookchains { public: virtual ~IRehldsHookchains() { } @@ -318,6 +322,7 @@ class IRehldsHookchains { virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource() = 0; virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf() = 0; virtual IRehldsHookRegistry_SV_AllowPhysent* SV_AllowPhysent() = 0; + virtual IRehldsHookRegistry_SV_SendResources* SV_SendResources() = 0; }; struct RehldsFuncs_t { diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 699bd164..6aece98c 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -254,6 +254,10 @@ typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_ClientPri typedef IHookChainImpl CRehldsHook_SV_AllowPhysent; typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_AllowPhysent; +//SV_SendResources hook +typedef IVoidHookChainImpl CRehldsHook_SV_SendResources; +typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_SendResources; + class CRehldsHookchains : public IRehldsHookchains { public: CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; @@ -311,6 +315,7 @@ class CRehldsHookchains : public IRehldsHookchains { CRehldsHookRegistry_SV_AddResource m_SV_AddResource; CRehldsHookRegistry_SV_ClientPrintf m_SV_ClientPrintf; CRehldsHookRegistry_SV_AllowPhysent m_SV_AllowPhysent; + CRehldsHookRegistry_SV_SendResources m_SV_SendResources; public: EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); @@ -368,6 +373,7 @@ class CRehldsHookchains : public IRehldsHookchains { EXT_FUNC virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource(); EXT_FUNC virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf(); EXT_FUNC virtual IRehldsHookRegistry_SV_AllowPhysent* SV_AllowPhysent(); + EXT_FUNC virtual IRehldsHookRegistry_SV_SendResources* SV_SendResources(); }; extern CRehldsHookchains g_RehldsHookchains; From 6cfb2d489b9adcc68d62eaf2ea9c72c23498ef24 Mon Sep 17 00:00:00 2001 From: Adrian Cirstea <54354938+ShadowsAdi@users.noreply.github.com> Date: Sun, 3 Mar 2024 03:38:07 +0200 Subject: [PATCH 02/14] Update rehlds_api_impl.cpp --- rehlds/rehlds/rehlds_api_impl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 8d7f9dad..2b4ede0b 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -885,6 +885,10 @@ IRehldsHookRegistry_SV_AllowPhysent* CRehldsHookchains::SV_AllowPhysent() { return &m_SV_AllowPhysent; } +IRehldsHookRegistry_SV_SendResources* CRehldsHookchains::SV_SendResources() { + return &m_SV_SendResources; +} + int EXT_FUNC CRehldsApi::GetMajorVersion() { return REHLDS_API_VERSION_MAJOR; From 40154d9233433393c8e4b1494dde1643f7c2f0ad Mon Sep 17 00:00:00 2001 From: Adrian Cirstea <54354938+ShadowsAdi@users.noreply.github.com> Date: Sun, 3 Mar 2024 03:46:45 +0200 Subject: [PATCH 03/14] Update sv_main.cpp --- rehlds/engine/sv_main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index a28c5523..36a4b70e 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -1215,6 +1215,7 @@ void SV_SendResources_internal(sizebuf_t *msg) if (sv_downloadurl.string && sv_downloadurl.string[0] != 0 && Q_strlen(sv_downloadurl.string) < 129) { MSG_WriteByte(msg, svc_resourcelocation); + Con_Printf("Testing: %s\n", sv_downloadurl.string); MSG_WriteString(msg, sv_downloadurl.string); } From 8a66db04f076afa242610b08d8e376c13ed69b0e Mon Sep 17 00:00:00 2001 From: Adrian Cirstea <54354938+ShadowsAdi@users.noreply.github.com> Date: Tue, 5 Mar 2024 22:00:39 +0200 Subject: [PATCH 04/14] test --- rehlds/engine/cmd.cpp | 32 ++++++++++++++++++++++++++++++++ rehlds/engine/cmd.h | 1 + rehlds/engine/sv_steam3.cpp | 11 +++++++++++ rehlds/engine/sv_steam3.h | 4 +++- 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/rehlds/engine/cmd.cpp b/rehlds/engine/cmd.cpp index a49df84a..22be88bf 100644 --- a/rehlds/engine/cmd.cpp +++ b/rehlds/engine/cmd.cpp @@ -1202,3 +1202,35 @@ void Cmd_CmdList_f(void) Con_Printf("cmdlist logged to %s\n", szTemp); } } + +void UnsafeCmdLineProcessor(const char *pchUnsafeCmdLine, int cubSize) +{ + int count = 9; + // mov edx, 6E6F632Bh + // mov ecx, 7463656Eh + const char* szPrefix = "nocmd tece "; + netadr_t *address; + char *szSanitizedConnect; + //void *s1 = nullptr; + Con_Printf("test: %s", pchUnsafeCmdLine); + + if(!Q_strcmp(pchUnsafeCmdLine, szPrefix, sizeof(szPrefix) - 1)) + { + if (cubSize > count && pchUnsafeCmdLine[9] != ' ') + { + //s1 = &pchUnsafeCmdLine[9]; + + netadr_t address; + if (NET_StringToAdr(address_str, &address)) + { + Q_snprintf(szSanitizedConnect, sizeof(szSanitizedConnect), "\nconnect %s\n", NET_AdrToString(address)); + Cbuf_AddText(szSanitizedConnect); + Cbuf_AddText("\ncl_skipvid 1\n"); + } + else + { + Con_Printf("Invalid address to connect to from unsafe command line.\n"); + } + } + } +} \ No newline at end of file diff --git a/rehlds/engine/cmd.h b/rehlds/engine/cmd.h index 2682e009..d66bcf97 100644 --- a/rehlds/engine/cmd.h +++ b/rehlds/engine/cmd.h @@ -110,3 +110,4 @@ void Cmd_ForwardToServer(void); qboolean Cmd_ForwardToServerUnreliable(void); NOXREF int Cmd_CheckParm(const char *parm); void Cmd_CmdList_f(void); +void UnsafeCmdLineProcessor(const char *pchUnsafeCmdLine, int cubSize); \ No newline at end of file diff --git a/rehlds/engine/sv_steam3.cpp b/rehlds/engine/sv_steam3.cpp index c35b2934..05eef281 100644 --- a/rehlds/engine/sv_steam3.cpp +++ b/rehlds/engine/sv_steam3.cpp @@ -628,6 +628,17 @@ void CSteam3Client::OnGameOverlayActivated(GameOverlayActivated_t *pGameOverlayA #endif } +void CSteam3Client::OnGameRichPresenceJoinRequested(GameRichPresenceJoinRequested_t *pCallback) +{ + Con_Printf("OnGameRichPresenceJoinRequested\n"); + + if(CSteam3Server::ClientFindFromSteamID(pCallback->m_steamIDFriend)) + { + UnsafeCmdLineProcessor(pCallback->m_rgchConnect, k_cchMaxRichPresenceValueLength); + } + +} + void CSteam3Client::RunFrame() { CRehldsPlatformHolder::get()->SteamAPI_RunCallbacks(); diff --git a/rehlds/engine/sv_steam3.h b/rehlds/engine/sv_steam3.h index 3238dc87..70652dfe 100644 --- a/rehlds/engine/sv_steam3.h +++ b/rehlds/engine/sv_steam3.h @@ -111,11 +111,13 @@ class CSteam3Client: public CSteam3 STEAM_CALLBACK(CSteam3Client, OnClientGameServerDeny, ClientGameServerDeny_t, m_CallbackClientGameServerDeny); STEAM_CALLBACK(CSteam3Client, OnGameServerChangeRequested, GameServerChangeRequested_t, m_CallbackGameServerChangeRequested); STEAM_CALLBACK(CSteam3Client, OnGameOverlayActivated, GameOverlayActivated_t, m_CallbackGameOverlayActivated); + STEAM_CALLBACK(CSteam3Client, OnGameRichPresenceJoinRequested, GameRichPresenceJoinRequested_t, m_CallbackGameRichPresenceJoinRequested); CSteam3Client() : m_CallbackClientGameServerDeny(this, &CSteam3Client::OnClientGameServerDeny), m_CallbackGameServerChangeRequested(this, &CSteam3Client::OnGameServerChangeRequested), - m_CallbackGameOverlayActivated(this, &CSteam3Client::OnGameOverlayActivated) + m_CallbackGameOverlayActivated(this, &CSteam3Client::OnGameOverlayActivated))), + m_CallbackGameRichPresenceJoinRequested(this, &CSteam3Client::OnGameRichPresenceJoinRequested))) {} virtual void Shutdown(); From 1f862b754e2901c6be8b9dafabd8f103eb16c340 Mon Sep 17 00:00:00 2001 From: Adrian Cirstea <54354938+ShadowsAdi@users.noreply.github.com> Date: Tue, 5 Mar 2024 22:03:13 +0200 Subject: [PATCH 05/14] Update sv_steam3.h --- rehlds/engine/sv_steam3.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rehlds/engine/sv_steam3.h b/rehlds/engine/sv_steam3.h index 70652dfe..e6c08557 100644 --- a/rehlds/engine/sv_steam3.h +++ b/rehlds/engine/sv_steam3.h @@ -116,8 +116,8 @@ class CSteam3Client: public CSteam3 CSteam3Client() : m_CallbackClientGameServerDeny(this, &CSteam3Client::OnClientGameServerDeny), m_CallbackGameServerChangeRequested(this, &CSteam3Client::OnGameServerChangeRequested), - m_CallbackGameOverlayActivated(this, &CSteam3Client::OnGameOverlayActivated))), - m_CallbackGameRichPresenceJoinRequested(this, &CSteam3Client::OnGameRichPresenceJoinRequested))) + m_CallbackGameOverlayActivated(this, &CSteam3Client::OnGameOverlayActivated), + m_CallbackGameRichPresenceJoinRequested(this, &CSteam3Client::OnGameRichPresenceJoinRequested) {} virtual void Shutdown(); From d7942934ab106d639d910c092bdb9d6a55903d5a Mon Sep 17 00:00:00 2001 From: Adrian Cirstea <54354938+ShadowsAdi@users.noreply.github.com> Date: Tue, 5 Mar 2024 22:06:17 +0200 Subject: [PATCH 06/14] Update sv_steam3.cpp --- rehlds/engine/sv_steam3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rehlds/engine/sv_steam3.cpp b/rehlds/engine/sv_steam3.cpp index 05eef281..b0c34b88 100644 --- a/rehlds/engine/sv_steam3.cpp +++ b/rehlds/engine/sv_steam3.cpp @@ -632,7 +632,7 @@ void CSteam3Client::OnGameRichPresenceJoinRequested(GameRichPresenceJoinRequeste { Con_Printf("OnGameRichPresenceJoinRequested\n"); - if(CSteam3Server::ClientFindFromSteamID(pCallback->m_steamIDFriend)) + if(ClientFindFromSteamID(pCallback->m_steamIDFriend)) { UnsafeCmdLineProcessor(pCallback->m_rgchConnect, k_cchMaxRichPresenceValueLength); } From e6c27f23923cd8395e6076b02a8761c2711a9020 Mon Sep 17 00:00:00 2001 From: Adrian Cirstea <54354938+ShadowsAdi@users.noreply.github.com> Date: Tue, 5 Mar 2024 22:18:44 +0200 Subject: [PATCH 07/14] Update sv_steam3.cpp --- rehlds/engine/sv_steam3.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/rehlds/engine/sv_steam3.cpp b/rehlds/engine/sv_steam3.cpp index b0c34b88..cb000218 100644 --- a/rehlds/engine/sv_steam3.cpp +++ b/rehlds/engine/sv_steam3.cpp @@ -628,15 +628,32 @@ void CSteam3Client::OnGameOverlayActivated(GameOverlayActivated_t *pGameOverlayA #endif } -void CSteam3Client::OnGameRichPresenceJoinRequested(GameRichPresenceJoinRequested_t *pCallback) +void CSteam3Client::OnGameRichPresenceJoinRequested(GameRichPresenceJoinRequested_t *pGameRichPresenceJoinRequested) { Con_Printf("OnGameRichPresenceJoinRequested\n"); - if(ClientFindFromSteamID(pCallback->m_steamIDFriend)) + client_t* cl = CSteam3Client::ClientFindFromSteamID(pGameRichPresenceJoinRequested->m_steamIDFriend) + + if(cl) + UnsafeCmdLineProcessor(pGameRichPresenceJoinRequested->m_rgchConnect, k_cchMaxRichPresenceValueLength); +} + +client_t *CSteam3Client::ClientFindFromSteamID(CSteamID &steamIDFind) +{ + for (int i = 0; i < g_psvs.maxclients; i++) { - UnsafeCmdLineProcessor(pCallback->m_rgchConnect, k_cchMaxRichPresenceValueLength); + auto cl = &g_psvs.clients[i]; + if (!cl->connected && !cl->active && !cl->spawned) + continue; + + if (cl->network_userid.idtype != AUTH_IDTYPE_STEAM) + continue; + + if (steamIDFind == cl->network_userid.m_SteamID) + return cl; } - + + return NULL; } void CSteam3Client::RunFrame() From d77a4091ea925c689bee3587a3bc375c2eee7a23 Mon Sep 17 00:00:00 2001 From: Adrian Cirstea <54354938+ShadowsAdi@users.noreply.github.com> Date: Tue, 5 Mar 2024 22:19:58 +0200 Subject: [PATCH 08/14] Update sv_steam3.cpp --- rehlds/engine/sv_steam3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rehlds/engine/sv_steam3.cpp b/rehlds/engine/sv_steam3.cpp index cb000218..f89f506a 100644 --- a/rehlds/engine/sv_steam3.cpp +++ b/rehlds/engine/sv_steam3.cpp @@ -632,7 +632,7 @@ void CSteam3Client::OnGameRichPresenceJoinRequested(GameRichPresenceJoinRequeste { Con_Printf("OnGameRichPresenceJoinRequested\n"); - client_t* cl = CSteam3Client::ClientFindFromSteamID(pGameRichPresenceJoinRequested->m_steamIDFriend) + client_t* cl = CSteam3Client::ClientFindFromSteamID(pGameRichPresenceJoinRequested->m_steamIDFriend); if(cl) UnsafeCmdLineProcessor(pGameRichPresenceJoinRequested->m_rgchConnect, k_cchMaxRichPresenceValueLength); From ac86b4c56985b2e80242452b6122c8304a313c67 Mon Sep 17 00:00:00 2001 From: Adrian Cirstea <54354938+ShadowsAdi@users.noreply.github.com> Date: Tue, 5 Mar 2024 22:21:48 +0200 Subject: [PATCH 09/14] Update sv_steam3.h --- rehlds/engine/sv_steam3.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rehlds/engine/sv_steam3.h b/rehlds/engine/sv_steam3.h index e6c08557..23255b11 100644 --- a/rehlds/engine/sv_steam3.h +++ b/rehlds/engine/sv_steam3.h @@ -119,7 +119,9 @@ class CSteam3Client: public CSteam3 m_CallbackGameOverlayActivated(this, &CSteam3Client::OnGameOverlayActivated), m_CallbackGameRichPresenceJoinRequested(this, &CSteam3Client::OnGameRichPresenceJoinRequested) {} - + + client_t *ClientFindFromSteamID(class CSteamID &steamIDFind); + virtual void Shutdown(); int InitiateGameConnection(void *pData, int cbMaxData, uint64 steamID, uint32 unIPServer, uint16 usPortServer, bool bSecure); From 67a6b9cb1d886aa2e3b8319026b321972d125141 Mon Sep 17 00:00:00 2001 From: Adrian Cirstea <54354938+ShadowsAdi@users.noreply.github.com> Date: Tue, 5 Mar 2024 22:23:26 +0200 Subject: [PATCH 10/14] Update cmd.cpp --- rehlds/engine/cmd.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/rehlds/engine/cmd.cpp b/rehlds/engine/cmd.cpp index 22be88bf..2ffbd047 100644 --- a/rehlds/engine/cmd.cpp +++ b/rehlds/engine/cmd.cpp @@ -1219,6 +1219,7 @@ void UnsafeCmdLineProcessor(const char *pchUnsafeCmdLine, int cubSize) if (cubSize > count && pchUnsafeCmdLine[9] != ' ') { //s1 = &pchUnsafeCmdLine[9]; + const char* address_str = &pchUnsafeCmdLine[9]; netadr_t address; if (NET_StringToAdr(address_str, &address)) From 93bc1b93cd3ec3b23c0567fdc16557f413eccca9 Mon Sep 17 00:00:00 2001 From: Adrian Cirstea <54354938+ShadowsAdi@users.noreply.github.com> Date: Tue, 5 Mar 2024 22:27:23 +0200 Subject: [PATCH 11/14] Update cmd.cpp --- rehlds/engine/cmd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rehlds/engine/cmd.cpp b/rehlds/engine/cmd.cpp index 2ffbd047..d1e35e14 100644 --- a/rehlds/engine/cmd.cpp +++ b/rehlds/engine/cmd.cpp @@ -1214,7 +1214,7 @@ void UnsafeCmdLineProcessor(const char *pchUnsafeCmdLine, int cubSize) //void *s1 = nullptr; Con_Printf("test: %s", pchUnsafeCmdLine); - if(!Q_strcmp(pchUnsafeCmdLine, szPrefix, sizeof(szPrefix) - 1)) + if(Q_strcmp(pchUnsafeCmdLine, szPrefix) == 0) { if (cubSize > count && pchUnsafeCmdLine[9] != ' ') { From 4f7e3f5db99a2ce28695da8180beb1721e5e0447 Mon Sep 17 00:00:00 2001 From: Adrian Cirstea <54354938+ShadowsAdi@users.noreply.github.com> Date: Tue, 5 Mar 2024 22:31:08 +0200 Subject: [PATCH 12/14] Update cmd.cpp --- rehlds/engine/cmd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rehlds/engine/cmd.cpp b/rehlds/engine/cmd.cpp index d1e35e14..7c562c40 100644 --- a/rehlds/engine/cmd.cpp +++ b/rehlds/engine/cmd.cpp @@ -1210,7 +1210,7 @@ void UnsafeCmdLineProcessor(const char *pchUnsafeCmdLine, int cubSize) // mov ecx, 7463656Eh const char* szPrefix = "nocmd tece "; netadr_t *address; - char *szSanitizedConnect; + const char *szSanitizedConnect; //void *s1 = nullptr; Con_Printf("test: %s", pchUnsafeCmdLine); From bc9e5aaf65ec0f7ff2ce2e2ce381a8f2dd0c0c16 Mon Sep 17 00:00:00 2001 From: Adrian Cirstea <54354938+ShadowsAdi@users.noreply.github.com> Date: Tue, 5 Mar 2024 22:34:35 +0200 Subject: [PATCH 13/14] Update cmd.cpp --- rehlds/engine/cmd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rehlds/engine/cmd.cpp b/rehlds/engine/cmd.cpp index 7c562c40..4f674fc4 100644 --- a/rehlds/engine/cmd.cpp +++ b/rehlds/engine/cmd.cpp @@ -1210,7 +1210,7 @@ void UnsafeCmdLineProcessor(const char *pchUnsafeCmdLine, int cubSize) // mov ecx, 7463656Eh const char* szPrefix = "nocmd tece "; netadr_t *address; - const char *szSanitizedConnect; + char szSanitizedConnect[128]; //void *s1 = nullptr; Con_Printf("test: %s", pchUnsafeCmdLine); From 3cabc97b4db5844d25027a9f144b5d77e4aa7e01 Mon Sep 17 00:00:00 2001 From: Adrian Cirstea <54354938+ShadowsAdi@users.noreply.github.com> Date: Tue, 5 Mar 2024 23:57:27 +0200 Subject: [PATCH 14/14] Update cmd.cpp --- rehlds/engine/cmd.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/rehlds/engine/cmd.cpp b/rehlds/engine/cmd.cpp index 4f674fc4..23386934 100644 --- a/rehlds/engine/cmd.cpp +++ b/rehlds/engine/cmd.cpp @@ -1211,27 +1211,28 @@ void UnsafeCmdLineProcessor(const char *pchUnsafeCmdLine, int cubSize) const char* szPrefix = "nocmd tece "; netadr_t *address; char szSanitizedConnect[128]; - //void *s1 = nullptr; - Con_Printf("test: %s", pchUnsafeCmdLine); + // 0x3039617A415A5F2D2E3A + // "09azAZ_-.:" ???? + if(Q_strcmp(pchUnsafeCmdLine, szPrefix) == 0) { if (cubSize > count && pchUnsafeCmdLine[9] != ' ') { - //s1 = &pchUnsafeCmdLine[9]; const char* address_str = &pchUnsafeCmdLine[9]; netadr_t address; if (NET_StringToAdr(address_str, &address)) { Q_snprintf(szSanitizedConnect, sizeof(szSanitizedConnect), "\nconnect %s\n", NET_AdrToString(address)); - Cbuf_AddText(szSanitizedConnect); - Cbuf_AddText("\ncl_skipvid 1\n"); - } - else - { - Con_Printf("Invalid address to connect to from unsafe command line.\n"); - } + Cbuf_AddText(szSanitizedConnect); + Cbuf_AddText("\ncl_skipvid 1\n"); + return; + } + + Con_Printf("Invalid address to connect to from unsafe location! Ignoring.\n"); + return; } } + Con_Printf("Rejecting unsafe cmdline\n"); } \ No newline at end of file