Remove bad-console-read protection logic for Metamod:Source 1.7 and earlier.
This commit is contained in:
parent
df672dd8ce
commit
b548ba7b58
@ -73,7 +73,7 @@ void ConCmdManager::OnSourceModShutdown()
|
|||||||
rootmenu->RemoveRootConsoleCommand("cmds", this);
|
rootmenu->RemoveRootConsoleCommand("cmds", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConCmdManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name, bool is_read_safe)
|
void ConCmdManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name)
|
||||||
{
|
{
|
||||||
/* Whoa, first get its information struct */
|
/* Whoa, first get its information struct */
|
||||||
ConCmdInfo *pInfo;
|
ConCmdInfo *pInfo;
|
||||||
@ -108,7 +108,7 @@ void ConCmdManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *na
|
|||||||
delete hook;
|
delete hook;
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveConCmd(pInfo, name, is_read_safe, false);
|
RemoveConCmd(pInfo, name, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConCmdManager::OnPluginDestroyed(IPlugin *plugin)
|
void ConCmdManager::OnPluginDestroyed(IPlugin *plugin)
|
||||||
@ -127,7 +127,7 @@ void ConCmdManager::OnPluginDestroyed(IPlugin *plugin)
|
|||||||
hook->admin->group->hooks.remove(hook);
|
hook->admin->group->hooks.remove(hook);
|
||||||
|
|
||||||
if (hook->info->hooks.empty())
|
if (hook->info->hooks.empty())
|
||||||
RemoveConCmd(hook->info, hook->info->pCmd->GetName(), true, true);
|
RemoveConCmd(hook->info, hook->info->pCmd->GetName(), true);
|
||||||
|
|
||||||
iter = pList->erase(iter);
|
iter = pList->erase(iter);
|
||||||
delete hook;
|
delete hook;
|
||||||
@ -517,7 +517,7 @@ void ConCmdManager::UpdateAdminCmdFlags(const char *cmd, OverrideType type, Flag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConCmdManager::RemoveConCmd(ConCmdInfo *info, const char *name, bool is_read_safe, bool untrack)
|
void ConCmdManager::RemoveConCmd(ConCmdInfo *info, const char *name, bool untrack)
|
||||||
{
|
{
|
||||||
/* Remove from the trie */
|
/* Remove from the trie */
|
||||||
m_Cmds.remove(name);
|
m_Cmds.remove(name);
|
||||||
@ -540,10 +540,6 @@ void ConCmdManager::RemoveConCmd(ConCmdInfo *info, const char *name, bool is_rea
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If it's not safe to read the pointer, we zap the SourceHook hook so it
|
|
||||||
// doesn't attempt to access the pointer's vtable.
|
|
||||||
if (!is_read_safe)
|
|
||||||
info->sh_hook->Zap();
|
|
||||||
if (untrack)
|
if (untrack)
|
||||||
UntrackConCommandBase(info->pCmd, this);
|
UntrackConCommandBase(info->pCmd, this);
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ public: //IPluginsListener
|
|||||||
public: //IRootConsoleCommand
|
public: //IRootConsoleCommand
|
||||||
void OnRootConsoleCommand(const char *cmdname, const ICommandArgs *command) override;
|
void OnRootConsoleCommand(const char *cmdname, const ICommandArgs *command) override;
|
||||||
public: //IConCommandTracker
|
public: //IConCommandTracker
|
||||||
void OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name, bool is_read_safe);
|
void OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name) override;
|
||||||
public:
|
public:
|
||||||
bool AddServerCommand(IPluginFunction *pFunction, const char *name, const char *description, int flags);
|
bool AddServerCommand(IPluginFunction *pFunction, const char *name, const char *description, int flags);
|
||||||
bool AddAdminCommand(IPluginFunction *pFunction,
|
bool AddAdminCommand(IPluginFunction *pFunction,
|
||||||
@ -148,7 +148,7 @@ private:
|
|||||||
ConCmdInfo *AddOrFindCommand(const char *name, const char *description, int flags);
|
ConCmdInfo *AddOrFindCommand(const char *name, const char *description, int flags);
|
||||||
void SetCommandClient(int client);
|
void SetCommandClient(int client);
|
||||||
void AddToCmdList(ConCmdInfo *info);
|
void AddToCmdList(ConCmdInfo *info);
|
||||||
void RemoveConCmd(ConCmdInfo *info, const char *cmd, bool is_read_safe, bool untrack);
|
void RemoveConCmd(ConCmdInfo *info, const char *cmd, bool untrack);
|
||||||
bool CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin);
|
bool CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin);
|
||||||
|
|
||||||
// Case insensitive
|
// Case insensitive
|
||||||
|
@ -167,7 +167,7 @@ bool convar_cache_lookup(const char *name, ConVarInfo **pVar)
|
|||||||
return convar_cache.retrieve(name, pVar);
|
return convar_cache.retrieve(name, pVar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConVarManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name, bool is_read_safe)
|
void ConVarManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name)
|
||||||
{
|
{
|
||||||
/* Only check convars that have not been created by SourceMod's core */
|
/* Only check convars that have not been created by SourceMod's core */
|
||||||
ConVarInfo *pInfo;
|
ConVarInfo *pInfo;
|
||||||
|
@ -103,7 +103,7 @@ public: // IPluginsListener
|
|||||||
public: //IRootConsoleCommand
|
public: //IRootConsoleCommand
|
||||||
void OnRootConsoleCommand(const char *cmdname, const ICommandArgs *command) override;
|
void OnRootConsoleCommand(const char *cmdname, const ICommandArgs *command) override;
|
||||||
public: //IConCommandTracker
|
public: //IConCommandTracker
|
||||||
void OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name, bool is_read_safe);
|
void OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name) override;
|
||||||
public: //IClientListener
|
public: //IClientListener
|
||||||
void OnClientDisconnected(int client);
|
void OnClientDisconnected(int client);
|
||||||
public:
|
public:
|
||||||
|
@ -1,33 +1,29 @@
|
|||||||
/**
|
// vim: set ts=4 sw=4 tw=99 et:
|
||||||
* vim: set ts=4 sw=4 tw=99 noet :
|
// =============================================================================
|
||||||
* =============================================================================
|
// SourceMod
|
||||||
* SourceMod
|
// Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
// =============================================================================
|
||||||
* =============================================================================
|
//
|
||||||
*
|
// This program is free software; you can redistribute it and/or modify it under
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
// the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
// Free Software Foundation.
|
||||||
* Free Software Foundation.
|
//
|
||||||
*
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
// details.
|
||||||
* details.
|
//
|
||||||
*
|
// You should have received a copy of the GNU General Public License along with
|
||||||
* You should have received a copy of the GNU General Public License along with
|
// this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
//
|
||||||
*
|
// As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
// code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
// by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
// all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
// this exception to all derivative works. AlliedModders LLC defines further
|
||||||
* this exception to all derivative works. AlliedModders LLC defines further
|
// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
// or <http://www.sourcemod.net/license.php>.
|
||||||
* or <http://www.sourcemod.net/license.php>.
|
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "sm_globals.h"
|
#include "sm_globals.h"
|
||||||
#include <sh_list.h>
|
#include <sh_list.h>
|
||||||
@ -104,41 +100,20 @@ public:
|
|||||||
listener = listener->next;
|
listener = listener->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pBase)
|
while (iter != tracked_bases.end())
|
||||||
{
|
{
|
||||||
while (iter != tracked_bases.end())
|
if ((*iter)->pBase == pBase)
|
||||||
{
|
{
|
||||||
if ((*iter)->pBase == pBase)
|
pInfo = (*iter);
|
||||||
{
|
iter = tracked_bases.erase(iter);
|
||||||
pInfo = (*iter);
|
pInfo->cls->OnUnlinkConCommandBase(pBase, pBase->GetName());
|
||||||
iter = tracked_bases.erase(iter);
|
delete pInfo;
|
||||||
pInfo->cls->OnUnlinkConCommandBase(pBase, pBase->GetName(), true);
|
}
|
||||||
delete pInfo;
|
else
|
||||||
}
|
{
|
||||||
else
|
iter++;
|
||||||
{
|
}
|
||||||
iter++;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while (iter != tracked_bases.end())
|
|
||||||
{
|
|
||||||
/* This is just god-awful! */
|
|
||||||
if (FindCommandBase((*iter)->name) != (*iter)->pBase)
|
|
||||||
{
|
|
||||||
pInfo = (*iter);
|
|
||||||
iter = tracked_bases.erase(iter);
|
|
||||||
pInfo->cls->OnUnlinkConCommandBase(pBase, pInfo->name, false);
|
|
||||||
delete pInfo;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddTarget(ConCommandBase *pBase, IConCommandTracker *cls)
|
void AddTarget(ConCommandBase *pBase, IConCommandTracker *cls)
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
class IConCommandTracker
|
class IConCommandTracker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name, bool is_read_safe) = 0;
|
virtual void OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
void TrackConCommandBase(ConCommandBase *pBase, IConCommandTracker *me);
|
void TrackConCommandBase(ConCommandBase *pBase, IConCommandTracker *me);
|
||||||
|
@ -131,7 +131,7 @@ public:
|
|||||||
class CommandFlagsHelper : public IConCommandTracker
|
class CommandFlagsHelper : public IConCommandTracker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name, bool is_read_safe)
|
void OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name) override
|
||||||
{
|
{
|
||||||
m_CmdFlags.remove(name);
|
m_CmdFlags.remove(name);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user