diff options
author | Simon Howard | 2014-03-29 21:23:29 -0400 |
---|---|---|
committer | Simon Howard | 2014-03-29 21:23:29 -0400 |
commit | 040ca1cfb5a3e1be7d05bcd90eaa4f01fb68437a (patch) | |
tree | a18e508d59f858f2d4bfda860a299a8f271a080a /src/doom/d_main.c | |
parent | e76b5678bfcac6fc7a42b2f581192ae08831728e (diff) | |
download | chocolate-doom-040ca1cfb5a3e1be7d05bcd90eaa4f01fb68437a.tar.gz chocolate-doom-040ca1cfb5a3e1be7d05bcd90eaa4f01fb68437a.tar.bz2 chocolate-doom-040ca1cfb5a3e1be7d05bcd90eaa4f01fb68437a.zip |
doom: Eliminate use of unsafe string functions.
Eliminate use of strcpy, strcat, strncpy, and use the new safe
alternatives.
Diffstat (limited to 'src/doom/d_main.c')
-rw-r--r-- | src/doom/d_main.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/doom/d_main.c b/src/doom/d_main.c index 60d93696..17dbd170 100644 --- a/src/doom/d_main.c +++ b/src/doom/d_main.c @@ -659,22 +659,28 @@ static char *GetGameName(char *gamename) if (deh_sub != banners[i]) { + size_t gamename_size; int version; // Has been replaced. // We need to expand via printf to include the Doom version number // We also need to cut off spaces to get the basic name - gamename = Z_Malloc(strlen(deh_sub) + 10, PU_STATIC, 0); + gamename_size = strlen(deh_sub) + 10; + gamename = Z_Malloc(gamename_size, PU_STATIC, 0); version = G_VanillaVersionCode(); sprintf(gamename, deh_sub, version / 100, version % 100); while (gamename[0] != '\0' && isspace(gamename[0])) - strcpy(gamename, gamename+1); + { + memmove(gamename, gamename + 1, gamename_size - 1); + } while (gamename[0] != '\0' && isspace(gamename[strlen(gamename)-1])) + { gamename[strlen(gamename) - 1] = '\0'; - + } + return gamename; } } |