fec479ae4c
problem but is not used anywhere and will probably be removed from cfengine from maintainer William Yodlowsky <bsd at openbsd.rutgers.edu>
120 lines
3.6 KiB
Plaintext
120 lines
3.6 KiB
Plaintext
$OpenBSD: patch-src_edittools_c,v 1.5 2005/10/27 21:47:28 sturm Exp $
|
|
--- src/edittools.c.orig Thu Jun 30 06:05:48 2005
|
|
+++ src/edittools.c Fri Oct 21 16:35:55 2005
|
|
@@ -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))
|
|
{
|
|
@@ -406,8 +406,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;
|
|
@@ -1355,6 +1355,7 @@ return true;
|
|
int ReplaceEditLineWith (char *string)
|
|
|
|
{ char *sp;
|
|
+ size_t splen;
|
|
|
|
if (strcmp(string,CURRENTLINEPTR->name) == 0)
|
|
{
|
|
@@ -1362,14 +1363,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++;
|
|
@@ -2078,10 +2080,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 */
|
|
|