$OpenBSD: patch-src_edittools_c,v 1.2 2004/08/08 14:02:11 sturm Exp $
--- src/edittools.c.orig	Wed Jun 23 17:38:13 2004
+++ src/edittools.c	Mon Aug  2 13:30:34 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))
          {
@@ -402,8 +402,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;
@@ -1330,6 +1330,7 @@ return true;
 int ReplaceEditLineWith (char *string)
 
 { char *sp;
+  size_t splen;
 
 if (strcmp(string,CURRENTLINEPTR->name) == 0)
    {
@@ -1337,14 +1338,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++;
@@ -2050,10 +2052,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 */
  
