Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash exploit when warden fix #376

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions addons/sourcemod/scripting/MyJailbreak/Modules/Warden/handcuffs.sp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ ConVar gc_iCuffedColorBlue;

// Booleans
bool g_bCuffed[MAXPLAYERS+1] = false;
bool g_bClientIsDisconnecting[MAXPLAYERS+1]; // fixes StripZeus crash

// Integers
int g_iPlayerHandCuffs[MAXPLAYERS+1];
Expand Down Expand Up @@ -136,26 +137,26 @@ public void HandCuffs_OnSettingChanged(Handle convar, const char[] oldValue, con
{
strcopy(g_sSoundCuffsPath, sizeof(g_sSoundCuffsPath), newValue);

if (gc_bSounds.BoolValue)
{
if (gc_bSounds.BoolValue)
{
PrecacheSoundAnyDownload(g_sSoundCuffsPath);
}
}
else if (convar == gc_sSoundBreakCuffsPath)
{
strcopy(g_sSoundBreakCuffsPath, sizeof(g_sSoundBreakCuffsPath), newValue);

if (gc_bSounds.BoolValue)
{
if (gc_bSounds.BoolValue)
{
PrecacheSoundAnyDownload(g_sSoundBreakCuffsPath);
}
}
else if (convar == gc_sSoundUnLockCuffsPath)
{
strcopy(g_sSoundUnLockCuffsPath, sizeof(g_sSoundUnLockCuffsPath), newValue);

if (gc_bSounds.BoolValue)
{
if (gc_bSounds.BoolValue)
{
PrecacheSoundAnyDownload(g_sSoundUnLockCuffsPath);
}
}
Expand Down Expand Up @@ -443,6 +444,7 @@ public void HandCuffs_OnClientDisconnect(int client)
g_iCuffed--;

g_iLastButtons[client] = 0;
g_bClientIsDisconnecting[client] = true;

if (BreakTimer[client] != null)
{
Expand Down Expand Up @@ -484,6 +486,7 @@ public void HandCuffs_OnMapEnd()
public void HandCuffs_OnClientPutInServer(int client)
{
g_iPlayerPaperClips[client] = 0;
g_bClientIsDisconnecting[client] = false;
SDKHook(client, SDKHook_OnTakeDamage, HandCuffs_OnTakedamage);
}

Expand Down Expand Up @@ -744,6 +747,9 @@ void StripZeus(int client)
if (!IsValidClient(client, true, false))
return;

if (g_bClientIsDisconnecting[client]) // OnClientDisconnect is called BEFORE client fully disconnects, so he still passes IsValidClient check
return; // prevents infinite loops with #GameUI_Disconnect_TooManyCommands since FakeClientCommand is used

if ((!IsClientWarden(client) && (!IsClientDeputy(client) && gc_bHandCuffDeputy.BoolValue)))
return;

Expand Down
3 changes: 2 additions & 1 deletion addons/sourcemod/scripting/MyJailbreak/warden.sp
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,8 @@ public void OnClientPutInServer(int client)
// Warden disconnect
public void OnClientDisconnect(int client)
{
HandCuffs_OnClientDisconnect(client); // this is prioritised to fix a crash with the StripZeus function

if (IsClientWarden(client))
{
CPrintToChatAll("%s %t", g_sPrefix, "warden_disconnected", client);
Expand Down Expand Up @@ -1272,7 +1274,6 @@ public void OnClientDisconnect(int client)

Deputy_OnClientDisconnect(client);
Painter_OnClientDisconnect(client);
HandCuffs_OnClientDisconnect(client);
Freedays_OnClientDisconnect(client);
}

Expand Down