foxygit / doom Log in
commit 724c4ad7a4f2a541eff157d9196b3835eb4bc8d8
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Sun Mar 30 00:27:11 2014 -0400
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Sun Mar 30 00:27:11 2014 -0400

    dehacked: Eliminate some more uses of strncpy().

    Use M_StringCopy() instead of strncpy() in the Dehacked code.
---
 src/deh_io.c      | 4 ++--
 src/deh_mapping.c | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/deh_io.c b/src/deh_io.c
index 83609068..37fc0a15 100644
--- a/src/deh_io.c
+++ b/src/deh_io.c
@@ -30,6 +30,7 @@
 #include <string.h>

 #include "i_system.h"
+#include "m_misc.h"
 #include "w_wad.h"
 #include "z_zone.h"

@@ -127,8 +128,7 @@ deh_context_t *DEH_OpenLump(int lumpnum)
     context->input_buffer_pos = 0;

     context->filename = malloc(9);
-    strncpy(context->filename, lumpinfo[lumpnum].name, 8);
-    context->filename[8] = '\0';
+    M_StringCopy(context->filename, lumpinfo[lumpnum].name, 9);

     return context;
 }
diff --git a/src/deh_mapping.c b/src/deh_mapping.c
index 85c675b4..eff9a7ce 100644
--- a/src/deh_mapping.c
+++ b/src/deh_mapping.c
@@ -32,6 +32,8 @@

 #include "doomtype.h"
 #include "i_system.h"
+#include "m_misc.h"
+
 #include "deh_mapping.h"

 static deh_mapping_entry_t *GetMappingEntryByName(deh_context_t *context,
@@ -158,7 +160,7 @@ boolean DEH_SetStringMapping(deh_context_t *context, deh_mapping_t *mapping,

     // Copy value into field:

-    strncpy(location, value, entry->size);
+    M_StringCopy(location, value, entry->size);

     return true;
 }