Remove strncopy().
This commit is contained in:
parent
67ba703b84
commit
e08697ad54
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* vim: set ts=4 sw=4 tw=99 noet :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
@ -37,6 +37,7 @@
|
||||
#include "HalfLife2.h"
|
||||
#include "logic_bridge.h"
|
||||
#include "sourcemod.h"
|
||||
#include <amtl/am-string.h>
|
||||
|
||||
#if SOURCE_ENGINE == SE_DOTA
|
||||
SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommandContext &, const CCommand &);
|
||||
@ -433,7 +434,7 @@ bool ChatTriggers::PreProcessTrigger(edict_t *pEdict, const char *args)
|
||||
*/
|
||||
char new_buf[80];
|
||||
strcpy(new_buf, "sm_");
|
||||
strncopy(&new_buf[3], cmd_buf, sizeof(new_buf)-3);
|
||||
ke::SafeStrcpy(&new_buf[3], sizeof(new_buf)-3, cmd_buf);
|
||||
|
||||
/* Recheck */
|
||||
if (!g_ConCmds.LookForSourceModCommand(new_buf))
|
||||
@ -454,10 +455,10 @@ bool ChatTriggers::PreProcessTrigger(edict_t *pEdict, const char *args)
|
||||
{
|
||||
len = UTIL_Format(m_ToExecute, sizeof(m_ToExecute), "sm_%s", args);
|
||||
} else {
|
||||
len = strncopy(m_ToExecute, args, sizeof(m_ToExecute));
|
||||
len = ke::SafeStrcpy(m_ToExecute, sizeof(m_ToExecute), args);
|
||||
}
|
||||
} else {
|
||||
strncopy(m_ToExecute, args, sizeof(m_ToExecute));
|
||||
ke::SafeStrcpy(m_ToExecute, sizeof(m_ToExecute), args);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -434,7 +434,7 @@ bool SM_ExecuteConfig(IPlugin *pl, AutoConfig *cfg, bool can_create)
|
||||
char *dptr = descr;
|
||||
|
||||
/* Print comments until there is no more */
|
||||
strncopy(descr, cvar->GetHelpText(), sizeof(descr));
|
||||
ke::SafeStrcpy(descr, sizeof(descr), cvar->GetHelpText());
|
||||
while (*dptr != '\0')
|
||||
{
|
||||
/* Find the next line */
|
||||
|
@ -831,7 +831,7 @@ void CHalfLife2::PushCommandStack(const CCommand *cmd)
|
||||
|
||||
info.args = cmd;
|
||||
#if SOURCE_ENGINE <= SE_DARKMESSIAH
|
||||
strncopy(info.cmd, cmd->Arg(0), sizeof(info.cmd));
|
||||
ke::SafeStrcpy(info.cmd, sizeof(info.cmd), cmd->Arg(0));
|
||||
#endif
|
||||
|
||||
m_CommandStack.push(info);
|
||||
@ -1247,7 +1247,7 @@ SMFindMapResult CHalfLife2::FindMap(char *pMapName, int nMapNameMax)
|
||||
}
|
||||
else
|
||||
{
|
||||
strncopy(pMapName, &results[0][helperCmdLen + 1], nMapNameMax);
|
||||
ke::SafeStrcpy(pMapName, nMapNameMax, &results[0][helperCmdLen + 1]);
|
||||
return SMFindMapResult::FuzzyMatch;
|
||||
}
|
||||
#elif SOURCE_ENGINE == SE_TF2
|
||||
@ -1263,7 +1263,7 @@ bool CHalfLife2::IsMapValid(const char *map)
|
||||
return false;
|
||||
|
||||
static char szTmp[PLATFORM_MAX_PATH];
|
||||
strncopy(szTmp, map, sizeof(szTmp));
|
||||
ke::SafeStrcpy(szTmp, sizeof(szTmp), map);
|
||||
|
||||
return FindMap(szTmp, sizeof(szTmp)) != SMFindMapResult::NotFound;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* vim: set ts=4 sw=4 tw=99 noet :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
@ -382,7 +382,7 @@ bool CValveMenu::SetExtOption(MenuOption option, const void *valuePtr)
|
||||
{
|
||||
if (option == MenuOption_IntroMessage)
|
||||
{
|
||||
strncopy(m_IntroMsg, (const char *)valuePtr, sizeof(m_IntroMsg));
|
||||
ke::SafeStrcpy(m_IntroMsg, sizeof(m_IntroMsg), (const char *)valuePtr);
|
||||
return true;
|
||||
} else if (option == MenuOption_IntroColor) {
|
||||
unsigned int *array = (unsigned int *)valuePtr;
|
||||
|
@ -1657,7 +1657,7 @@ void PlayerManager::ProcessCommandTarget(cmd_target_info_t *info)
|
||||
{
|
||||
info->targets[0] = client;
|
||||
info->num_targets = 1;
|
||||
strncopy(info->target_name, pTarget->GetName(), info->target_name_maxlength);
|
||||
ke::SafeStrcpy(info->target_name, info->target_name_maxlength, pTarget->GetName());
|
||||
info->target_name_style = COMMAND_TARGETNAME_RAW;
|
||||
}
|
||||
else
|
||||
@ -1731,7 +1731,7 @@ void PlayerManager::ProcessCommandTarget(cmd_target_info_t *info)
|
||||
{
|
||||
info->targets[0] = i;
|
||||
info->num_targets = 1;
|
||||
strncopy(info->target_name, pTarget->GetName(), info->target_name_maxlength);
|
||||
ke::SafeStrcpy(info->target_name, info->target_name_maxlength, pTarget->GetName());
|
||||
info->target_name_style = COMMAND_TARGETNAME_RAW;
|
||||
}
|
||||
else
|
||||
@ -1761,7 +1761,7 @@ void PlayerManager::ProcessCommandTarget(cmd_target_info_t *info)
|
||||
{
|
||||
info->targets[0] = i;
|
||||
info->num_targets = 1;
|
||||
strncopy(info->target_name, pTarget->GetName(), info->target_name_maxlength);
|
||||
ke::SafeStrcpy(info->target_name, info->target_name_maxlength, pTarget->GetName());
|
||||
info->target_name_style = COMMAND_TARGETNAME_RAW;
|
||||
}
|
||||
else
|
||||
@ -1780,7 +1780,7 @@ void PlayerManager::ProcessCommandTarget(cmd_target_info_t *info)
|
||||
{
|
||||
info->targets[0] = info->admin;
|
||||
info->num_targets = 1;
|
||||
strncopy(info->target_name, pAdmin->GetName(), info->target_name_maxlength);
|
||||
ke::SafeStrcpy(info->target_name, info->target_name_maxlength, pAdmin->GetName());
|
||||
info->target_name_style = COMMAND_TARGETNAME_RAW;
|
||||
}
|
||||
else
|
||||
@ -1799,7 +1799,7 @@ void PlayerManager::ProcessCommandTarget(cmd_target_info_t *info)
|
||||
if (strcmp(info->pattern, "@all") == 0)
|
||||
{
|
||||
is_multi = true;
|
||||
strncopy(info->target_name, "all players", info->target_name_maxlength);
|
||||
ke::SafeStrcpy(info->target_name, info->target_name_maxlength, "all players");
|
||||
info->target_name_style = COMMAND_TARGETNAME_ML;
|
||||
}
|
||||
else if (strcmp(info->pattern, "@dead") == 0)
|
||||
@ -1812,7 +1812,7 @@ void PlayerManager::ProcessCommandTarget(cmd_target_info_t *info)
|
||||
return;
|
||||
}
|
||||
info->flags |= COMMAND_FILTER_DEAD;
|
||||
strncopy(info->target_name, "all dead players", info->target_name_maxlength);
|
||||
ke::SafeStrcpy(info->target_name, info->target_name_maxlength, "all dead players");
|
||||
info->target_name_style = COMMAND_TARGETNAME_ML;
|
||||
}
|
||||
else if (strcmp(info->pattern, "@alive") == 0)
|
||||
@ -1824,7 +1824,7 @@ void PlayerManager::ProcessCommandTarget(cmd_target_info_t *info)
|
||||
info->reason = COMMAND_TARGET_NOT_DEAD;
|
||||
return;
|
||||
}
|
||||
strncopy(info->target_name, "all alive players", info->target_name_maxlength);
|
||||
ke::SafeStrcpy(info->target_name, info->target_name_maxlength, "all alive players");
|
||||
info->target_name_style = COMMAND_TARGETNAME_ML;
|
||||
info->flags |= COMMAND_FILTER_ALIVE;
|
||||
}
|
||||
@ -1837,21 +1837,21 @@ void PlayerManager::ProcessCommandTarget(cmd_target_info_t *info)
|
||||
info->reason = COMMAND_TARGET_NOT_HUMAN;
|
||||
return;
|
||||
}
|
||||
strncopy(info->target_name, "all bots", info->target_name_maxlength);
|
||||
ke::SafeStrcpy(info->target_name, info->target_name_maxlength, "all bots");
|
||||
info->target_name_style = COMMAND_TARGETNAME_ML;
|
||||
bots_only = true;
|
||||
}
|
||||
else if (strcmp(info->pattern, "@humans") == 0)
|
||||
{
|
||||
is_multi = true;
|
||||
strncopy(info->target_name, "all humans", info->target_name_maxlength);
|
||||
ke::SafeStrcpy(info->target_name, info->target_name_maxlength, "all humans");
|
||||
info->target_name_style = COMMAND_TARGETNAME_ML;
|
||||
info->flags |= COMMAND_FILTER_NO_BOTS;
|
||||
}
|
||||
else if (strcmp(info->pattern, "@!me") == 0)
|
||||
{
|
||||
is_multi = true;
|
||||
strncopy(info->target_name, "all players", info->target_name_maxlength);
|
||||
ke::SafeStrcpy(info->target_name, info->target_name_maxlength, "all players");
|
||||
info->target_name_style = COMMAND_TARGETNAME_ML;
|
||||
skip_client = info->admin;
|
||||
}
|
||||
@ -1923,7 +1923,7 @@ void PlayerManager::ProcessCommandTarget(cmd_target_info_t *info)
|
||||
{
|
||||
info->targets[0] = found_client;
|
||||
info->num_targets = 1;
|
||||
strncopy(info->target_name, pFoundClient->GetName(), info->target_name_maxlength);
|
||||
ke::SafeStrcpy(info->target_name, info->target_name_maxlength, pFoundClient->GetName());
|
||||
info->target_name_style = COMMAND_TARGETNAME_RAW;
|
||||
}
|
||||
else
|
||||
@ -2071,7 +2071,7 @@ void CPlayer::Initialize(const char *name, const char *ip, edict_t *pEntity)
|
||||
m_Serial.bits.serial = g_PlayerSerialCount++;
|
||||
|
||||
char ip2[24], *ptr;
|
||||
strncopy(ip2, ip, sizeof(ip2));
|
||||
ke::SafeStrcpy(ip2, sizeof(ip2), ip);
|
||||
if ((ptr = strchr(ip2, ':')) != NULL)
|
||||
{
|
||||
*ptr = '\0';
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* vim: set ts=4 sw=4 tw=99 noet :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2013 AlliedModders LLC. All rights reserved.
|
||||
@ -34,6 +34,7 @@
|
||||
|
||||
#include <sh_list.h>
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include <amtl/am-string.h>
|
||||
|
||||
#define GETCHECK_FIELD() \
|
||||
const protobuf::FieldDescriptor *field = msg->GetDescriptor()->FindFieldByName(pszFieldName); \
|
||||
@ -672,7 +673,7 @@ public:
|
||||
CHECK_FIELD_NOT_REPEATED();
|
||||
|
||||
std::string scratch;
|
||||
strncopy(out, msg->GetReflection()->GetStringReference(*msg, field, &scratch).c_str(), size);
|
||||
ke::SafeStrcpy(out, size, msg->GetReflection()->GetStringReference(*msg, field, &scratch).c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -695,7 +696,7 @@ public:
|
||||
CHECK_REPEATED_ELEMENT(index);
|
||||
|
||||
std::string scratch;
|
||||
strncopy(out, msg->GetReflection()->GetRepeatedStringReference(*msg, field, index, &scratch).c_str(), size);
|
||||
ke::SafeStrcpy(out, size, msg->GetReflection()->GetRepeatedStringReference(*msg, field, index, &scratch).c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -38,6 +38,7 @@
|
||||
#elif SOURCE_ENGINE == SE_CSGO
|
||||
#include <cstrike15_usermessage_helpers.h>
|
||||
#endif
|
||||
#include <amtl/am-string.h>
|
||||
|
||||
UserMessages g_UserMsgs;
|
||||
|
||||
@ -158,7 +159,7 @@ bool UserMessages::GetMessageName(int msgid, char *buffer, size_t maxlength) con
|
||||
if (!pszName)
|
||||
return false;
|
||||
|
||||
strncopy(buffer, pszName, maxlength);
|
||||
ke::SafeStrcpy(buffer, maxlength, pszName);
|
||||
return true;
|
||||
#else
|
||||
if (m_FallbackSearch)
|
||||
@ -171,7 +172,7 @@ bool UserMessages::GetMessageName(int msgid, char *buffer, size_t maxlength) con
|
||||
|
||||
if (msg)
|
||||
{
|
||||
strncopy(buffer, msg, maxlength);
|
||||
ke::SafeStrcpy(buffer, maxlength, msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* vim: set ts=4 sw=4 tw=99 noet :
|
||||
* =============================================================================
|
||||
* SourceMod
|
||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||
@ -36,6 +36,7 @@
|
||||
#include "sm_stringutil.h"
|
||||
#include "sourcemm_api.h"
|
||||
#include "compat_wrappers.h"
|
||||
#include <amtl/am-string.h>
|
||||
|
||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||
SH_DECL_HOOK1_void(ICvar, UnregisterConCommand, SH_NOATTRIB, 0, ConCommandBase *);
|
||||
@ -146,7 +147,7 @@ public:
|
||||
|
||||
info->pBase = pBase;
|
||||
info->cls = cls;
|
||||
strncopy(info->name, pBase->GetName(), sizeof(info->name));
|
||||
ke::SafeStrcpy(info->name, sizeof(info->name), pBase->GetName());
|
||||
|
||||
tracked_bases.push_back(info);
|
||||
}
|
||||
|
@ -469,7 +469,7 @@ bool CoreProviderImpl::GetGameName(char *buffer, size_t maxlength)
|
||||
const char *str;
|
||||
if ((str = pGameInfo->GetString("game", NULL)) != NULL)
|
||||
{
|
||||
strncopy(buffer, str, maxlength);
|
||||
ke::SafeStrcpy(buffer, maxlength, str);
|
||||
pGameInfo->deleteThis();
|
||||
return true;
|
||||
}
|
||||
|
@ -41,11 +41,6 @@
|
||||
#include <am-utility.h>
|
||||
#include <am-float.h>
|
||||
|
||||
unsigned int strncopy(char *dest, const char *src, size_t count)
|
||||
{
|
||||
return ke::SafeStrcpy(dest, count, src);
|
||||
}
|
||||
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
@ -42,7 +42,6 @@ using namespace SourceMod;
|
||||
|
||||
#define IS_STR_FILLED(var) (var[0] != '\0')
|
||||
|
||||
unsigned int strncopy(char *dest, const char *src, size_t count);
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||
size_t UTIL_FormatArgs(char *buffer, size_t maxlength, const char *fmt, va_list ap);
|
||||
char *sm_strdup(const char *str);
|
||||
|
@ -1003,7 +1003,7 @@ static cell_t SetEntDataString(IPluginContext *pContext, const cell_t *params)
|
||||
char *dest = (char *)((uint8_t *)pEntity + offset);
|
||||
|
||||
pContext->LocalToString(params[3], &src);
|
||||
size_t len = strncopy(dest, src, params[4]);
|
||||
size_t len = ke::SafeStrcpy(dest, params[4], src);
|
||||
|
||||
if (params[5] && (pEdict != NULL))
|
||||
{
|
||||
@ -2165,7 +2165,7 @@ static cell_t SetEntPropString(IPluginContext *pContext, const cell_t *params)
|
||||
else
|
||||
{
|
||||
char *dest = (char *) ((uint8_t *) pEntity + offset);
|
||||
len = strncopy(dest, src, maxlen);
|
||||
len = ke::SafeStrcpy(dest, maxlen, src);
|
||||
}
|
||||
|
||||
if (params[2] == Prop_Send && (pEdict != NULL))
|
||||
|
@ -152,7 +152,7 @@ bool SourceModBase::InitializeSourceMod(char *error, size_t maxlength, bool late
|
||||
{
|
||||
if (gamepath[i] == PLATFORM_SEP_CHAR)
|
||||
{
|
||||
strncopy(m_ModDir, &gamepath[++i], sizeof(m_ModDir));
|
||||
ke::SafeStrcpy(m_ModDir, sizeof(m_ModDir), &gamepath[++i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user