diff options
author | Simon Howard | 2014-03-29 21:58:47 -0400 |
---|---|---|
committer | Simon Howard | 2014-03-29 21:58:47 -0400 |
commit | 1990930eb1cae6e60296ba6c85a946b063624f48 (patch) | |
tree | b40fce4b2ad83906c0a664de09519855dc8b3f57 | |
parent | 6c24da0dad1477fb0585eefac19349dd60f37c3f (diff) | |
download | chocolate-doom-1990930eb1cae6e60296ba6c85a946b063624f48.tar.gz chocolate-doom-1990930eb1cae6e60296ba6c85a946b063624f48.tar.bz2 chocolate-doom-1990930eb1cae6e60296ba6c85a946b063624f48.zip |
common: Eliminate use of unsafe string functions.
Remove some remaining uses of strncpy() and use M_StringCopy() instead.
-rw-r--r-- | src/net_server.c | 17 | ||||
-rw-r--r-- | src/w_checksum.c | 4 |
2 files changed, 9 insertions, 12 deletions
diff --git a/src/net_server.c b/src/net_server.c index a2868370..c22d57e9 100644 --- a/src/net_server.c +++ b/src/net_server.c @@ -32,8 +32,8 @@ #include "d_mode.h" #include "i_system.h" #include "i_timer.h" - #include "m_argv.h" +#include "m_misc.h" #include "net_client.h" #include "net_common.h" @@ -427,15 +427,12 @@ static void NET_SV_SendWaitingData(net_client_t *client) for (i = 0; i < wait_data.num_players; ++i) { - strncpy(wait_data.player_names[i], - sv_players[i]->name, - MAXPLAYERNAME); - wait_data.player_names[i][MAXPLAYERNAME-1] = '\0'; - - strncpy(wait_data.player_addrs[i], - NET_AddrToString(sv_players[i]->addr), - MAXPLAYERNAME); - wait_data.player_addrs[i][MAXPLAYERNAME-1] = '\0'; + M_StringCopy(wait_data.player_names[i], + sv_players[i]->name, + MAXPLAYERNAME); + M_StringCopy(wait_data.player_addrs[i], + NET_AddrToString(sv_players[i]->addr), + MAXPLAYERNAME); } // Construct packet: diff --git a/src/w_checksum.c b/src/w_checksum.c index 28451fda..c3a9a888 100644 --- a/src/w_checksum.c +++ b/src/w_checksum.c @@ -27,6 +27,7 @@ #include <stdlib.h> #include <string.h> +#include "m_misc.h" #include "sha1.h" #include "w_checksum.h" #include "w_wad.h" @@ -64,8 +65,7 @@ static void ChecksumAddLump(sha1_context_t *sha1_context, lumpinfo_t *lump) { char buf[9]; - strncpy(buf, lump->name, 8); - buf[8] = '\0'; + M_StringCopy(buf, lump->name, sizeof(buf)); SHA1_UpdateString(sha1_context, buf); SHA1_UpdateInt32(sha1_context, GetFileNumber(lump->wad_file)); SHA1_UpdateInt32(sha1_context, lump->position); |