openbsd-ports/sysutils/cfengine/patches/patch-src_link_c
sturm 221fb97e5d update to cfengine 2.1.7p1
from maintainer William Yodlowsky <bsd at openbsd.rutgers.edu>
2004-08-08 14:02:11 +00:00

328 lines
9.3 KiB
Plaintext

$OpenBSD: patch-src_link_c,v 1.2 2004/08/08 14:02:11 sturm Exp $
--- src/link.c.orig Sat Apr 17 10:11:06 2004
+++ src/link.c Mon Aug 2 13:30:35 2004
@@ -61,23 +61,23 @@ for (dirp = readdir(dirh); dirp != NULL;
continue;
}
- strcpy(pcwdto,to); /* Assemble pathnames */
+ (void)strlcpy(pcwdto,to,sizeof(pcwdto)); /* Assemble pathnames */
AddSlash(pcwdto);
if (BufferOverflow(pcwdto,dirp->d_name))
{
FatalError("Can't build filename in LinkChildFiles");
}
- strcat(pcwdto,dirp->d_name);
+ (void)strlcat(pcwdto,dirp->d_name,sizeof(pcwdto));
- strcpy(pcwdfrom,from);
+ (void)strlcpy(pcwdfrom,from,sizeof(pcwdfrom));
AddSlash(pcwdfrom);
if (BufferOverflow(pcwdfrom,dirp->d_name))
{
FatalError("Can't build filename in LinkChildFiles");
}
- strcat(pcwdfrom,dirp->d_name);
+ (void)strlcat(pcwdfrom,dirp->d_name,sizeof(pcwdfrom));
switch (type)
{
@@ -152,13 +152,13 @@ for (sp = path+strlen(path); sp != path-
if (MatchAFileSystem(server,lastlink))
{
- strcpy(odir,server);
+ (void)strlcpy(odir,server,sizeof(odir));
if (BufferOverflow(odir,relpath))
{
FatalError("culprit: LinkChildren()");
}
- strcat(odir,relpath);
+ (void)strlcat(odir,relpath,sizeof(odir));
if ((dirh = opendir(odir)) == NULL)
{
@@ -174,7 +174,7 @@ for (sp = path+strlen(path); sp != path-
continue;
}
- strcpy(from,path);
+ (void)strlcpy(from,path,sizeof(from));
AddSlash(from);
if (BufferOverflow(from,dirp->d_name))
@@ -182,9 +182,9 @@ for (sp = path+strlen(path); sp != path-
FatalError("culprit: LinkChildren()");
}
- strcat(from,dirp->d_name);
+ (void)strlcat(from,dirp->d_name,sizeof(from));
- strcpy(to,odir);
+ (void)strlcpy(to,odir,sizeof(to));
AddSlash(to);
if (BufferOverflow(to,dirp->d_name))
@@ -192,7 +192,7 @@ for (sp = path+strlen(path); sp != path-
FatalError("culprit: LinkChildren()");
}
- strcat(to,dirp->d_name);
+ (void)strlcat(to,dirp->d_name,sizeof(to));
Debug2("LinkChild from = %s to = %s\n",from,to);
@@ -299,9 +299,9 @@ for (dirp = readdir(dirh); dirp != NULL;
continue;
}
- strcpy(newfrom,from); /* Assemble pathname */
+ (void)strlcpy(newfrom,from,sizeof(newfrom)); /* Assemble pathname */
AddSlash(newfrom);
- strcpy(newto,to);
+ (void)strlcpy(newto,to,sizeof(newto));
AddSlash(newto);
if (BufferOverflow(newfrom,dirp->d_name))
@@ -310,7 +310,7 @@ for (dirp = readdir(dirh); dirp != NULL;
return true;
}
- strcat(newfrom,dirp->d_name);
+ (void)strlcat(newfrom,dirp->d_name,sizeof(newfrom));
if (BufferOverflow(newto,dirp->d_name))
{
@@ -318,7 +318,7 @@ for (dirp = readdir(dirh); dirp != NULL;
return true;
}
- strcat(newto,dirp->d_name);
+ (void)strlcat(newto,dirp->d_name,sizeof(newto));
if (TRAVLINKS)
{
@@ -403,7 +403,7 @@ memset(&ip,0,sizeof(ip));
if ((*to_tmp != '/') && (*to_tmp != '.')) /* links without a directory reference */
{
- strcpy(to,"./");
+ (void)strlcpy(to,"./",sizeof(to));
}
if (strlen(to_tmp)+3 > CF_BUFSIZE)
@@ -412,7 +412,7 @@ if (strlen(to_tmp)+3 > CF_BUFSIZE)
return false;
}
-strcat(to,to_tmp);
+(void)strlcat(to,to_tmp,sizeof(to));
Debug2("Linkfiles(%s,%s)\n",from,to);
@@ -461,12 +461,12 @@ if (IsWildItemIn(VCOPYLINKS,lastnode) ||
if (*to != '/') /* relative path, must still check if exists */
{
Debug("Relative link destination detected: %s\n",to);
- strcpy(absto,AbsLinkPath(from,to));
+ (void)strlcpy(absto,AbsLinkPath(from,to),sizeof(absto));
Debug("Absolute path to relative link = %s, from %s\n",absto,from);
}
else
{
- strcpy(absto,to);
+ (void)strlcpy(absto,to,sizeof(absto));
}
if (!nofile)
@@ -501,12 +501,12 @@ if (lstat(from,&buf) == 0)
}
saved[0] = '\0';
- strcpy(saved,from);
+ (void)strlcpy(saved,from,sizeof(saved));
- sprintf(stamp, "_%d_%s", CFSTARTTIME, CanonifyName(ctime(&STAMPNOW)));
- strcat(saved,stamp);
+ (void)snprintf(stamp, sizeof(stamp), "_%d_%s", CFSTARTTIME, CanonifyName(ctime(&STAMPNOW)));
+ (void)strlcat(saved,stamp,sizeof(saved));
- strcat(saved,CF_SAVED);
+ (void)strlcat(saved,CF_SAVED,sizeof(saved));
if (rename(from,saved) == -1)
{
@@ -532,13 +532,13 @@ if (lstat(from,&buf) == 0)
}
saved[0] = '\0';
- strcpy(saved,from);
+ (void)strlcpy(saved,from,sizeof(saved));
- sprintf(stamp, "_%d_%s", CFSTARTTIME, CanonifyName(ctime(&STAMPNOW)));
- strcat(saved,stamp);
+ (void)snprintf(stamp, sizeof(stamp), "_%d_%s", CFSTARTTIME, CanonifyName(ctime(&STAMPNOW)));
+ (void)strlcat(saved,stamp,sizeof(saved));
- strcat(saved,CF_SAVED);
- strcat(saved,".dir");
+ (void)strlcat(saved,CF_SAVED,sizeof(saved));
+ (void)strlcat(saved,".dir",sizeof(saved));
if (stat(saved,&savebuf) != -1)
{
@@ -693,7 +693,7 @@ Debug("LEVELS = %d\n",levels);
memset(buff,0,CF_BUFSIZE);
-strcat(buff,"./");
+(void)strlcat(buff,"./",sizeof(buff));
while(--levels > 0)
{
@@ -702,7 +702,7 @@ while(--levels > 0)
return false;
}
- strcat(buff,"../");
+ (void)strlcat(buff,"../",sizeof(buff));
}
if (BufferOverflow(buff,commonto))
@@ -710,7 +710,7 @@ if (BufferOverflow(buff,commonto))
return false;
}
-strcat(buff,commonto);
+(void)strlcat(buff,commonto,sizeof(buff));
return LinkFiles(from,buff,inclusions,exclusions,copy,nofile,ptr);
}
@@ -728,14 +728,14 @@ Debug2("AbsoluteLink(%s,%s)\n",from,to);
if (*to == '.')
{
- strcpy(LINKTO,from);
+ (void)strlcpy(LINKTO,from,CF_BUFSIZE);
ChopLastNode(LINKTO);
AddSlash(LINKTO);
- strcat(LINKTO,to);
+ (void)strlcat(LINKTO,to,CF_BUFSIZE);
}
else
{
- strcpy(LINKTO,to);
+ (void)strlcpy(LINKTO,to,CF_BUFSIZE);
}
CompressPath(absto,LINKTO);
@@ -758,7 +758,7 @@ if (!nofile)
}
else
{
- strcpy(expand,absto);
+ (void)strlcpy(expand,absto,sizeof(expand));
}
CompressPath(LINKTO,expand);
@@ -816,7 +816,7 @@ if (readlink(name,linkbuf,CF_BUFSIZE-1)
if (linkbuf[0] != '/')
{
- strcpy(linkpath,name); /* Get path to link */
+ (void)strlcpy(linkpath,name,sizeof(linkpath)); /* Get path to link */
for (sp = linkpath+strlen(linkpath); (*sp != '/') && (sp >= linkpath); sp-- )
{
@@ -824,7 +824,7 @@ if (linkbuf[0] != '/')
}
}
-strcat(linkpath,linkbuf);
+(void)strlcat(linkpath,linkbuf,sizeof(linkpath));
CompressPath(VBUFF,linkpath);
if (stat(VBUFF,&statbuf) == -1) /* link points nowhere */
@@ -962,12 +962,12 @@ if (ENFORCELINKS)
}
saved[0] = '\0';
- strcpy(saved,from);
+ (void)strlcpy(saved,from,sizeof(saved));
- sprintf(stamp, "_%d_%s", CFSTARTTIME, CanonifyName(ctime(&STAMPNOW)));
- strcat(saved,stamp);
+ (void)snprintf(stamp, sizeof(stamp), "_%d_%s", CFSTARTTIME, CanonifyName(ctime(&STAMPNOW)));
+ (void)strlcat(saved,stamp,sizeof(saved));
- strcat(saved,CF_SAVED);
+ (void)strlcat(saved,CF_SAVED,sizeof(saved));
if (rename(from,saved) == -1)
{
@@ -1059,10 +1059,10 @@ for (sp = from; *sp != '\0'; sp++)
}
else
{
- strcat(dest,"/");
+ (void)strlcat(dest,"/",CF_BUFSIZE);
}
- strcat(dest,node);
+ (void)strlcat(dest,node,CF_BUFSIZE);
if (lstat(dest,&statbuf) == -1) /* File doesn't exist so we can stop here */
{
@@ -1091,11 +1091,11 @@ for (sp = from; *sp != '\0'; sp++)
{
return false;
}
- strcat(dest,buff);
+ (void)strlcat(dest,buff,CF_BUFSIZE);
}
else if (buff[0] == '/')
{
- strcpy(dest,buff);
+ (void)strlcpy(dest,buff,CF_BUFSIZE);
DeleteSlash(dest);
if (strcmp(dest,from) == 0)
@@ -1113,7 +1113,7 @@ for (sp = from; *sp != '\0'; sp++)
{
ChopLastNode(dest);
AddSlash(dest);
- strcat(dest,buff);
+ (void)strlcat(dest,buff,CF_BUFSIZE);
DeleteSlash(dest);
if (strcmp(dest,from) == 0)
@@ -1153,7 +1153,7 @@ if (*relto == '/')
FatalError("");
}
-strcpy(destination,from); /* reuse to save stack space */
+(void)strlcpy(destination,from,sizeof(destination)); /* reuse to save stack space */
for (sp = relto; *sp != '\0'; sp++)
{
@@ -1181,14 +1181,14 @@ while (pop > 0)
if (strlen(destination) == 0)
{
- strcpy(destination,"/");
+ (void)strlcpy(destination,"/",sizeof(destination));
}
else
{
AddSlash(destination);
}
-strcat(destination,sp);
+(void)strlcat(destination,sp,sizeof(destination));
Debug("Reconstructed absolute linkname = %s\n",destination);
return destination;
}