Replace strncpy usage with Q_strncpyz
This commit is contained in:
1 parent
c8553223ec
commit
1132abe3dc
10 files changed
+16
-34
No files matched your search
@@ -286,8 +286,7 @@ int AAS_ValueForBSPEpairKey(int ent, char *key, char *value, int size)
|
||||
{
|
||||
if (!strcmp(epair->key, key))
|
||||
{
|
||||
strncpy(value, epair->value, size-1);
|
||||
value[size-1] = '\0';
|
||||
Q_strncpyz(value, epair->value, size);
|
||||
return qtrue;
|
||||
} //end if
|
||||
} //end for
|
||||
|
||||
@@ -758,8 +758,7 @@ void Characteristic_String(int character, int index, char *buf, int size)
|
||||
//an integer will be converted to a float
|
||||
if (ch->c[index].type == CT_STRING)
|
||||
{
|
||||
strncpy(buf, ch->c[index].value.string, size-1);
|
||||
buf[size-1] = '\0';
|
||||
Q_strncpyz(buf, ch->c[index].value.string, size);
|
||||
} //end if
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1499,8 +1499,7 @@ void BotMatchVariable(bot_match_t *match, int variable, char *buf, int size)
|
||||
if (match->variables[variable].length < size)
|
||||
size = match->variables[variable].length+1;
|
||||
assert( match->variables[variable].offset >= 0 );
|
||||
strncpy(buf, &match->string[ (int) match->variables[variable].offset], size-1);
|
||||
buf[size-1] = '\0';
|
||||
Q_strncpyz(buf, &match->string[ (int) match->variables[variable].offset], size);
|
||||
} //end if
|
||||
else
|
||||
{
|
||||
@@ -2846,8 +2845,7 @@ void BotGetChatMessage(int chatstate, char *buf, int size)
|
||||
if (!cs) return;
|
||||
|
||||
BotRemoveTildes(cs->chatmessage);
|
||||
strncpy(buf, cs->chatmessage, size-1);
|
||||
buf[size-1] = '\0';
|
||||
Q_strncpyz(buf, cs->chatmessage, size);
|
||||
//clear the chat message from the state
|
||||
strcpy(cs->chatmessage, "");
|
||||
} //end of the function BotGetChatMessage
|
||||
@@ -2883,9 +2881,7 @@ void BotSetChatName(int chatstate, char *name, int client)
|
||||
cs = BotChatStateFromHandle(chatstate);
|
||||
if (!cs) return;
|
||||
cs->client = client;
|
||||
Com_Memset(cs->name, 0, sizeof(cs->name));
|
||||
strncpy(cs->name, name, sizeof(cs->name)-1);
|
||||
cs->name[sizeof(cs->name)-1] = '\0';
|
||||
Q_strncpyz(cs->name, name, sizeof(cs->name));
|
||||
} //end of the function BotSetChatName
|
||||
//===========================================================================
|
||||
//
|
||||
|
||||
@@ -235,8 +235,7 @@ int Export_BotLibVarGet(const char *var_name, char *value, int size)
|
||||
char *varvalue;
|
||||
|
||||
varvalue = LibVarGetString(var_name);
|
||||
strncpy(value, varvalue, size-1);
|
||||
value[size-1] = '\0';
|
||||
Q_strncpyz(value, varvalue, size);
|
||||
return BLERR_NOERROR;
|
||||
} //end of the function Export_BotLibVarGet
|
||||
//===========================================================================
|
||||
|
||||
@@ -221,9 +221,7 @@ int ReadString(source_t *source, fielddef_t *fd, void *p)
|
||||
//remove the double quotes
|
||||
StripDoubleQuotes(token.string);
|
||||
//copy the string
|
||||
strncpy((char *) p, token.string, MAX_STRINGFIELD-1);
|
||||
//make sure the string is closed with a zero
|
||||
((char *)p)[MAX_STRINGFIELD-1] = '\0';
|
||||
Q_strncpyz((char *) p, token.string, MAX_STRINGFIELD);
|
||||
//
|
||||
return 1;
|
||||
} //end of the function ReadString
|
||||
|
||||
Reference in new issue
Block a user