mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-01 01:25:38 +03:00
Merge branch 'coverity_fixes'
This commit is contained in:
commit
c0889990db
@ -40,6 +40,8 @@ public:
|
||||
Failure (std::string message, std::string testName) {
|
||||
this->testName = testName;
|
||||
this->message = message;
|
||||
this->fileName = "<unknown>";
|
||||
this->lineNumber = -1;
|
||||
}
|
||||
|
||||
std::string testName;
|
||||
|
@ -14,7 +14,7 @@ void Assertions::StringEquals(std::string message, std::string expected, std::st
|
||||
}
|
||||
|
||||
void Assertions::StringEquals(std::string message, const char* expected, const char* actual, const char* fileName, long lineNumber) {
|
||||
if (expected == NULL) {
|
||||
if (actual == NULL) {
|
||||
std::stringstream ss;
|
||||
ss << message << " (expected '" << expected << "', got NULL";
|
||||
throw TestFailException(ss.str(), std::string(fileName), lineNumber);
|
||||
|
@ -11,7 +11,8 @@
|
||||
Test::Test (const char* testName, const char* testGroup, int timeout)
|
||||
: name_ (testName), group_ (testGroup), timeout_(timeout)
|
||||
{
|
||||
TestRegistry::addTest (this);
|
||||
next_ = NULL;
|
||||
TestRegistry::addTest(this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -998,7 +998,7 @@ void Cmd_ExecuteString(char *text, cmd_source_t src)
|
||||
}
|
||||
|
||||
IGameClient* cl = (src == src_client) ? GetRehldsApiClient(host_client) : NULL;
|
||||
if (!g_RehldsHookchains.m_ValidateCommand.callChain(ValidateCmd_API, cmd_argv[0], src, cl))
|
||||
if (!g_RehldsHookchains.m_ValidateCommand.callChain(ValidateCmd_API, false, cmd_argv[0], src, cl))
|
||||
return;
|
||||
|
||||
g_RehldsHookchains.m_ExecuteServerStringCmd.callChain(Cmd_ExecuteString_internal, cmd_argv[0], src, cl);
|
||||
|
@ -1307,7 +1307,7 @@ bool NET_GetPacketPreprocessor(uint8* data, unsigned int len, const netadr_t& sr
|
||||
qboolean NET_GetPacket(netsrc_t sock) {
|
||||
qboolean getRes = NET_GetPacket_internal(sock);
|
||||
while (getRes) {
|
||||
bool pass = g_RehldsHookchains.m_PreprocessPacket.callChain(NET_GetPacketPreprocessor, net_message.data, net_message.cursize, net_from);
|
||||
bool pass = g_RehldsHookchains.m_PreprocessPacket.callChain(NET_GetPacketPreprocessor, FALSE, net_message.data, net_message.cursize, net_from);
|
||||
if (pass) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -1776,7 +1776,7 @@ qboolean SV_FilterUser(USERID_t *userid)
|
||||
|
||||
int SV_CheckProtocol(netadr_t *adr, int nProtocol)
|
||||
{
|
||||
return g_RehldsHookchains.m_SV_CheckProtocol.callChain(SV_CheckProtocol_internal, adr, nProtocol);
|
||||
return g_RehldsHookchains.m_SV_CheckProtocol.callChain(SV_CheckProtocol_internal, 0, adr, nProtocol);
|
||||
}
|
||||
|
||||
/* <a7396> ../engine/sv_main.c:2302 */
|
||||
@ -1863,7 +1863,7 @@ int SV_CheckChallenge(netadr_t *adr, int nChallengeValue)
|
||||
|
||||
int SV_CheckIPRestrictions(netadr_t *adr, int nAuthProtocol)
|
||||
{
|
||||
return g_RehldsHookchains.m_SV_CheckIPRestrictions.callChain(SV_CheckIPRestrictions_internal, adr, nAuthProtocol);
|
||||
return g_RehldsHookchains.m_SV_CheckIPRestrictions.callChain(SV_CheckIPRestrictions_internal, 0, adr, nAuthProtocol);
|
||||
}
|
||||
|
||||
/* <a743d> ../engine/sv_main.c:2393 */
|
||||
@ -1904,7 +1904,7 @@ int SV_CheckIPConnectionReuse(netadr_t *adr)
|
||||
|
||||
int SV_FinishCertificateCheck(netadr_t *adr, int nAuthProtocol, char *szRawCertificate, char *userinfo)
|
||||
{
|
||||
return g_RehldsHookchains.m_SV_FinishCertificateCheck.callChain(SV_FinishCertificateCheck_internal, adr, nAuthProtocol, szRawCertificate, userinfo);
|
||||
return g_RehldsHookchains.m_SV_FinishCertificateCheck.callChain(SV_FinishCertificateCheck_internal, 0, adr, nAuthProtocol, szRawCertificate, userinfo);
|
||||
}
|
||||
|
||||
/* <a74f4> ../engine/sv_main.c:2461 */
|
||||
@ -1945,7 +1945,7 @@ int SV_FinishCertificateCheck_internal(netadr_t *adr, int nAuthProtocol, char *s
|
||||
|
||||
int SV_CheckKeyInfo(netadr_t *adr, char *protinfo, short unsigned int *port, int *pAuthProtocol, char *pszRaw, char *cdkey)
|
||||
{
|
||||
return g_RehldsHookchains.m_SV_CheckKeyInfo.callChain(SV_CheckKeyInfo_internal, adr, protinfo, port, pAuthProtocol, pszRaw, cdkey);
|
||||
return g_RehldsHookchains.m_SV_CheckKeyInfo.callChain(SV_CheckKeyInfo_internal, 0, adr, protinfo, port, pAuthProtocol, pszRaw, cdkey);
|
||||
}
|
||||
|
||||
/* <a7584> ../engine/sv_main.c:2527 */
|
||||
@ -4766,8 +4766,6 @@ void SV_ExtractFromUserinfo(client_t *cl)
|
||||
{
|
||||
const char *val;
|
||||
int i;
|
||||
client_t *client;
|
||||
int dupc;
|
||||
char newname[MAX_NAME];
|
||||
char rawname[MAX_NAME];
|
||||
|
||||
@ -7085,7 +7083,7 @@ void SV_Shutdown(void)
|
||||
|
||||
qboolean SV_CompareUserID(USERID_t *id1, USERID_t *id2)
|
||||
{
|
||||
return g_RehldsHookchains.m_SV_CompareUserID.callChain(SV_CompareUserID_internal, id1, id2);
|
||||
return g_RehldsHookchains.m_SV_CompareUserID.callChain(SV_CompareUserID_internal, 0, id1, id2);
|
||||
}
|
||||
|
||||
/* <a5ef9> ../engine/sv_main.c:9585 */
|
||||
@ -7114,7 +7112,7 @@ qboolean SV_CompareUserID_internal(USERID_t *id1, USERID_t *id2)
|
||||
|
||||
char *SV_GetIDString(USERID_t *id)
|
||||
{
|
||||
return g_RehldsHookchains.m_SV_GetIDString.callChain(SV_GetIDString_internal, id);
|
||||
return g_RehldsHookchains.m_SV_GetIDString.callChain(SV_GetIDString_internal, 0, id);
|
||||
}
|
||||
|
||||
/* <aad82> ../engine/sv_main.c:9625 */
|
||||
|
@ -687,7 +687,7 @@ qboolean Steam_NotifyClientConnect_api(IGameClient *cl, const void *pvSteam2Key,
|
||||
qboolean Steam_NotifyClientConnect(client_t *cl, const void *pvSteam2Key, unsigned int ucbSteam2Key)
|
||||
{
|
||||
return g_RehldsHookchains.m_Steam_NotifyClientConnect
|
||||
.callChain(Steam_NotifyClientConnect_api, GetRehldsApiClient(cl), pvSteam2Key, ucbSteam2Key);
|
||||
.callChain(Steam_NotifyClientConnect_api, FALSE, GetRehldsApiClient(cl), pvSteam2Key, ucbSteam2Key);
|
||||
}
|
||||
|
||||
|
||||
@ -708,7 +708,7 @@ qboolean Steam_NotifyBotConnect_api(IGameClient* cl)
|
||||
|
||||
qboolean Steam_NotifyBotConnect(client_t *cl)
|
||||
{
|
||||
return g_RehldsHookchains.m_Steam_NotifyBotConnect.callChain(Steam_NotifyBotConnect_api, GetRehldsApiClient(cl));
|
||||
return g_RehldsHookchains.m_Steam_NotifyBotConnect.callChain(Steam_NotifyBotConnect_api, FALSE, GetRehldsApiClient(cl));
|
||||
}
|
||||
|
||||
/* <f18cf> ../engine/sv_steam3.cpp:924 */
|
||||
|
@ -192,6 +192,7 @@ uint32 calcEdictChecksum(uint32 crc, const edict_t* ed) {
|
||||
}
|
||||
|
||||
void PrintFloat(const float* pVal, std::stringstream &ss) {
|
||||
IosFlagSaver iosfs(ss);
|
||||
uint32 sVal = *reinterpret_cast<const uint32*>(pVal);
|
||||
ss << "{ float: " << *pVal << "; raw: " << std::hex << sVal << " }";
|
||||
}
|
||||
@ -254,6 +255,7 @@ enum PrintEdictFlags_e {
|
||||
|
||||
void PrintEdict(edict_t* ent, std::stringstream &ss, int flags)
|
||||
{
|
||||
IosFlagSaver iosfs(ss);
|
||||
if (ent == NULL) {
|
||||
ss << "NULL";
|
||||
return;
|
||||
@ -538,18 +540,21 @@ void __cdecl SV_Physics_Step_hooked(edict_t *ent)
|
||||
|
||||
void Rehlds_Debug_logAlloc(size_t sz, void* ptr)
|
||||
{
|
||||
IosFlagSaver iosfs(g_RehldsDebugLog);
|
||||
g_RehldsDebugLog << "malloc(" << sz << ") => " << std::hex << (size_t)ptr << "\n";
|
||||
g_RehldsDebugLog.flush();
|
||||
}
|
||||
|
||||
void Rehlds_Debug_logRealloc(size_t sz, void* oldPtr, void* newPtr)
|
||||
{
|
||||
g_RehldsDebugLog << "realloc(" << std::hex << (size_t)oldPtr << ", " << sz << ") => " << std::hex << (size_t)newPtr << "\n";
|
||||
IosFlagSaver iosfs(g_RehldsDebugLog);
|
||||
g_RehldsDebugLog << "realloc(" << std::hex << (size_t)oldPtr << ", " << sz << ") => " << (size_t)newPtr << "\n";
|
||||
g_RehldsDebugLog.flush();
|
||||
}
|
||||
|
||||
void Rehlds_Debug_logFree(void* ptr)
|
||||
{
|
||||
IosFlagSaver iosfs(g_RehldsDebugLog);
|
||||
g_RehldsDebugLog << "free(" << std::hex << (size_t)ptr << ")\n";
|
||||
g_RehldsDebugLog.flush();
|
||||
}
|
||||
|
@ -470,6 +470,7 @@
|
||||
<ClInclude Include="..\public\FileSystem.h" />
|
||||
<ClInclude Include="..\public\idedicatedexports.h" />
|
||||
<ClInclude Include="..\public\interface.h" />
|
||||
<ClInclude Include="..\public\iosutil.h" />
|
||||
<ClInclude Include="..\public\iregistry.h" />
|
||||
<ClInclude Include="..\public\protected_things.h" />
|
||||
<ClInclude Include="..\public\rehlds\archtypes.h" />
|
||||
|
@ -1050,6 +1050,9 @@
|
||||
<ClInclude Include="..\public\rehlds\crc32c.h">
|
||||
<Filter>public\rehlds</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\public\iosutil.h">
|
||||
<Filter>public</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\linux\appversion.sh">
|
||||
|
21
rehlds/public/iosutil.h
Normal file
21
rehlds/public/iosutil.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <ios>
|
||||
|
||||
class IosFlagSaver {
|
||||
public:
|
||||
explicit IosFlagSaver(std::ostream& _ios) :
|
||||
ios(_ios),
|
||||
f(_ios.flags()) {
|
||||
}
|
||||
~IosFlagSaver() {
|
||||
ios.flags(f);
|
||||
}
|
||||
|
||||
IosFlagSaver(const IosFlagSaver &rhs) = delete;
|
||||
IosFlagSaver& operator= (const IosFlagSaver& rhs) = delete;
|
||||
|
||||
private:
|
||||
std::ostream& ios;
|
||||
std::ios::fmtflags f;
|
||||
};
|
@ -12,7 +12,7 @@ You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "crc32c.h"
|
||||
#include "crc32c.h"
|
||||
#include "sys_shared.h"
|
||||
#include "immintrin.h"
|
||||
|
||||
@ -120,22 +120,22 @@ uint32 crc32c_t8_sse(uint32 iCRC, uint8 u8) {
|
||||
}
|
||||
|
||||
uint32 crc32c_t_sse(uint32 iCRC, const uint8 *buf, unsigned int len) {
|
||||
uint32 crc32cval = iCRC;
|
||||
unsigned int i = 0;
|
||||
|
||||
for (; i < (len >> 2); i += 4) {
|
||||
crc32cval = _mm_crc32_u32(crc32cval, *(uint32*)&buf[i]);
|
||||
}
|
||||
|
||||
for (; i < len; i++) {
|
||||
crc32cval = _mm_crc32_u8(crc32cval, buf[i]);
|
||||
}
|
||||
|
||||
uint32 crc32cval = iCRC;
|
||||
unsigned int i = 0;
|
||||
|
||||
for (; i < (len >> 2); i += 4) {
|
||||
crc32cval = _mm_crc32_u32(crc32cval, *(uint32*)&buf[i]);
|
||||
}
|
||||
|
||||
for (; i < len; i++) {
|
||||
crc32cval = _mm_crc32_u8(crc32cval, buf[i]);
|
||||
}
|
||||
|
||||
return crc32cval;
|
||||
}
|
||||
|
||||
uint32 crc32c_t(uint32 iCRC, const uint8 *buf, unsigned int len) {
|
||||
return cpuinfo.sse4_2 ? crc32c_t_nosse(iCRC, buf, len) : crc32c_t_nosse(iCRC, buf, len);
|
||||
return cpuinfo.sse4_2 ? crc32c_t_sse(iCRC, buf, len) : crc32c_t_nosse(iCRC, buf, len);
|
||||
}
|
||||
|
||||
uint32 crc32c(const uint8 *buf, int len) {
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
AbstractHookChain::AbstractHookChain() {
|
||||
memset(m_Hooks, 0, sizeof(m_Hooks));
|
||||
m_NumHooks = 0;
|
||||
m_CurHook = 0;
|
||||
m_bOriginalCalled = false;
|
||||
@ -39,6 +40,7 @@ void AbstractHookChain::init(void* origFunc, void* hooks, int numHooks) {
|
||||
|
||||
AbstractHookChainRegistry::AbstractHookChainRegistry()
|
||||
{
|
||||
memset(m_Hooks, 0, sizeof(m_Hooks));
|
||||
m_NumHooks = 0;
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,11 @@ private:
|
||||
|
||||
public:
|
||||
virtual ~IHookChainImpl() { }
|
||||
|
||||
IHookChainImpl(t_ret defaultResult) {
|
||||
m_OriginalReturnResult = defaultResult;
|
||||
}
|
||||
|
||||
virtual t_ret callNext(t_args... args) {
|
||||
void* nextvhook = nextHook();
|
||||
if (nextvhook) {
|
||||
@ -130,8 +135,8 @@ public:
|
||||
|
||||
virtual ~IHookChainRegistryImpl() { }
|
||||
|
||||
t_ret callChain(origfunc_t origFunc, t_args... args) {
|
||||
IHookChainImpl<t_ret, t_args...> chain;
|
||||
t_ret callChain(origfunc_t origFunc, t_ret defaultResult, t_args... args) {
|
||||
IHookChainImpl<t_ret, t_args...> chain(defaultResult);
|
||||
chain.init((void*)origFunc, m_Hooks, m_NumHooks);
|
||||
return chain.callNext(args...);
|
||||
}
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include "utlbuffer.h"
|
||||
#include "utlrbtree.h"
|
||||
|
||||
#include "iosutil.h"
|
||||
|
||||
//testsuite
|
||||
#include "testsuite.h"
|
||||
#include "funccalls.h"
|
||||
|
@ -1,12 +1,5 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
uint64 NET_AdrToLong(const netadr_t &a) {
|
||||
if (a.type != NA_IP)
|
||||
return -1;
|
||||
|
||||
return a.ip[0] | (a.ip[1] << 8) | (a.ip[2] << 16) | (a.ip[3] << 24) | (uint64)a.port << 32;
|
||||
}
|
||||
|
||||
CSteamCallbackAnonymizingWrapper::CSteamCallbackAnonymizingWrapper(CAnonymizingEngExtInterceptor* anonymizer, CCallbackBase* cb, int id)
|
||||
{
|
||||
m_Anonymizer = anonymizer;
|
||||
|
Loading…
Reference in New Issue
Block a user