mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-10 14:52:00 +00:00
Fix strncpy usage in botlib
All usage of strncpy in botlib should now either set string terminator or use Q_strncpyz.
This commit is contained in:
parent
8956ab41dd
commit
c12b81a273
8 changed files with 13 additions and 14 deletions
|
@ -238,7 +238,7 @@ int AAS_LoadFiles(const char *mapname)
|
|||
return errnum;
|
||||
|
||||
botimport.Print(PRT_MESSAGE, "loaded %s\n", aasfile);
|
||||
strncpy(aasworld.filename, aasfile, MAX_PATH);
|
||||
Q_strncpyz(aasworld.filename, aasfile, sizeof(aasworld.filename));
|
||||
return BLERR_NOERROR;
|
||||
} //end of the function AAS_LoadFiles
|
||||
//===========================================================================
|
||||
|
|
|
@ -342,7 +342,7 @@ void BotQueueConsoleMessage(int chatstate, int type, char *message)
|
|||
m->handle = cs->handle;
|
||||
m->time = AAS_Time();
|
||||
m->type = type;
|
||||
strncpy(m->message, message, MAX_MESSAGE_SIZE);
|
||||
Q_strncpyz(m->message, message, MAX_MESSAGE_SIZE);
|
||||
m->next = NULL;
|
||||
if (cs->lastmessage)
|
||||
{
|
||||
|
@ -1456,7 +1456,7 @@ int BotFindMatch(char *str, bot_match_t *match, unsigned long int context)
|
|||
int i;
|
||||
bot_matchtemplate_t *ms;
|
||||
|
||||
strncpy(match->string, str, MAX_MESSAGE_SIZE);
|
||||
Q_strncpyz(match->string, str, MAX_MESSAGE_SIZE);
|
||||
//remove any trailing enters
|
||||
while(strlen(match->string) &&
|
||||
match->string[strlen(match->string)-1] == '\n')
|
||||
|
@ -2114,7 +2114,7 @@ bot_chat_t *BotLoadInitialChat(char *chatfile, char *chatname)
|
|||
if (pass && ptr)
|
||||
{
|
||||
chattype = (bot_chattype_t *) ptr;
|
||||
strncpy(chattype->name, token.string, MAX_CHATTYPE_NAME);
|
||||
Q_strncpyz(chattype->name, token.string, MAX_CHATTYPE_NAME);
|
||||
chattype->firstchatmessage = NULL;
|
||||
//add the chat type to the chat
|
||||
chattype->next = chat->types;
|
||||
|
@ -2884,7 +2884,7 @@ void BotSetChatName(int chatstate, char *name, int client)
|
|||
if (!cs) return;
|
||||
cs->client = client;
|
||||
Com_Memset(cs->name, 0, sizeof(cs->name));
|
||||
strncpy(cs->name, name, sizeof(cs->name));
|
||||
strncpy(cs->name, name, sizeof(cs->name)-1);
|
||||
cs->name[sizeof(cs->name)-1] = '\0';
|
||||
} //end of the function BotSetChatName
|
||||
//===========================================================================
|
||||
|
|
|
@ -281,7 +281,7 @@ itemconfig_t *LoadItemConfig(char *filename)
|
|||
LibVarSet( "max_iteminfo", "256" );
|
||||
}
|
||||
|
||||
strncpy( path, filename, MAX_PATH );
|
||||
Q_strncpyz(path, filename, sizeof(path));
|
||||
PC_SetBaseFolder(BOTFILESBASEFOLDER);
|
||||
source = LoadSourceFile( path );
|
||||
if( !source ) {
|
||||
|
@ -314,7 +314,7 @@ itemconfig_t *LoadItemConfig(char *filename)
|
|||
return NULL;
|
||||
} //end if
|
||||
StripDoubleQuotes(token.string);
|
||||
strncpy(ii->classname, token.string, sizeof(ii->classname)-1);
|
||||
Q_strncpyz(ii->classname, token.string, sizeof(ii->classname));
|
||||
if (!ReadStructure(source, &iteminfo_struct, (char *) ii))
|
||||
{
|
||||
FreeMemory(ic);
|
||||
|
@ -685,8 +685,7 @@ void BotGoalName(int number, char *name, int size)
|
|||
{
|
||||
if (li->number == number)
|
||||
{
|
||||
strncpy(name, itemconfig->iteminfo[li->iteminfo].name, size-1);
|
||||
name[size-1] = '\0';
|
||||
Q_strncpyz(name, itemconfig->iteminfo[li->iteminfo].name, size);
|
||||
return;
|
||||
} //end for
|
||||
} //end for
|
||||
|
|
|
@ -219,7 +219,7 @@ weaponconfig_t *LoadWeaponConfig(char *filename)
|
|||
max_projectileinfo = 32;
|
||||
LibVarSet("max_projectileinfo", "32");
|
||||
} //end if
|
||||
strncpy(path, filename, MAX_PATH);
|
||||
Q_strncpyz(path, filename, sizeof(path));
|
||||
PC_SetBaseFolder(BOTFILESBASEFOLDER);
|
||||
source = LoadSourceFile(path);
|
||||
if (!source)
|
||||
|
|
|
@ -75,7 +75,7 @@ void Log_Open(char *filename)
|
|||
botimport.Print(PRT_ERROR, "can't open the log file %s\n", filename);
|
||||
return;
|
||||
} //end if
|
||||
strncpy(logfile.filename, filename, MAX_LOGFILENAMESIZE);
|
||||
Q_strncpyz(logfile.filename, filename, MAX_LOGFILENAMESIZE);
|
||||
botimport.Print(PRT_MESSAGE, "Opened log %s\n", logfile.filename);
|
||||
} //end of the function Log_Create
|
||||
//===========================================================================
|
||||
|
|
|
@ -1323,7 +1323,7 @@ define_t *PC_DefineFromString(char *string)
|
|||
script = LoadScriptMemory(string, strlen(string), "*extern");
|
||||
//create a new source
|
||||
Com_Memset(&src, 0, sizeof(source_t));
|
||||
strncpy(src.filename, "*extern", sizeof(src.filename) - 1);
|
||||
Q_strncpyz(src.filename, "*extern", sizeof(src.filename));
|
||||
src.scriptstack = script;
|
||||
#if DEFINEHASHING
|
||||
src.definehash = GetClearedMemory(DEFINEHASHSIZE * sizeof(define_t *));
|
||||
|
|
|
@ -804,7 +804,7 @@ int PS_ReadPunctuation(script_t *script, token_t *token)
|
|||
//if the script contains the punctuation
|
||||
if (!strncmp(script->script_p, p, len))
|
||||
{
|
||||
strncpy(token->string, p, MAX_TOKEN);
|
||||
Q_strncpyz(token->string, p, MAX_TOKEN);
|
||||
script->script_p += len;
|
||||
token->type = TT_PUNCTUATION;
|
||||
//sub type is the number of the punctuation
|
||||
|
|
|
@ -221,7 +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);
|
||||
strncpy((char *) p, token.string, MAX_STRINGFIELD-1);
|
||||
//make sure the string is closed with a zero
|
||||
((char *)p)[MAX_STRINGFIELD-1] = '\0';
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue