$OpenBSD: patch-src_edittools_c,v 1.3 2004/10/01 21:22:15 sturm Exp $
--- src/edittools.c.orig	Wed Aug 11 22:50:07 2004
+++ src/edittools.c	Fri Oct  1 23:14:47 2004
@@ -74,7 +74,7 @@ for (dirp = readdir(dirh); dirp != NULL;
       continue;
       }
 
-   strcpy(pcwd,name);                                   /* Assemble pathname */
+   (void)strlcpy(pcwd,name,sizeof(pcwd));                                   /* Assemble pathname */
    AddSlash(pcwd);
 
    if (BufferOverflow(pcwd,dirp->d_name))
@@ -82,7 +82,7 @@ for (dirp = readdir(dirh); dirp != NULL;
       return true;
       }
 
-   strcat(pcwd,dirp->d_name);
+   (void)strlcat(pcwd,dirp->d_name,sizeof(pcwd));
 
    if (!FileObjectFilter(pcwd,&statbuf,ptr->filters,editfiles))
       {
@@ -190,9 +190,9 @@ for (ip = VMOUNTLIST; ip != NULL; ip=ip-
          continue;
          }
 
-      strcpy(homedir,ip->name);
+      (void)strlcpy(homedir,ip->name,sizeof(homedir));
       AddSlash(homedir);
-      strcat(homedir,dirp->d_name);
+      (void)strlcat(homedir,dirp->d_name,sizeof(homedir));
 
       if (! IsHomeDir(homedir))
          {
@@ -213,12 +213,12 @@ for (ip = VMOUNTLIST; ip != NULL; ip=ip-
             continue;
             }
          
-         strcpy(dest,homedir);
+         (void)strlcpy(dest,homedir,sizeof(dest));
          AddSlash(dest);
-         strcat(dest,dirp2->d_name);
+         (void)strlcat(dest,dirp2->d_name,sizeof(dest));
          AddSlash(dest);
          sp = ptr->fname + strlen("home/");
-         strcat(dest,sp);
+         (void)strlcat(dest,sp,sizeof(dest));
          
          if (stat(dest,&statbuf))
             {
@@ -276,7 +276,7 @@ if (lstat(filename,&statbuf) != -1)
       
       if (linkname[0] != '/')
          {
-         strcpy(realname,filename);
+         (void)strlcpy(realname,filename,sizeof(realname));
          ChopLastNode(realname);
          AddSlash(realname);
          }
@@ -299,7 +299,7 @@ if (lstat(filename,&statbuf) != -1)
             }
          }
       
-      strcat(realname,linkname);
+      (void)strlcat(realname,linkname,sizeof(realname));
       
       if (!FileObjectFilter(realname,&statbuf2,ptr->filters,editfiles))
          {
@@ -401,8 +401,8 @@ NUMBEROFEDITS = 0;
 EDITVERBOSE = VERBOSE;
 CURRENTLINENUMBER = 1;
 CURRENTLINEPTR = filestart;
-strcpy(COMMENTSTART,"# ");
-strcpy(COMMENTEND,"");
+(void)strlcpy(COMMENTSTART,"# ",CF_MAXVARSIZE);
+(void)strlcpy(COMMENTEND,"",CF_MAXVARSIZE);
 EDITGROUPLEVEL = 0;
 SEARCHREPLACELEVEL = 0;
 FOREACHLEVEL = 0;
@@ -1329,6 +1329,7 @@ return true;
 int ReplaceEditLineWith (char *string)
 
 { char *sp;
+  size_t splen;
 
 if (strcmp(string,CURRENTLINEPTR->name) == 0)
    {
@@ -1336,14 +1337,15 @@ if (strcmp(string,CURRENTLINEPTR->name) 
    return true;
    }
 
-if ((sp = malloc(strlen(string)+1)) == NULL)
+splen = strlen(string)+1;
+if ((sp = malloc(splen)) == NULL)
    {
    printf("Memory allocation failed in ReplaceEditLineWith, aborting edit.\n");
    return false;
    }
 
 EditVerbose("Replacing line %d with %10s...\n",CURRENTLINENUMBER,string);
-strcpy(sp,string);
+(void)strlcpy(sp,string,splen);
 free (CURRENTLINEPTR->name);
 CURRENTLINEPTR->name = sp;
 NUMBEROFEDITS++;
@@ -2048,10 +2050,10 @@ int SaveBinaryFile(char *file,off_t size
 Debug("SaveBinaryFile(%s,%d)\n",file,size);
 Verbose("Saving %s\n",file);
  
-strcpy(new,file);
-strcat(new,CF_NEW);
-strcpy(backup,file);
-strcat(backup,CF_EDITED);
+(void)strlcpy(new,file,sizeof(new));
+(void)strlcat(new,CF_NEW,sizeof(new));
+(void)strlcpy(backup,file,sizeof(backup));
+(void)strlcat(backup,CF_EDITED,sizeof(backup));
  
 unlink(new);  /* To avoid link attacks */
  
