Fix max length inconsistencies + typo
This commit is contained in:
@ -24,7 +24,7 @@ CDirectory::CDirectory(const char *path)
|
||||
#if defined PLATFORM_WINDOWS
|
||||
|
||||
char newpath[PLATFORM_MAX_PATH];
|
||||
ke::SafeSprintf(newpath, sizeof(newpath) - 1, "%s\\*.*", path);
|
||||
ke::SafeSprintf(newpath, sizeof(newpath), "%s\\*.*", path);
|
||||
|
||||
m_dir = FindFirstFile(newpath, &m_fd);
|
||||
|
||||
@ -40,7 +40,7 @@ CDirectory::CDirectory(const char *path)
|
||||
if (IsValid())
|
||||
{
|
||||
m_ep = readdir(m_dir); // TODO: we need to read past "." and ".."!
|
||||
ke::SafeSprintf(m_origpath, sizeof(m_origpath) - 1, "%s", path);
|
||||
ke::SafeSprintf(m_origpath, sizeof(m_origpath), "%s", path);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -121,7 +121,7 @@ bool CDirectory::IsEntryFile()
|
||||
char temppath[PLATFORM_MAX_PATH];
|
||||
ke::SafeSprintf(temppath, sizeof(temppath), "%s/%s", m_origpath, GetEntryName());
|
||||
|
||||
return ke::file::IsDirectory(temppath);
|
||||
return ke::file::IsFile(temppath);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ static cell AMX_NATIVE_CALL set_cvar_float(AMX *amx, cell *params)
|
||||
|
||||
if (info)
|
||||
{
|
||||
ke::SafeSprintf(CVarTempBuffer, sizeof(CVarTempBuffer) - 1, "%f", amx_ctof(params[2]));
|
||||
ke::SafeSprintf(CVarTempBuffer, sizeof(CVarTempBuffer), "%f", amx_ctof(params[2]));
|
||||
CVAR_DIRECTSET(info->var, &CVarTempBuffer[0]);
|
||||
}
|
||||
|
||||
@ -258,7 +258,7 @@ static cell AMX_NATIVE_CALL set_cvar_num(AMX *amx, cell *params)
|
||||
|
||||
if (info)
|
||||
{
|
||||
ke::SafeSprintf(CVarTempBuffer, sizeof(CVarTempBuffer) - 1, "%d", value);
|
||||
ke::SafeSprintf(CVarTempBuffer, sizeof(CVarTempBuffer), "%d", value);
|
||||
CVAR_DIRECTSET(info->var, &CVarTempBuffer[0]);
|
||||
}
|
||||
|
||||
@ -444,7 +444,7 @@ static cell AMX_NATIVE_CALL set_pcvar_float(AMX *amx, cell *params)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ke::SafeSprintf(CVarTempBuffer, sizeof(CVarTempBuffer) - 1, "%f", amx_ctof(params[2]));
|
||||
ke::SafeSprintf(CVarTempBuffer, sizeof(CVarTempBuffer), "%f", amx_ctof(params[2]));
|
||||
CVAR_DIRECTSET(ptr, &CVarTempBuffer[0]);
|
||||
|
||||
return 1;
|
||||
@ -460,7 +460,7 @@ static cell AMX_NATIVE_CALL set_pcvar_num(AMX *amx, cell *params)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ke::SafeSprintf(CVarTempBuffer, sizeof(CVarTempBuffer) - 1, "%d", params[2]);
|
||||
ke::SafeSprintf(CVarTempBuffer, sizeof(CVarTempBuffer), "%d", params[2]);
|
||||
CVAR_DIRECTSET(ptr, &CVarTempBuffer[0]);
|
||||
|
||||
return 1;
|
||||
|
@ -673,7 +673,7 @@ reswitch:
|
||||
if (!def)
|
||||
{
|
||||
static char buf[255];
|
||||
ke::SafeSprintf(buf, sizeof(buf) - 1, "ML_NOTFOUND: %s", key);
|
||||
ke::SafeSprintf(buf, sizeof(buf), "ML_NOTFOUND: %s", key);
|
||||
def = buf;
|
||||
}
|
||||
size_t written = atcprintf(buf_p, llen, def, amx, params, &arg);
|
||||
|
@ -97,7 +97,7 @@ size_t AddLibrariesFromString(const char *name, LibType type, LibSource src, voi
|
||||
char *ptr, *p, s;
|
||||
size_t count = 0;
|
||||
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "%s", name);
|
||||
ke::SafeSprintf(buffer, sizeof(buffer), "%s", name);
|
||||
|
||||
ptr = buffer;
|
||||
p = buffer;
|
||||
|
@ -226,7 +226,7 @@ void LoadExtraPluginsToPCALM(const char *initialdir)
|
||||
while (!files.empty())
|
||||
{
|
||||
ke::AString *pString = files.front();
|
||||
ke::SafeSprintf(path, sizeof(path)-1, "%s/%s",
|
||||
ke::SafeSprintf(path, sizeof(path), "%s/%s",
|
||||
initialdir,
|
||||
pString->chars());
|
||||
g_plugins.CALMFromFile(path);
|
||||
@ -243,7 +243,7 @@ void LoadExtraPluginsFromDir(const char *initialdir)
|
||||
while (!files.empty())
|
||||
{
|
||||
ke::AString *pString = files.front();
|
||||
ke::SafeSprintf(path, sizeof(path)-1, "%s/%s",
|
||||
ke::SafeSprintf(path, sizeof(path), "%s/%s",
|
||||
initialdir,
|
||||
pString->chars());
|
||||
g_plugins.loadPluginsFromFile(path);
|
||||
|
@ -670,7 +670,7 @@ char* build_pathname(const char *fmt, ...)
|
||||
{
|
||||
static char string[256];
|
||||
int b;
|
||||
int a = b = ke::SafeSprintf(string, 255, "%s%c", g_mod_name.chars(), PATH_SEP_CHAR);
|
||||
int a = b = ke::SafeSprintf(string, sizeof(string), "%s%c", g_mod_name.chars(), PATH_SEP_CHAR);
|
||||
|
||||
va_list argptr;
|
||||
va_start(argptr, fmt);
|
||||
|
@ -289,7 +289,7 @@ bool Menu::Display(int player, page_t page)
|
||||
return false;
|
||||
|
||||
static char buffer[2048];
|
||||
int len = ke::SafeSprintf(buffer, sizeof(buffer)-1, "%s", str);
|
||||
int len = ke::SafeSprintf(buffer, sizeof(buffer), "%s", str);
|
||||
|
||||
CPlayer *pPlayer = GET_PLAYER_POINTER_I(player);
|
||||
|
||||
@ -342,14 +342,14 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||
if (items_per_page && (pages != 1))
|
||||
{
|
||||
if (m_AutoColors)
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "\\y%s %d/%d\n\\w\n", m_Title.chars(), page + 1, pages);
|
||||
ke::SafeSprintf(buffer, sizeof(buffer), "\\y%s %d/%d\n\\w\n", m_Title.chars(), page + 1, pages);
|
||||
else
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "%s %d/%d\n\n", m_Title.chars(), page + 1, pages);
|
||||
ke::SafeSprintf(buffer, sizeof(buffer), "%s %d/%d\n\n", m_Title.chars(), page + 1, pages);
|
||||
} else {
|
||||
if (m_AutoColors)
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "\\y%s\n\\w\n", m_Title.chars());
|
||||
ke::SafeSprintf(buffer, sizeof(buffer), "\\y%s\n\\w\n", m_Title.chars());
|
||||
else
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "%s\n\n", m_Title.chars());
|
||||
ke::SafeSprintf(buffer, sizeof(buffer), "%s\n\n", m_Title.chars());
|
||||
}
|
||||
|
||||
m_Text = m_Text + buffer;
|
||||
@ -446,22 +446,22 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||
|
||||
if (pItem->isBlank)
|
||||
{
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "%s\n", pItem->name.chars());
|
||||
ke::SafeSprintf(buffer, sizeof(buffer), "%s\n", pItem->name.chars());
|
||||
}
|
||||
else if (enabled)
|
||||
{
|
||||
if (m_AutoColors)
|
||||
{
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "%s%d.\\w %s\n", m_ItemColor.chars(),option_display, pItem->name.chars());
|
||||
ke::SafeSprintf(buffer, sizeof(buffer), "%s%d.\\w %s\n", m_ItemColor.chars(),option_display, pItem->name.chars());
|
||||
} else {
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "%d. %s\n", option_display, pItem->name.chars());
|
||||
ke::SafeSprintf(buffer, sizeof(buffer), "%d. %s\n", option_display, pItem->name.chars());
|
||||
}
|
||||
} else {
|
||||
if (m_AutoColors)
|
||||
{
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "\\d%d. %s\n\\w", option_display, pItem->name.chars());
|
||||
ke::SafeSprintf(buffer, sizeof(buffer), "\\d%d. %s\n\\w", option_display, pItem->name.chars());
|
||||
} else {
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "#. %s\n", pItem->name.chars());
|
||||
ke::SafeSprintf(buffer, sizeof(buffer), "#. %s\n", pItem->name.chars());
|
||||
}
|
||||
}
|
||||
slots++;
|
||||
@ -504,14 +504,14 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||
if (m_AutoColors)
|
||||
{
|
||||
ke::SafeSprintf(buffer,
|
||||
sizeof(buffer)-1,
|
||||
sizeof(buffer),
|
||||
"%s%d. \\w%s\n",
|
||||
m_ItemColor.chars(),
|
||||
option == 10 ? 0 : option,
|
||||
m_OptNames[abs(MENU_BACK)].chars());
|
||||
} else {
|
||||
ke::SafeSprintf(buffer,
|
||||
sizeof(buffer)-1,
|
||||
sizeof(buffer),
|
||||
"%d. %s\n",
|
||||
option == 10 ? 0 : option,
|
||||
m_OptNames[abs(MENU_BACK)].chars());
|
||||
@ -521,12 +521,12 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||
if (m_AutoColors)
|
||||
{
|
||||
ke::SafeSprintf(buffer,
|
||||
sizeof(buffer)-1,
|
||||
sizeof(buffer),
|
||||
"\\d%d. %s\n\\w",
|
||||
option == 10 ? 0 : option,
|
||||
m_OptNames[abs(MENU_BACK)].chars());
|
||||
} else {
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "#. %s\n", m_OptNames[abs(MENU_BACK)].chars());
|
||||
ke::SafeSprintf(buffer, sizeof(buffer), "#. %s\n", m_OptNames[abs(MENU_BACK)].chars());
|
||||
}
|
||||
}
|
||||
m_Text = m_Text + buffer;
|
||||
@ -537,14 +537,14 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||
if (m_AutoColors)
|
||||
{
|
||||
ke::SafeSprintf(buffer,
|
||||
sizeof(buffer)-1,
|
||||
sizeof(buffer),
|
||||
"%s%d. \\w%s\n",
|
||||
m_ItemColor.chars(),
|
||||
option == 10 ? 0 : option,
|
||||
m_OptNames[abs(MENU_MORE)].chars());
|
||||
} else {
|
||||
ke::SafeSprintf(buffer,
|
||||
sizeof(buffer)-1,
|
||||
sizeof(buffer),
|
||||
"%d. %s\n",
|
||||
option == 10 ? 0 : option,
|
||||
m_OptNames[abs(MENU_MORE)].chars());
|
||||
@ -554,12 +554,12 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||
if (m_AutoColors)
|
||||
{
|
||||
ke::SafeSprintf(buffer,
|
||||
sizeof(buffer)-1,
|
||||
sizeof(buffer),
|
||||
"\\d%d. %s\n\\w",
|
||||
option == 10 ? 0 : option,
|
||||
m_OptNames[abs(MENU_MORE)].chars());
|
||||
} else {
|
||||
ke::SafeSprintf(buffer, sizeof(buffer)-1, "#. %s\n", m_OptNames[abs(MENU_MORE)].chars());
|
||||
ke::SafeSprintf(buffer, sizeof(buffer), "#. %s\n", m_OptNames[abs(MENU_MORE)].chars());
|
||||
}
|
||||
}
|
||||
m_Text = m_Text + buffer;
|
||||
@ -579,14 +579,14 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
|
||||
if (m_AutoColors)
|
||||
{
|
||||
ke::SafeSprintf(buffer,
|
||||
sizeof(buffer)-1,
|
||||
sizeof(buffer),
|
||||
"%s%d. \\w%s\n",
|
||||
m_ItemColor.chars(),
|
||||
option == 10 ? 0 : option,
|
||||
m_OptNames[abs(MENU_EXIT)].chars());
|
||||
} else {
|
||||
ke::SafeSprintf(buffer,
|
||||
sizeof(buffer)-1,
|
||||
sizeof(buffer),
|
||||
"%d. %s\n",
|
||||
option == 10 ? 0 : option,
|
||||
m_OptNames[abs(MENU_EXIT)].chars());
|
||||
|
@ -335,9 +335,7 @@ void UTIL_FakeClientCommand(edict_t *pEdict, const char *cmd, const char *arg1,
|
||||
g_fakecmd.argv[1] = arg1;
|
||||
g_fakecmd.argv[2] = arg2;
|
||||
// build argument line
|
||||
ke::SafeSprintf(g_fakecmd.args, 255, "%s %s", arg1, arg2);
|
||||
// if ke::SafeSprintf reached 255 chars limit, this will make sure there will be no access violation
|
||||
g_fakecmd.args[255] = 0;
|
||||
ke::SafeSprintf(g_fakecmd.args, sizeof(g_fakecmd.args), "%s %s", arg1, arg2);
|
||||
}
|
||||
else if (arg1)
|
||||
{ // only one argument passed
|
||||
@ -345,9 +343,7 @@ void UTIL_FakeClientCommand(edict_t *pEdict, const char *cmd, const char *arg1,
|
||||
// store argument
|
||||
g_fakecmd.argv[1] = arg1;
|
||||
// build argument line
|
||||
ke::SafeSprintf(g_fakecmd.args, 255, "%s", arg1);
|
||||
// if ke::SafeSprintf reached 255 chars limit, this will make sure there will be no access violation
|
||||
g_fakecmd.args[255] = 0;
|
||||
ke::SafeSprintf(g_fakecmd.args, sizeof(g_fakecmd.args), "%s", arg1);
|
||||
}
|
||||
else
|
||||
g_fakecmd.argc = 1; // no argmuents -> only one command
|
||||
|
Reference in New Issue
Block a user