Fix up misc string handling in game code.

Replace strcpy/strcat in p_client.c->ClientUserinfoChanged() and q_shared.c->COM_DefaultExtension().
This commit is contained in:
Knightmare66 2019-03-28 21:37:34 -04:00
parent fcfe248915
commit 5fef64230e
4 changed files with 7 additions and 5 deletions

View file

@ -36,7 +36,7 @@ extern int LittleLong ( int l ) ;
extern int BigLong ( int l ) ;
extern short LittleShort ( short l ) ;
extern short BigShort ( short l ) ;
extern void COM_DefaultExtension ( char * path , char * extension ) ;
extern void COM_DefaultExtension ( char * path , size_t pathSize , char * extension ) ;
extern void COM_FilePath ( char * in , char * out ) ;
extern void COM_FileBase ( char * in , char * out ) ;
extern char * COM_FileExtension ( char * in ) ;

View file

@ -2188,7 +2188,8 @@ void ClientUserinfoChanged (edict_t *ent, char *userinfo)
// check for malformed or illegal info strings
if (!Info_Validate(userinfo))
{
strcpy (userinfo, "\\name\\badinfo\\skin\\male/grunt");
// strcpy (userinfo, "\\name\\badinfo\\skin\\male/grunt");
Q_strncpyz (userinfo, "\\name\\badinfo\\skin\\male/grunt", MAX_INFO_STRING); // userinfo is always length of MAX_INFO_STRING
}
// set name

View file

@ -1079,7 +1079,7 @@ void COM_FilePath (char *in, char *out)
COM_DefaultExtension
==================
*/
void COM_DefaultExtension (char *path, char *extension)
void COM_DefaultExtension (char *path, size_t pathSize, char *extension)
{
char *src;
//
@ -1095,7 +1095,8 @@ void COM_DefaultExtension (char *path, char *extension)
src--;
}
strcat (path, extension);
// strncat (path, extension);
Q_strncatz(path, extension, pathSize);
}
/*

View file

@ -398,7 +398,7 @@ void COM_StripExtension (char *in, char *out);
void COM_FileBase (char *in, char *out);
void COM_FilePath (char *in, char *out);
char *COM_FileExtension (char *in);
void COM_DefaultExtension (char *path, char *extension);
void COM_DefaultExtension (char *path, size_t pathSize, char *extension);
char *COM_Parse (char **data_p);
// data is an in/out parm, returns a parsed out token