openbsd-ports/sysutils/cfengine/patches/patch-src_image_c
sturm fec479ae4c update to 2.1.16, removing sbin/vicf which seems to have a security
problem but is not used anywhere and will probably be removed from
cfengine

from maintainer William Yodlowsky <bsd at openbsd.rutgers.edu>
2005-10-27 21:47:28 +00:00

181 lines
5.4 KiB
Plaintext

$OpenBSD: patch-src_image_c,v 1.5 2005/10/27 21:47:28 sturm Exp $
--- src/image.c.orig Thu Aug 18 12:02:59 2005
+++ src/image.c Fri Oct 21 16:35:55 2005
@@ -59,8 +59,8 @@ for (ip = VRPCPEERLIST; ip != NULL; ip =
}
else
{
- strcat(client,".");
- strcat(client,VDOMAIN);
+ (void)strlcat(client,".",sizeof(client));
+ (void)strlcat(client,VDOMAIN,sizeof(client));
}
Verbose(" Hailing remote peer %s\n",client);
@@ -81,8 +81,8 @@ for (ip = VRPCPEERLIST; ip != NULL; ip =
MINUSMASK = 0377;
IMAGEBACKUP = 'n';
ENCRYPT = 'y';
- strcpy(IMAGEACTION,"fix");
- strcpy(CLASSBUFF,"any");
+ (void)strlcpy(IMAGEACTION,"fix",CF_BUFSIZE);
+ (void)strlcpy(CLASSBUFF,"any",CF_BUFSIZE);
snprintf(VUIDNAME,CF_MAXVARSIZE,"%d",getuid());
snprintf(VGIDNAME,CF_MAXVARSIZE,"%d",getgid());
IMGCOMP = '>';
@@ -193,7 +193,7 @@ for (dirp = cfreaddir(dirh,ip); dirp !=
return;
}
- strcat(newto,dirp->d_name);
+ (void)strlcat(newto,dirp->d_name,sizeof(newto));
if (TRAVLINKS || ip->linktype == 'n')
{
@@ -364,9 +364,9 @@ for (itp = VMOUNTLIST; itp != NULL; itp=
continue;
}
- strcpy(homedir,itp->name);
+ (void)strlcpy(homedir,itp->name,sizeof(homedir));
AddSlash(homedir);
- strcat(homedir,dirp->d_name);
+ (void)strlcat(homedir,dirp->d_name,sizeof(homedir));
if (! IsHomeDir(homedir))
{
@@ -387,10 +387,10 @@ for (itp = VMOUNTLIST; itp != NULL; itp=
continue;
}
- strcpy(username,dirp2->d_name);
- strcpy(dest,homedir);
+ (void)strlcpy(username,dirp2->d_name,sizeof(username));
+ (void)strlcpy(dest,homedir,sizeof(dest));
AddSlash(dest);
- strcat(dest,dirp2->d_name);
+ (void)strlcat(dest,dirp2->d_name,sizeof(dest));
if (strlen(ip->destination) > 4)
{
@@ -403,7 +403,7 @@ for (itp = VMOUNTLIST; itp != NULL; itp=
}
else
{
- strcat(dest,(ip->destination)+strlen("home/"));
+ (void)strlcat(dest,(ip->destination)+strlen("home/"),sizeof(dest));
}
}
@@ -505,9 +505,9 @@ if ((ip->gid)->gid == (gid_t)-1)
if (S_ISDIR(sourcestatbuf.st_mode))
{
- strcpy(sourcedir,source);
+ (void)strlcpy(sourcedir,source,sizeof(sourcedir));
AddSlash(sourcedir);
- strcpy(destdir,destination);
+ (void)strlcpy(destdir,destination,sizeof(destdir));
AddSlash(destdir);
if ((dirh = cfopendir(sourcedir,ip)) == NULL)
@@ -539,22 +539,22 @@ if (S_ISDIR(sourcestatbuf.st_mode))
continue;
}
- strcpy(sourcefile, sourcedir);
+ (void)strlcpy(sourcefile, sourcedir, sizeof(sourcefile));
if (BufferOverflow(sourcefile,dirp->d_name))
{
FatalError("Culprit: CheckImage");
}
- strcat(sourcefile, dirp->d_name);
- strcpy(destfile, destdir);
+ (void)strlcat(sourcefile, dirp->d_name, sizeof(sourcefile));
+ (void)strlcpy(destfile, destdir, sizeof(destfile));
if (BufferOverflow(destfile,dirp->d_name))
{
FatalError("Culprit: CheckImage");
}
- strcat(destfile, dirp->d_name);
+ (void)strlcat(destfile, dirp->d_name, sizeof(destfile));
if (cflstat(sourcefile,&sourcestatbuf,ip) == -1)
{
@@ -575,8 +575,8 @@ if (S_ISDIR(sourcestatbuf.st_mode))
return;
}
- strcpy(sourcefile,source);
- strcpy(destfile,destination);
+ (void)strlcpy(sourcefile,source,sizeof(sourcefile));
+ (void)strlcpy(destfile,destination,sizeof(destfile));
ImageCopy(sourcefile,destfile,sourcestatbuf,ip);
(ip->uid)->uid = save_uid;
@@ -1011,7 +1011,7 @@ if (ip->linktype != 'n')
if (ip->linktype == 'a' && linkbuf[0] != '/') /* Not absolute path - must fix */
{
- strcpy(VBUFF,sourcefile);
+ (void)strlcpy(VBUFF,sourcefile,sizeof(VBUFF));
ChopLastNode(VBUFF);
AddSlash(VBUFF);
strncat(VBUFF,linkbuf,CF_BUFSIZE-1);
@@ -1399,7 +1399,7 @@ for (sp = ip->cache; sp != NULL; sp=sp->
else
{
memset(linkbuf,0,buffsize);
- strcpy(linkbuf,sp->cf_readlink);
+ (void)strlcpy(linkbuf,sp->cf_readlink,buffsize);
return 0;
}
}
@@ -1587,13 +1587,13 @@ if (BufferOverflow(dest,CF_NEW))
printf(" culprit: CopyReg\n");
return false;
}
-strcpy(new,dest);
+(void)strlcpy(new,dest,sizeof(new));
#ifdef DARWIN
}
#endif
-strcat(new,CF_NEW);
+(void)strlcat(new,CF_NEW,sizeof(new));
if (remote)
{
@@ -1632,22 +1632,22 @@ if (IMAGEBACKUP != 'n')
time_t STAMPNOW;
STAMPNOW = time((time_t *)NULL);
- sprintf(stamp, "_%d_%s", CFSTARTTIME, CanonifyName(ctime(&STAMPNOW)));
+ (void)snprintf(stamp, sizeof(stamp), "_%d_%s", CFSTARTTIME, CanonifyName(ctime(&STAMPNOW)));
if (BufferOverflow(dest,stamp))
{
printf(" culprit: CopyReg\n");
return false;
}
- strcpy(backup,dest);
+ (void)strlcpy(backup,dest,sizeof(backup));
if (IMAGEBACKUP == 's')
{
- strcat(backup,stamp);
+ (void)strlcat(backup,stamp,sizeof(backup));
}
/* rely on prior BufferOverflow() and on strlen(CF_SAVED) < CF_BUFFERMARGIN */
- strcat(backup,CF_SAVED);
+ (void)strlcat(backup,CF_SAVED,sizeof(backup));
if (IsItemIn(VREPOSLIST,backup))
{