$OpenBSD: patch-libgputils_gpwriteobj_c,v 1.1.1.1 2003/11/03 01:02:36 naddy Exp $
--- libgputils/gpwriteobj.c.orig	2003-10-14 23:02:28.000000000 +1000
+++ libgputils/gpwriteobj.c	2003-10-14 23:26:36.000000000 +1000
@@ -33,6 +33,7 @@ _gp_coffgen_addstring(char *name, char *
 {
   int nbytes;
   int offset;
+  size_t sizeof_name = strlen(name) + 1;
 
   assert(name != NULL);
 
@@ -40,11 +41,11 @@ _gp_coffgen_addstring(char *name, char *
   offset = nbytes = gp_getl32(&table[0]);
 
   /* check the length against the max string table size */
-  nbytes += strlen(name) + 1;
+  nbytes += sizeof_name;
   assert(!(nbytes > MAX_STRING_TABLE));
 
   /* copy the string to the table */
-  strcpy(&table[offset], name);
+  memmove(&table[offset], name, sizeof_name);
 
   /* write the new byte count */
   gp_putl32(&table[0], nbytes);
@@ -53,7 +54,7 @@ _gp_coffgen_addstring(char *name, char *
 }
 
 static void
-_gp_coffgen_addname(char *name, char *ptr, char *table)
+_gp_coffgen_addname(char *name, char *ptr, size_t sizeof_ptr, char *table)
 {
   int length;
   int offset;
@@ -65,7 +66,7 @@ _gp_coffgen_addname(char *name, char *pt
 
   if (length < 9) {
     /* The string will fit in the structure. */
-    strncpy(ptr, name, 8);
+    strlcpy(ptr, name, sizeof_ptr);
   } else {
     offset = _gp_coffgen_addstring(name, table);
  
@@ -118,7 +119,7 @@ _gp_coffgen_write_scnhdr(gp_section_type
 {
   char name[8];
   
-  _gp_coffgen_addname(section->name, &name[0], table);
+  _gp_coffgen_addname(section->name, name, sizeof(name), table);
   gp_fputvar(&name[0], 8, fp);
   gp_fputl32(section->address, fp);
   gp_fputl32(section->address, fp);
@@ -266,7 +267,7 @@ _gp_coffgen_write_symbols(gp_object_type
 
   while(current != NULL) {
 
-    _gp_coffgen_addname(current->name, &name[0], table);
+    _gp_coffgen_addname(current->name, name, sizeof(name), table);
 
     gp_fputvar(&name[0], 8, fp);
     gp_fputl32(current->value, fp);
