update to cfengine 2.2.1

simplify port drastically by removing str* patches, these might be
revived one day as an external patch

no objections from maintainer
This commit is contained in:
sturm 2007-10-12 20:12:18 +00:00
parent a1b3fc2d19
commit f6bb42b4ff
60 changed files with 50 additions and 6659 deletions

View File

@ -1,9 +1,8 @@
# $OpenBSD: Makefile,v 1.25 2007/09/15 21:14:01 merdely Exp $
# $OpenBSD: Makefile,v 1.26 2007/10/12 20:12:18 sturm Exp $
COMMENT= GNU system administration tool for networks
V= 2.1.16
DISTNAME= cfengine-${V}
DISTNAME= cfengine-2.2.1
CATEGORIES= sysutils
HOMEPAGE= http://www.cfengine.org/
@ -24,8 +23,4 @@ CONFIGURE_ARGS+= --with-docs
LIB_DEPENDS= lib/db4/db.=4:db-4.*:databases/db/v4
CONFIGURE_ENV= ac_cv_lib_pthread_main=no
SUBST_VARS= V
.include <bsd.port.mk>

View File

@ -1,5 +1,5 @@
MD5 (cfengine-2.1.16.tar.gz) = GwCdzCqyfCBecrU2xnrhcw==
RMD160 (cfengine-2.1.16.tar.gz) = O4dfvWFE52EU8Z8+ofQLVZ8G9FM=
SHA1 (cfengine-2.1.16.tar.gz) = EaWRyy6Ab+WFMqXEqQ179k7Zxjw=
SHA256 (cfengine-2.1.16.tar.gz) = C/MjyOELWq6gnvb3fShTxfN6pIMO6X68yah5AKLSXw8=
SIZE (cfengine-2.1.16.tar.gz) = 3606067
MD5 (cfengine-2.2.1.tar.gz) = J3ZLNS6DXutkgFLuARQJUw==
RMD160 (cfengine-2.2.1.tar.gz) = S2UXIW9v6FZrCFdJpfL+ku4q0J8=
SHA1 (cfengine-2.2.1.tar.gz) = zklUF0EQxDVB0ld1dHrmWtowBj0=
SHA256 (cfengine-2.2.1.tar.gz) = rYIPCNwIg+rOrljq+gQ9djjRF4JUlquyiSKHRhMrr+o=
SIZE (cfengine-2.2.1.tar.gz) = 3715232

View File

@ -1,20 +1,12 @@
$OpenBSD: patch-configure,v 1.4 2005/10/27 21:47:28 sturm Exp $
--- configure.orig Sat Oct 1 08:32:10 2005
+++ configure Fri Oct 21 16:35:54 2005
@@ -9135,6 +9135,7 @@ cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
$ac_includes_default
+#include <sys/param.h>
#include <$ac_header>
_ACEOF
rm -f conftest.$ac_objext
@@ -15958,7 +15959,7 @@ echo $ECHO_N "checking Checking for GCC
$OpenBSD: patch-configure,v 1.5 2007/10/12 20:12:19 sturm Exp $
--- configure.orig Tue May 29 20:07:07 2007
+++ configure Sun Sep 2 16:14:30 2007
@@ -17941,7 +17941,7 @@ echo $ECHO_N "checking Checking for GCC Specific compi
if test x"$GCC" = "xyes"; then
- GCC_CFLAG="-g -O2 -Wreturn-type -Wmissing-prototypes -Wuninitialized"
+ GCC_CFLAG=""
echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
{ echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6; }

View File

@ -1,15 +0,0 @@
$OpenBSD: patch-contrib_Makefile_in,v 1.1 2005/10/27 21:47:28 sturm Exp $
vicf has security issues
--- contrib/Makefile.in.orig Tue Oct 25 10:59:38 2005
+++ contrib/Makefile.in Tue Oct 25 10:59:40 2005
@@ -170,7 +170,7 @@ target_os = @target_os@
target_vendor = @target_vendor@
s1 = cfdoc
s2 = cfengine.el
-sbin_SCRIPTS = vicf $(s1)
+sbin_SCRIPTS = $(s1)
pkgdata_SCRIPTS = $(s2)
EXTRA_DIST = README README.vicf $(s1) $(s2)

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-doc_Makefile_in,v 1.2 2005/07/21 15:16:46 aanriot Exp $
--- doc/Makefile.in.orig Fri Jun 10 16:01:42 2005
+++ doc/Makefile.in Mon Jul 18 14:31:00 2005
$OpenBSD: patch-doc_Makefile_in,v 1.3 2007/10/12 20:12:19 sturm Exp $
--- doc/Makefile.in.orig Tue May 29 20:07:06 2007
+++ doc/Makefile.in Sun Sep 2 15:56:22 2007
@@ -79,7 +79,7 @@ am__vpath_adj = case $$p in \
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
docDATA_INSTALL = $(INSTALL_DATA)
@ -10,7 +10,7 @@ $OpenBSD: patch-doc_Makefile_in,v 1.2 2005/07/21 15:16:46 aanriot Exp $
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
@@ -704,7 +704,7 @@ info: info-am
@@ -717,7 +717,7 @@ info: info-am
info-am: $(INFO_DEPS)
@ -19,7 +19,7 @@ $OpenBSD: patch-doc_Makefile_in,v 1.2 2005/07/21 15:16:46 aanriot Exp $
install-man
install-exec-am:
@@ -770,7 +770,7 @@ uninstall-am: uninstall-docDATA uninstal
@@ -783,7 +783,7 @@ uninstall-am: uninstall-docDATA uninstall-htmlDATA uni
uninstall-man: uninstall-man8
.PHONY: all all-am check check-am clean clean-generic dist-info \

View File

@ -1,17 +0,0 @@
$OpenBSD: patch-src_2Dlist_c,v 1.1 2004/06/17 11:21:42 sturm Exp $
--- src/2Dlist.c.orig 2004-06-10 23:26:23.000000000 -0400
+++ src/2Dlist.c 2004-06-10 22:54:37.000000000 -0400
@@ -76,11 +76,11 @@ memset(entry,0,CF_BUFSIZE);
for (tp = list; tp != NULL; tp=tp->next)
{
- sprintf(seps,"%c",tp->sep);
+ (void)snprintf(seps,sizeof(seps),"%c",tp->sep);
if (tp->current != NULL)
{
- strcat(entry,(tp->current)->name);
+ (void)strlcat(entry,(tp->current)->name,CF_BUFSIZE);
}
}

View File

@ -1,138 +0,0 @@
$OpenBSD: patch-src_cfagent_c,v 1.5 2005/10/27 21:47:28 sturm Exp $
--- src/cfagent.c.orig Wed Sep 21 16:06:14 2005
+++ src/cfagent.c Fri Oct 21 16:35:54 2005
@@ -205,7 +205,7 @@ void Initialize(int argc,char *argv[])
unsigned char s[16];
char ebuff[CF_EXPANDSIZE];
-strcpy(VDOMAIN,CF_START_DOMAIN);
+(void)strlcpy(VDOMAIN,CF_START_DOMAIN,sizeof(VDOMAIN));
PreLockState();
@@ -218,7 +218,7 @@ VMAILSERVER[0] = '\0';
ALLCLASSBUFFER[0] = '\0';
VREPOSITORY = strdup("\0");
-strcpy(METHODNAME,"cf-nomethod");
+(void)strlcpy(METHODNAME,"cf-nomethod",sizeof(METHODNAME));
METHODREPLYTO[0] = '\0';
METHODFOR[0] = '\0';
@@ -226,8 +226,8 @@ METHODFOR[0] = '\0';
re_syntax_options |= RE_INTERVALS;
#endif
-strcpy(VINPUTFILE,"cfagent.conf");
-strcpy(VNFSTYPE,"nfs");
+(void)strlcpy(VINPUTFILE,"cfagent.conf",CF_BUFSIZE);
+(void)strlcpy(VNFSTYPE,"nfs",sizeof(VNFSTYPE));
IDClasses();
@@ -270,27 +270,28 @@ for (i = 1; i < argc; i++)
/* XXX Initialize workdir for non privileged users */
- strcpy(CFWORKDIR,WORKDIR);
+ (void)strlcpy(CFWORKDIR,WORKDIR,sizeof(CFWORKDIR));
if (getuid() > 0)
{
char *homedir;
if ((homedir = getenv("HOME")) != NULL)
{
- strcpy(CFWORKDIR,homedir);
- strcat(CFWORKDIR,"/.cfagent");
+ (void)strlcpy(CFWORKDIR,homedir,sizeof(CFWORKDIR));
+ (void)strlcat(CFWORKDIR,"/.cfagent",sizeof(CFWORKDIR));
}
}
- sprintf(ebuff,"%s/state/cf_procs",CFWORKDIR);
+ (void)snprintf(ebuff,sizeof(ebuff),"%s/state/cf_procs",CFWORKDIR);
if (stat(ebuff,&statbuf) == -1)
{
CreateEmptyFile(ebuff);
}
- strcpy(VLOGDIR,CFWORKDIR);
- strcpy(VLOCKDIR,VLOGDIR); /* Same since 2.0.a8 */
+ (void)strlcpy(VLOGDIR,CFWORKDIR,CF_BUFSIZE);
+ (void)strlcpy(VLOCKDIR,VLOGDIR,CF_BUFSIZE); /* Same since 2.0.a8 */
+
OpenSSL_add_all_algorithms();
ERR_load_crypto_strings();
@@ -323,8 +324,8 @@ if (NOPRECONFIG)
return;
}
-strcpy(VPREFIX,"cfengine:");
-strcat(VPREFIX,VUQNAME);
+(void)strlcpy(VPREFIX,"cfengine:",40);
+(void)strlcat(VPREFIX,VUQNAME, 40);
if ((sp=getenv(CF_INPUTSVAR)) != NULL)
{
@@ -617,8 +618,8 @@ if (strlen(ebuff) != 0)
}
else
{
- strcpy(VPREFIX,"cfengine:");
- strcat(VPREFIX,VUQNAME);
+ (void)strlcpy(VPREFIX,"cfengine:",40);
+ (void)strlcat(VPREFIX,VUQNAME,40);
}
p2 = SortItemListNames(VHEAP);
@@ -765,7 +766,7 @@ if (VACTIONSEQ == NULL)
Warning("perhaps cfagent.conf/update.conf have not yet been set up?");
}
-sprintf(id,"%d",geteuid()); /* get effective user id */
+(void)snprintf(id,sizeof(id),"%d",geteuid()); /* get effective user id */
if (VACCESSLIST != NULL && !IsItemIn(VACCESSLIST,id))
{
@@ -920,7 +921,7 @@ if (OptionIs(CONTEXTID,"DryRun",true))
if (GetMacroValue(CONTEXTID,"BinaryPaddingChar"))
{
- strcpy(ebuff,GetMacroValue(CONTEXTID,"BinaryPaddingChar"));
+ (void)strlcpy(ebuff,GetMacroValue(CONTEXTID,"BinaryPaddingChar"),sizeof(ebuff));
if (ebuff[0] == '\\')
{
@@ -1520,7 +1521,7 @@ while (*sp != '\0')
{
VIFELAPSED = VDEFAULTIFELAPSED;
VEXPIREAFTER = VDEFAULTEXPIREAFTER;
- strcpy(actiontxt,cbuff);
+ (void)strlcpy(actiontxt,cbuff,sizeof(actiontxt));
continue;
}
else
@@ -1861,8 +1862,8 @@ for (ip = VHEAP; ip != NULL; ip=ip->next
else
{
size++; /* Allow for : separator */
- strcat(ALLCLASSBUFFER,ip->name);
- strcat(ALLCLASSBUFFER,":");
+ (void)strlcat(ALLCLASSBUFFER,ip->name,sizeof(ALLCLASSBUFFER));
+ (void)strlcat(ALLCLASSBUFFER,":",sizeof(ALLCLASSBUFFER));
}
fprintf(fp,"%s\n",ip->name);
@@ -1881,8 +1882,8 @@ for (ip = VHEAP; ip != NULL; ip=ip->next
else
{
size++; /* Allow for : separator */
- strcat(ALLCLASSBUFFER,ip->name);
- strcat(ALLCLASSBUFFER,":");
+ (void)strlcat(ALLCLASSBUFFER,ip->name,sizeof(ALLCLASSBUFFER));
+ (void)strlcat(ALLCLASSBUFFER,":",sizeof(ALLCLASSBUFFER));
}
fprintf(fp,"%s\n",ip->name);

View File

@ -1,285 +0,0 @@
$OpenBSD: patch-src_cfenvd_c,v 1.5 2005/10/27 21:47:28 sturm Exp $
--- src/cfenvd.c.orig Fri Jul 15 11:16:04 2005
+++ src/cfenvd.c Fri Oct 21 16:35:54 2005
@@ -187,10 +187,10 @@ void CheckOptsAndInit(int argc,char **ar
int c, i,j,k;
umask(077);
-sprintf(VPREFIX,"cfenvd");
+(void)snprintf(VPREFIX,40,"cfenvd");
openlog(VPREFIX,LOG_PID|LOG_NOWAIT|LOG_ODELAY,LOG_DAEMON);
-strcpy(CFLOCK,"cfenvd");
+(void)strlcpy(CFLOCK,"cfenvd",sizeof(CFLOCK));
IGNORELOCK = false;
OUTPUT[0] = '\0';
@@ -247,30 +247,30 @@ SetSignals();
/* XXX Initialize workdir for non privileged users */
-strcpy(CFWORKDIR,WORKDIR);
+(void)strlcpy(CFWORKDIR,WORKDIR,sizeof(CFWORKDIR));
if (getuid() > 0)
{
char *homedir;
if ((homedir = getenv("HOME")) != NULL)
{
- strcpy(CFWORKDIR,homedir);
- strcat(CFWORKDIR,"/.cfagent");
+ (void)strlcpy(CFWORKDIR,homedir,sizeof(CFWORKDIR));
+ (void)strlcat(CFWORKDIR,"/.cfagent",sizeof(CFWORKDIR));
}
}
-sprintf(VBUFF,"%s/test",CFWORKDIR);
+(void)snprintf(VBUFF,sizeof(VBUFF),"%s/test",CFWORKDIR);
MakeDirectoriesFor(VBUFF,'y');
-sprintf(VBUFF,"%s/state/test",CFWORKDIR);
+(void)snprintf(VBUFF,sizeof(VBUFF),"%s/state/test",CFWORKDIR);
MakeDirectoriesFor(VBUFF,'y');
strncpy(VLOCKDIR,CFWORKDIR,CF_BUFSIZE-1);
strncpy(VLOGDIR,CFWORKDIR,CF_BUFSIZE-1);
for (i = 0; i < ATTR; i++)
{
- sprintf(VBUFF,"%s/state/cf_incoming.%s",CFWORKDIR,ECGSOCKS[i][1]);
+ (void)snprintf(VBUFF,sizeof(VBUFF),"%s/state/cf_incoming.%s",CFWORKDIR,ECGSOCKS[i][1]);
CreateEmptyFile(VBUFF);
- sprintf(VBUFF,"%s/state/cf_outgoing.%s",CFWORKDIR,ECGSOCKS[i][1]);
+ (void)snprintf(VBUFF,sizeof(VBUFF),"%s/state/cf_outgoing.%s",CFWORKDIR,ECGSOCKS[i][1]);
CreateEmptyFile(VBUFF);
}
@@ -280,7 +280,7 @@ for (i = 0; i < CF_NETATTR; i++)
NETOUT_DIST[i] = NULL;
}
-sprintf(VBUFF,"%s/state/cf_users",CFWORKDIR);
+(void)snprintf(VBUFF,sizeof(VBUFF),"%s/state/cf_users",CFWORKDIR);
CreateEmptyFile(VBUFF);
snprintf(AVDB,CF_MAXVARSIZE,"%s/state/%s",CFWORKDIR,CF_AVDB_FILE);
@@ -288,6 +288,7 @@ snprintf(STATELOG,CF_BUFSIZE,"%s/state/%
snprintf(ENV_NEW,CF_BUFSIZE,"%s/state/%s",CFWORKDIR,CF_ENVNEW_FILE);
snprintf(ENV,CF_BUFSIZE,"%s/state/%s",CFWORKDIR,CF_ENV_FILE);
+
if (!BATCH_MODE)
{
GetDatabaseAge();
@@ -476,7 +477,7 @@ void StartServer(int argc,char **argv)
if ((!NO_FORK) && (fork() != 0))
{
- sprintf(OUTPUT,"cfenvd: starting\n");
+ (void)snprintf(OUTPUT,sizeof(OUTPUT),"cfenvd: starting\n");
CfLog(cfinform,OUTPUT,"");
exit(0);
}
@@ -650,7 +651,7 @@ if ((now = time((time_t *)NULL)) == -1)
exit(1);
}
-sprintf(str,"%s",ctime(&now));
+(void)snprintf(str,sizeof(str),"%s",ctime(&now));
return ConvTimeKey(str);
}
@@ -816,14 +817,14 @@ SetVariable("loadavg",LOADAVG,av.expect_
for (i = 0; i < ATTR; i++)
{
char name[256];
- strcpy(name,ECGSOCKS[i][1]);
- strcat(name,"_in");
+ (void)strlcpy(name,ECGSOCKS[i][1],sizeof(name));
+ (void)strlcat(name,"_in",sizeof(name));
sig = SetClasses(name,INCOMING[i],av.expect_incoming[i],av.var_incoming[i],LOCALAV.expect_incoming[i],LOCALAV.var_incoming[i],&classlist,timekey);
SetVariable(name,INCOMING[i],av.expect_incoming[i],sig,&classlist);
- strcpy(name,ECGSOCKS[i][1]);
- strcat(name,"_out");
+ (void)strlcpy(name,ECGSOCKS[i][1],sizeof(name));
+ (void)strlcat(name,"_out",sizeof(name));
sig = SetClasses(name,OUTGOING[i],av.expect_outgoing[i],av.var_outgoing[i],LOCALAV.expect_outgoing[i],LOCALAV.var_outgoing[i],&classlist,timekey);
SetVariable(name,OUTGOING[i],av.expect_outgoing[i],sig,&classlist);
@@ -843,13 +844,13 @@ for (i = 0; i < PH_LIMIT; i++)
for (i = 0; i < CF_NETATTR; i++)
{
char name[256];
- strcpy(name,TCPNAMES[i]);
- strcat(name,"_in");
+ (void)strlcpy(name,TCPNAMES[i],sizeof(name));
+ (void)strlcat(name,"_in",sizeof(name));
sig = SetClasses(name,NETIN[i],av.expect_netin[i],av.var_netin[i],LOCALAV.expect_netin[i],LOCALAV.var_netin[i],&classlist,timekey);
SetVariable(name,NETIN[i],av.expect_netin[i],sig,&classlist);
- strcpy(name,TCPNAMES[i]);
- strcat(name,"_out");
+ (void)strlcpy(name,TCPNAMES[i],sizeof(name));
+ (void)strlcat(name,"_out",sizeof(name));
sig = SetClasses(name,NETOUT[i],av.expect_netout[i],av.var_netout[i],LOCALAV.expect_netout[i],LOCALAV.var_netout[i],&classlist,timekey);
SetVariable(name,NETOUT[i],av.expect_netout[i],sig,&classlist);
}
@@ -1166,7 +1167,7 @@ if (ALL_OUTGOING != NULL)
sscanf(VNETSTAT[VSYSTEMHARDCLASS],"%s",comm);
-strcat(comm," -n");
+(void)strlcat(comm," -n",sizeof(comm));
if ((pp = cfpopen(comm,"r")) == NULL)
{
@@ -1495,7 +1496,7 @@ struct Averages *GetCurrentAverages(char
if ((errno = db_create(&dbp,NULL,0)) != 0)
{
- sprintf(OUTPUT,"Couldn't open average database %s\n",AVDB);
+ (void)snprintf(OUTPUT,sizeof(OUTPUT),"Couldn't open average database %s\n",AVDB);
CfLog(cferror,OUTPUT,"db_open");
return NULL;
}
@@ -1506,7 +1507,7 @@ if ((errno = dbp->open(dbp,AVDB,NULL,DB_
if ((errno = dbp->open(dbp,NULL,AVDB,NULL,DB_BTREE,DB_CREATE,0644)) != 0)
#endif
{
- sprintf(OUTPUT,"Couldn't open average database %s\n",AVDB);
+ (void)snprintf(OUTPUT,sizeof(OUTPUT),"Couldn't open average database %s\n",AVDB);
CfLog(cferror,OUTPUT,"db_open");
return NULL;
}
@@ -1556,7 +1557,7 @@ void UpdateAverages(char *timekey,struct
if ((errno = db_create(&dbp,NULL,0)) != 0)
{
- sprintf(OUTPUT,"Couldn't open average database %s\n",AVDB);
+ (void)snprintf(OUTPUT,sizeof(OUTPUT),"Couldn't open average database %s\n",AVDB);
CfLog(cferror,OUTPUT,"db_open");
return;
}
@@ -1567,7 +1568,7 @@ if ((errno = dbp->open(dbp,AVDB,NULL,DB_
if ((errno = dbp->open(dbp,NULL,AVDB,NULL,DB_BTREE,DB_CREATE,0644)) != 0)
#endif
{
- sprintf(OUTPUT,"Couldn't open average database %s\n",AVDB);
+ (void)snprintf(OUTPUT,sizeof(OUTPUT),"Couldn't open average database %s\n",AVDB);
CfLog(cferror,OUTPUT,"db_open");
return;
}
@@ -1794,27 +1795,27 @@ if (fabs(delta) < cf_noise_threshold) /*
Debug(" Sensitivity too high ..\n");
buffer[0] = '\0';
- strcpy(buffer,name);
+ (void)strlcpy(buffer,name,sizeof(buffer));
if ((delta > 0) && (ldelta > 0))
{
- strcat(buffer,"_high");
+ (void)strlcat(buffer,"_high",sizeof(buffer));
}
else if ((delta < 0) && (ldelta < 0))
{
- strcat(buffer,"_low");
+ (void)strlcat(buffer,"_low",sizeof(buffer));
}
else
{
- strcat(buffer,"_normal");
+ (void)strlcat(buffer,"_normal",sizeof(buffer));
}
dev = sqrt(delta*delta/(1.0+sigma*sigma)+ldelta*ldelta/(1.0+lsigma*lsigma));
if (dev > 2.0*sqrt(2.0))
{
- strcpy(buffer2,buffer);
- strcat(buffer2,"_microanomaly");
+ (void)strlcpy(buffer2,buffer,sizeof(buffer2));
+ (void)strlcat(buffer2,"_microanomaly",sizeof(buffer2));
AppendItem(classlist,buffer2,"2");
AddPersistentClass(buffer2,40,cfpreserve);
}
@@ -1824,33 +1825,33 @@ if (fabs(delta) < cf_noise_threshold) /*
else
{
buffer[0] = '\0';
- strcpy(buffer,name);
+ (void)strlcpy(buffer,name,sizeof(buffer));
if ((delta > 0) && (ldelta > 0))
{
- strcat(buffer,"_high");
+ (void)strlcat(buffer,"_high",sizeof(buffer));
}
else if ((delta < 0) && (ldelta < 0))
{
- strcat(buffer,"_low");
+ (void)strlcat(buffer,"_low",sizeof(buffer));
}
else
{
- strcat(buffer,"_normal");
+ (void)strlcat(buffer,"_normal",sizeof(buffer));
}
dev = sqrt(delta*delta/(1.0+sigma*sigma)+ldelta*ldelta/(1.0+lsigma*lsigma));
if (dev <= sqrt(2.0))
{
- strcpy(buffer2,buffer);
- strcat(buffer2,"_normal");
+ (void)strlcpy(buffer2,buffer,sizeof(buffer));
+ (void)strlcat(buffer2,"_normal",sizeof(buffer2));
AppendItem(classlist,buffer2,"0");
}
else
{
- strcpy(buffer2,buffer);
- strcat(buffer2,"_dev1");
+ (void)strlcpy(buffer2,buffer,sizeof(buffer2));
+ (void)strlcat(buffer2,"_dev1",sizeof(buffer2));
AppendItem(classlist,buffer2,"0");
}
@@ -1860,16 +1861,16 @@ if (fabs(delta) < cf_noise_threshold) /*
if (dev > 2.0*sqrt(2.0))
{
- strcpy(buffer2,buffer);
- strcat(buffer2,"_dev2");
+ (void)strlcpy(buffer2,buffer,sizeof(buffer2));
+ (void)strlcat(buffer2,"_dev2",sizeof(buffer2));
AppendItem(classlist,buffer2,"2");
AddPersistentClass(buffer2,40,cfpreserve);
}
if (dev > 3.0*sqrt(2.0))
{
- strcpy(buffer2,buffer);
- strcat(buffer2,"_anomaly");
+ (void)strlcpy(buffer2,buffer,sizeof(buffer2));
+ (void)strlcat(buffer2,"_anomaly",sizeof(buffer2));
AppendItem(classlist,buffer2,"3");
AddPersistentClass(buffer2,40,cfpreserve);
}
@@ -1884,13 +1885,13 @@ void SetVariable(char *name,double value
{ char var[CF_BUFSIZE];
-sprintf(var,"value_%s=%d",name,(int)value);
+(void)snprintf(var,sizeof(var),"value_%s=%d",name,(int)value);
AppendItem(classlist,var,"");
-sprintf(var,"average_%s=%1.1f",name,average);
+(void)snprintf(var,sizeof(var),"average_%s=%1.1f",name,average);
AppendItem(classlist,var,"");
-sprintf(var,"stddev_%s=%1.1f",name,stddev);
+(void)snprintf(var,sizeof(var),"stddev_%s=%1.1f",name,stddev);
AppendItem(classlist,var,"");
}

View File

@ -1,298 +0,0 @@
$OpenBSD: patch-src_cfenvgraph_c,v 1.4 2005/07/21 15:16:46 aanriot Exp $
--- src/cfenvgraph.c.orig Wed May 25 10:17:00 2005
+++ src/cfenvgraph.c Fri Jul 15 12:24:00 2005
@@ -177,7 +177,7 @@ for (sp = line; *sp != '\0'; sp++)
}
}
-strcpy(VFQNAME,line);
+(void)strlcpy(VFQNAME,line,sizeof(VFQNAME));
if (strlen(VFQNAME) == 0)
{
@@ -187,7 +187,7 @@ if (strlen(VFQNAME) == 0)
perror("uname ");
exit(0);
}
- strcpy(VFQNAME,sys.sysname);
+ (void)strlcpy(VFQNAME,sys.sysname,sizeof(VFQNAME));
}
else
{
@@ -285,7 +285,7 @@ for (NOW = CF_MONDAY_MORNING; NOW < CF_M
memset(&value,0,sizeof(value));
memset(&ENTRY,0,sizeof(ENTRY));
- strcpy(TIMEKEY,GenTimeKey(NOW));
+ (void)strlcpy(TIMEKEY,GenTimeKey(NOW),sizeof(TIMEKEY));
key.data = TIMEKEY;
key.size = strlen(TIMEKEY)+1;
@@ -554,7 +554,7 @@ if (TIMESTAMPS)
printf("Couldn't read system clock\n");
}
- sprintf(FLNAME,"cfenvgraphs-%s-%s",VFQNAME,ctime(&NOW));
+ (void)snprintf(FLNAME,sizeof(FLNAME),"cfenvgraphs-%s-%s",VFQNAME,ctime(&NOW));
for (sp = FLNAME; *sp != '\0'; sp++)
{
@@ -566,7 +566,7 @@ if (TIMESTAMPS)
}
else
{
- sprintf(FLNAME,"cfenvgraphs-snapshot-%s",VFQNAME);
+ (void)snprintf(FLNAME,sizeof(FLNAME),"cfenvgraphs-snapshot-%s",VFQNAME);
}
printf("Creating sub-directory %s\n",FLNAME);
@@ -588,7 +588,7 @@ if (chdir(FLNAME))
printf("Writing data to sub-directory %s: \n x,y1,y2,y3...\n ",FLNAME);
-sprintf(FLNAME,"cfenv-average");
+(void)snprintf(FLNAME,sizeof(FLNAME),"cfenv-average");
if ((FPAV = fopen(FLNAME,"w")) == NULL)
{
@@ -596,7 +596,7 @@ if ((FPAV = fopen(FLNAME,"w")) == NULL)
exit(1);
}
-sprintf(FLNAME,"cfenv-stddev");
+(void)snprintf(FLNAME,sizeof(FLNAME),"cfenv-stddev");
if ((FPVAR = fopen(FLNAME,"w")) == NULL)
{
@@ -609,31 +609,31 @@ if ((FPVAR = fopen(FLNAME,"w")) == NULL)
if (SEPARATE)
{
- sprintf(FLNAME,"users.cfenv");
+ (void)snprintf(FLNAME,sizeof(FLNAME),"users.cfenv");
if ((FPUSER = fopen(FLNAME,"w")) == NULL)
{
perror("fopen");
exit(1);
}
- sprintf(FLNAME,"rootprocs.cfenv");
+ (void)snprintf(FLNAME,sizeof(FLNAME),"rootprocs.cfenv");
if ((FPROOT = fopen(FLNAME,"w")) == NULL)
{
perror("fopen");
exit(1);
}
- sprintf(FLNAME,"otherprocs.cfenv");
+ (void)snprintf(FLNAME,sizeof(FLNAME),"otherprocs.cfenv");
if ((FPOTHER = fopen(FLNAME,"w")) == NULL)
{
perror("fopen");
exit(1);
}
- sprintf(FLNAME,"freedisk.cfenv");
+ (void)snprintf(FLNAME,sizeof(FLNAME),"freedisk.cfenv");
if ((FPDISK = fopen(FLNAME,"w")) == NULL)
{
perror("fopen");
exit(1);
}
- sprintf(FLNAME,"loadavg.cfenv");
+ (void)snprintf(FLNAME,sizeof(FLNAME),"loadavg.cfenv");
if ((FPLOAD = fopen(FLNAME,"w")) == NULL)
{
perror("fopen");
@@ -642,14 +642,14 @@ if (SEPARATE)
for (i = 0; i < ATTR; i++)
{
- sprintf(FLNAME,"%s-in.cfenv",ECGSOCKS[i][1]);
+ (void)snprintf(FLNAME,sizeof(FLNAME),"%s-in.cfenv",ECGSOCKS[i][1]);
if ((FPIN[i] = fopen(FLNAME,"w")) == NULL)
{
perror("fopen");
exit(1);
}
- sprintf(FLNAME,"%s-out.cfenv",ECGSOCKS[i][1]);
+ (void)snprintf(FLNAME,sizeof(FLNAME),"%s-out.cfenv",ECGSOCKS[i][1]);
if ((FPOUT[i] = fopen(FLNAME,"w")) == NULL)
{
perror("fopen");
@@ -659,14 +659,14 @@ if (SEPARATE)
for (i = 0; i < CF_NETATTR; i++)
{
- sprintf(FLNAME,"%s-in.cfenv",TCPNAMES[i]);
+ (void)snprintf(FLNAME,sizeof(FLNAME),"%s-in.cfenv",TCPNAMES[i]);
if ((FPNETIN[i] = fopen(FLNAME,"w")) == NULL)
{
perror("fopen");
exit(1);
}
- sprintf(FLNAME,"%s-out.cfenv",TCPNAMES[i]);
+ (void)snprintf(FLNAME,sizeof(FLNAME),"%s-out.cfenv",TCPNAMES[i]);
if ((FPNETOUT[i] = fopen(FLNAME,"w")) == NULL)
{
perror("fopen");
@@ -681,7 +681,7 @@ if (SEPARATE)
continue;
}
- sprintf(FLNAME,"%s.cfenv",CanonifyName(PH_BINARIES[i]));
+ (void)snprintf(FLNAME,sizeof(FLNAME),"%s.cfenv",CanonifyName(PH_BINARIES[i]));
if ((FPPH[i] = fopen(FLNAME,"w")) == NULL)
{
perror("fopen");
@@ -771,7 +771,7 @@ while (NOW < CF_MONDAY_MORNING+CF_WEEK)
memset(&key,0,sizeof(key));
memset(&value,0,sizeof(value));
- strcpy(TIMEKEY,GenTimeKey(NOW));
+ (void)strlcpy(TIMEKEY,GenTimeKey(NOW),sizeof(TIMEKEY));
key.data = TIMEKEY;
key.size = strlen(TIMEKEY)+1;
@@ -1023,7 +1023,7 @@ for (i = 0; i < 7; i++)
int position,day;
int weekly[CF_NETATTR*2+ATTR*2+5+PH_LIMIT][CF_GRAINS];
- snprintf(FLNAME,CF_BUFSIZE,"%s/state/histograms",CFWORKDIR);
+ snprintf(FLNAME,sizeof(FLNAME),"%s/state/histograms",CFWORKDIR);
if ((fp = fopen(FLNAME,"r")) == NULL)
{
@@ -1076,31 +1076,31 @@ for (i = 0; i < 7; i++)
}
}
- sprintf(FLNAME,"users.distr");
+ (void)snprintf(FLNAME,sizeof(FLNAME),"users.distr");
if ((FPUSER = fopen(FLNAME,"w")) == NULL)
{
perror("fopen");
exit(1);
}
- sprintf(FLNAME,"rootprocs.distr");
+ (void)snprintf(FLNAME,sizeof(FLNAME),"rootprocs.distr");
if ((FPROOT = fopen(FLNAME,"w")) == NULL)
{
perror("fopen");
exit(1);
}
- sprintf(FLNAME,"otherprocs.distr");
+ (void)snprintf(FLNAME,sizeof(FLNAME),"otherprocs.distr");
if ((FPOTHER = fopen(FLNAME,"w")) == NULL)
{
perror("fopen");
exit(1);
}
- sprintf(FLNAME,"freedisk.distr");
+ (void)snprintf(FLNAME,sizeof(FLNAME),"freedisk.distr");
if ((FPDISK = fopen(FLNAME,"w")) == NULL)
{
perror("fopen");
exit(1);
}
- sprintf(FLNAME,"loadavg.distr");
+ (void)snprintf(FLNAME,sizeof(FLNAME),"loadavg.distr");
if ((FPLOAD = fopen(FLNAME,"w")) == NULL)
{
perror("fopen");
@@ -1109,14 +1109,14 @@ for (i = 0; i < 7; i++)
for (i = 0; i < ATTR; i++)
{
- sprintf(FLNAME,"%s-in.distr",ECGSOCKS[i][1]);
+ (void)snprintf(FLNAME,sizeof(FLNAME),"%s-in.distr",ECGSOCKS[i][1]);
if ((FPIN[i] = fopen(FLNAME,"w")) == NULL)
{
perror("fopen");
exit(1);
}
- sprintf(FLNAME,"%s-out.distr",ECGSOCKS[i][1]);
+ (void)snprintf(FLNAME,sizeof(FLNAME),"%s-out.distr",ECGSOCKS[i][1]);
if ((FPOUT[i] = fopen(FLNAME,"w")) == NULL)
{
perror("fopen");
@@ -1126,13 +1126,13 @@ for (i = 0; i < 7; i++)
for (i = 0; i < CF_NETATTR; i++)
{
- sprintf(FLNAME,"%s-in.distr",TCPNAMES[i]);
+ (void)snprintf(FLNAME,sizeof(FLNAME),"%s-in.distr",TCPNAMES[i]);
if ((FPNETIN[i] = fopen(FLNAME,"w")) == NULL)
{
perror("fopen");
exit(1);
}
- sprintf(FLNAME,"%s-out.distr",TCPNAMES[i]);
+ (void)snprintf(FLNAME,sizeof(FLNAME),"%s-out.distr",TCPNAMES[i]);
if ((FPNETOUT[i] = fopen(FLNAME,"w")) == NULL)
{
@@ -1148,7 +1148,7 @@ for (i = 0; i < 7; i++)
continue;
}
- sprintf(FLNAME,"%s.distr",CanonifyName(PH_BINARIES[i]));
+ (void)snprintf(FLNAME,sizeof(FLNAME),"%s.distr",CanonifyName(PH_BINARIES[i]));
if ((FPPH[i] = fopen(FLNAME,"w")) == NULL)
{
perror("fopen");
@@ -1380,7 +1380,7 @@ for (dirp = readdir(dirh); dirp != NULL;
memset(&key,0,sizeof(key));
memset(&value,0,sizeof(value));
- strcpy(TIMEKEY,GenTimeKey(now));
+ (void)strlcpy(TIMEKEY,GenTimeKey(now),sizeof(TIMEKEY));
key.data = TIMEKEY;
key.size = strlen(TIMEKEY)+1;
@@ -1476,15 +1476,15 @@ void CheckOpts(int argc,char **argv)
/* XXX Initialize workdir for non privileged users */
- strcpy(CFWORKDIR,WORKDIR);
+ (void)strlcpy(CFWORKDIR,WORKDIR,sizeof(CFWORKDIR));
if (geteuid() > 0)
{
char *homedir;
if ((homedir = getenv("HOME")) != NULL)
{
- strcpy(CFWORKDIR,homedir);
- strcat(CFWORKDIR,"/.cfagent");
+ (void)strlcpy(CFWORKDIR,homedir,sizeof(CFWORKDIR));
+ (void)strlcat(CFWORKDIR,"/.cfagent",sizeof(CFWORKDIR));
}
}
@@ -1497,7 +1497,7 @@ while ((c=getopt_long(argc,argv,"Thtf:rs
case 't': TITLES = true;
break;
- case 'f': strcpy(FILENAME,optarg);
+ case 'f': (void)strlcpy(FILENAME,optarg,CF_BUFSIZE);
break;
case 'T': TIMESTAMPS = true;
@@ -1551,7 +1551,7 @@ char *CanonifyName(char *str)
char *sp;
memset(buffer,0,CF_BUFSIZE);
-strcpy(buffer,str);
+(void)strlcpy(buffer,str,sizeof(buffer));
for (sp = buffer; *sp != '\0'; sp++)
{
@@ -1623,7 +1623,7 @@ for (NOW = CF_MONDAY_MORNING; NOW < CF_M
memset(&value,0,sizeof(value));
memset(&ENTRY,0,sizeof(ENTRY));
- strcpy(TIMEKEY,GenTimeKey(NOW));
+ (void)strlcpy(TIMEKEY,GenTimeKey(NOW),sizeof(TIMEKEY));
key.data = TIMEKEY;
key.size = strlen(TIMEKEY)+1;

View File

@ -1,509 +0,0 @@
$OpenBSD: patch-src_cfetool_c,v 1.2 2005/12/18 20:45:41 pvalchev Exp $
--- src/cfetool.c.orig Thu Jun 30 01:53:06 2005
+++ src/cfetool.c Sun Dec 18 11:58:21 2005
@@ -326,7 +326,7 @@ void parse_create_opts(int argc, char **
case 'f':
BATCH_MODE = true;
- strcpy(BATCHFILE, optarg);
+ (void)strlcpy(BATCHFILE, optarg, sizeof(BATCHFILE));
break;
case 'v':
@@ -338,7 +338,7 @@ void parse_create_opts(int argc, char **
break;
case 'p':
- strcpy(PATHNAME,optarg);
+ (void)strlcpy(PATHNAME,optarg,sizeof(PATHNAME));
break;
case 's':
@@ -420,7 +420,7 @@ void parse_update_opts(int argc, char **
break;
case 'p':
- strcpy(PATHNAME,optarg);
+ (void)strlcpy(PATHNAME,optarg,sizeof(PATHNAME));
break;
case 't':
@@ -522,7 +522,7 @@ void parse_check_opts(int argc, char **a
break;
case 'p':
- strcpy(PATHNAME,optarg);
+ (void)strlcpy(PATHNAME,optarg,sizeof(PATHNAME));
break;
case 't':
@@ -603,7 +603,7 @@ void parse_info_opts(int argc, char **ar
break;
case 'p':
- strcpy(PATHNAME,optarg);
+ (void)strlcpy(PATHNAME,optarg,sizeof(PATHNAME));
break;
case 'E':
@@ -675,7 +675,7 @@ void parse_dump_opts(int argc, char **ar
break;
case 'p':
- strcpy(PATHNAME,optarg);
+ (void)strlcpy(PATHNAME,optarg,sizeof(PATHNAME));
break;
case 'Y':
@@ -687,7 +687,7 @@ void parse_dump_opts(int argc, char **ar
break;
case 'f':
- strcpy(DUMPFILE, optarg);
+ (void)strlcpy(DUMPFILE, optarg, sizeof(DUMPFILE));
break;
case 'd':
@@ -772,7 +772,7 @@ void parse_import_opts(int argc, char **
break;
case 'p':
- strcpy(PATHNAME,optarg);
+ (void)strlcpy(PATHNAME,optarg,sizeof(PATHNAME));
break;
case 'v':
@@ -780,7 +780,7 @@ void parse_import_opts(int argc, char **
break;
case 'f':
- strcpy(IMPORTFILE, optarg);
+ (void)strlcpy(IMPORTFILE, optarg, sizeof(IMPORTFILE));
break;
case 'd':
@@ -851,22 +851,22 @@ void Create(int step, int dbtype)
if(getcwd(current_dir, cwdbufsize) == NULL)
perror("getcwd");
if(PATHNAME[0] == '\0')
- sprintf(LOCATION, "%s/%s", current_dir, NAME);
+ (void)snprintf(LOCATION, sizeof(LOCATION), "%s/%s", current_dir, NAME);
else if(PATHNAME[0] == '/')
- sprintf(LOCATION, "%s/%s", PATHNAME, NAME);
+ (void)snprintf(LOCATION, sizeof(LOCATION), "%s/%s", PATHNAME, NAME);
else
- sprintf(LOCATION, "%s/%s/%s", current_dir, PATHNAME, NAME);
+ (void)snprintf(LOCATION, sizeof(LOCATION), "%s/%s/%s", current_dir, PATHNAME, NAME);
switch(dbtype)
{
case DAILY:
- sprintf(AVDB, "%s/daily.db", LOCATION);
+ (void)snprintf(AVDB, CF_MAXVARSIZE-1, "%s/daily.db", LOCATION);
break;
case YEARLY:
- sprintf(AVDB, "%s/yearly.db", LOCATION);
+ (void)snprintf(AVDB, CF_MAXVARSIZE-1, "%s/yearly.db", LOCATION);
break;
default: /* weekly */
- sprintf(AVDB, "%s/weekly.db", LOCATION);
+ (void)snprintf(AVDB, CF_MAXVARSIZE-1, "%s/weekly.db", LOCATION);
break;
}
Verbose("Creating new database: %s\n", AVDB);
@@ -989,20 +989,20 @@ int Update(double value, time_t u_time,
VALUE = value;
if(PATHNAME[0] != '\0')
- sprintf(LOCATION, "%s/%s", PATHNAME, NAME);
+ (void)snprintf(LOCATION, sizeof(LOCATION), "%s/%s", PATHNAME, NAME);
else
- sprintf(LOCATION, "./%s", NAME);
+ (void)snprintf(LOCATION, sizeof(LOCATION), "./%s", NAME);
switch(dbtype)
{
case DAILY:
- sprintf(AVDB, "%s/daily.db", LOCATION);
+ (void)snprintf(AVDB, CF_MAXVARSIZE-1, "%s/daily.db", LOCATION);
break;
case YEARLY:
- sprintf(AVDB, "%s/yearly.db", LOCATION);
+ (void)snprintf(AVDB, CF_MAXVARSIZE-1, "%s/yearly.db", LOCATION);
break;
default: /* weekly */
- sprintf(AVDB, "%s/weekly.db", LOCATION);
+ (void)snprintf(AVDB, CF_MAXVARSIZE-1, "%s/weekly.db", LOCATION);
break;
}
@@ -1049,20 +1049,20 @@ int Check(double value, time_t u_time, i
VALUE = value;
if(PATHNAME[0] != '\0')
- sprintf(LOCATION, "%s/%s", PATHNAME, NAME);
+ (void)snprintf(LOCATION, sizeof(LOCATION), "%s/%s", PATHNAME, NAME);
else
- sprintf(LOCATION, "./%s", NAME);
+ (void)snprintf(LOCATION, sizeof(LOCATION), "./%s", NAME);
switch(dbtype)
{
case DAILY:
- sprintf(AVDB, "%s/daily.db", LOCATION);
+ (void)snprintf(AVDB, CF_MAXVARSIZE-1, "%s/daily.db", LOCATION);
break;
case YEARLY:
- sprintf(AVDB, "%s/yearly.db", LOCATION);
+ (void)snprintf(AVDB, CF_MAXVARSIZE-1, "%s/yearly.db", LOCATION);
break;
default: /* weekly */
- sprintf(AVDB, "%s/weekly.db", LOCATION);
+ (void)snprintf(AVDB, CF_MAXVARSIZE-1, "%s/weekly.db", LOCATION);
break;
}
@@ -1113,23 +1113,23 @@ void Info(int dbtype)
Verbose("Gathering database info...\n");
if(PATHNAME[0] != '\0')
- sprintf(LOCATION, "%s/%s", PATHNAME, NAME);
+ (void)snprintf(LOCATION, sizeof(LOCATION), "%s/%s", PATHNAME, NAME);
else
- sprintf(LOCATION, "./%s", NAME);
+ (void)snprintf(LOCATION, sizeof(LOCATION), "./%s", NAME);
switch(dbtype)
{
case DAILY:
- sprintf(AVDB, "%s/daily.db", LOCATION);
- sprintf(histfile, "%s/daily.hist", LOCATION);
+ (void)snprintf(AVDB, CF_MAXVARSIZE-1, "%s/daily.db", LOCATION);
+ (void)snprintf(histfile, sizeof(histfile), "%s/daily.hist", LOCATION);
break;
case YEARLY:
- sprintf(AVDB, "%s/yearly.db", LOCATION);
- sprintf(histfile, "%s/yearly.hist", LOCATION);
+ (void)snprintf(AVDB, CF_MAXVARSIZE-1, "%s/yearly.db", LOCATION);
+ (void)snprintf(histfile, sizeof(histfile), "%s/yearly.hist", LOCATION);
break;
default: /* weekly */
- sprintf(AVDB, "%s/weekly.db", LOCATION);
- sprintf(histfile, "%s/weekly.hist", LOCATION);
+ (void)snprintf(AVDB, CF_MAXVARSIZE-1, "%s/weekly.db", LOCATION);
+ (void)snprintf(histfile, sizeof(histfile), "%s/weekly.hist", LOCATION);
break;
}
@@ -1231,25 +1231,25 @@ void Dump(FILE * fp, int dbtype)
int begin_time;
int total_time;
if(PATHNAME[0] != '\0')
- sprintf(LOCATION, "%s/%s", PATHNAME, NAME);
+ (void)snprintf(LOCATION, sizeof(LOCATION), "%s/%s", PATHNAME, NAME);
else
- sprintf(LOCATION, "./%s", NAME);
+ (void)snprintf(LOCATION, sizeof(LOCATION), "./%s", NAME);
memset(str, 0, 256);
switch(dbtype)
{
case DAILY:
- sprintf(AVDB, "%s/daily.db", LOCATION);
+ (void)snprintf(AVDB, CF_MAXVARSIZE-1, "%s/daily.db", LOCATION);
begin_time = MONDAY_MORNING;
total_time = ONE_DAY;
break;
case YEARLY:
- sprintf(AVDB, "%s/yearly.db", LOCATION);
+ (void)snprintf(AVDB, CF_MAXVARSIZE-1, "%s/yearly.db", LOCATION);
begin_time = JANUARY_FIRST;
total_time = ONE_YEAR;
break;
default: /* weekly */
- sprintf(AVDB, "%s/weekly.db", LOCATION);
+ (void)snprintf(AVDB, CF_MAXVARSIZE-1, "%s/weekly.db", LOCATION);
begin_time = MONDAY_MORNING;
total_time = ONE_WEEK;
break;
@@ -1365,7 +1365,7 @@ void Dump(FILE * fp, int dbtype)
for (NOW = begin_time; NOW < begin_time + total_time;
NOW += INTERVAL)
{
- sprintf(str, "%s", ctime(&NOW));
+ (void)snprintf(str, sizeof(str), "%s", ctime(&NOW));
timekey = ConvTimeKey2(str, dbtype);
memset(&value, 0, sizeof(value));
@@ -1423,9 +1423,9 @@ void Import(FILE * fp, int dbtype)
char begincommand[128], endcommand[128];
if(PATHNAME[0] != '\0')
- sprintf(LOCATION, "%s/%s", PATHNAME, NAME);
+ (void)snprintf(LOCATION, sizeof(LOCATION), "%s/%s", PATHNAME, NAME);
else
- sprintf(LOCATION, "./%s", NAME);
+ (void)snprintf(LOCATION, sizeof(LOCATION), "./%s", NAME);
LOCALAV.expect = 0.0;
LOCALAV.var = 0.0;
@@ -1439,19 +1439,19 @@ void Import(FILE * fp, int dbtype)
{
case DAILY:
dumpcommand = "dailydump";
- sprintf(AVDB, "%s/daily.db", LOCATION);
+ (void)snprintf(AVDB, CF_MAXVARSIZE-1, "%s/daily.db", LOCATION);
break;
case YEARLY:
dumpcommand = "yearlydump";
- sprintf(AVDB, "%s/yearly.db", LOCATION);
+ (void)snprintf(AVDB, CF_MAXVARSIZE-1, "%s/yearly.db", LOCATION);
break;
default: /* weekly */
dumpcommand = "weeklydump";
- sprintf(AVDB, "%s/weekly.db", LOCATION);
+ (void)snprintf(AVDB, CF_MAXVARSIZE-1, "%s/weekly.db", LOCATION);
break;
}
- sprintf(begincommand, "<%s>", dumpcommand);
- sprintf(endcommand, "/%s", dumpcommand);
+ (void)snprintf(begincommand, sizeof(begincommand), "<%s>", dumpcommand);
+ (void)snprintf(endcommand, sizeof(endcommand), "/%s", dumpcommand);
Verbose("Importing to database: %s\n", AVDB);
@@ -1561,7 +1561,7 @@ void Import(FILE * fp, int dbtype)
exit(1);
}
skip(&buffer);
- sprintf(temp, "</%s>", command);
+ (void)snprintf(temp, sizeof(temp), "</%s>", command);
if (strncmp(buffer, temp, strlen(temp)) != 0)
{
fprintf(stderr, "Couldn't find </%s>!\n", command);
@@ -1727,7 +1727,7 @@ void parse_entry(char **buffer)
exit(1);
}
skip(buffer);
- sprintf(temp, "</%s>", command);
+ (void)snprintf(temp, sizeof(temp), "</%s>", command);
if (strncmp(*buffer, temp, strlen(temp)) != 0)
{
fprintf(stderr, "Couldn't find </%s>!\n", command);
@@ -2044,7 +2044,7 @@ struct Average *GetCurrentAverage(char *
Debug("No previous value for time index %s\n", timekey);
}
- sprintf(str, "%s", ctime(&last_time));
+ (void)snprintf(str, sizeof(str), "%s", ctime(&last_time));
Verbose("time key for last update was %s\n", ConvTimeKey2(str, dbtype));
Verbose("comparing to current timekey %s\n", timekey);
if (strcmp(ConvTimeKey2(str, dbtype), timekey) != 0)
@@ -2438,12 +2438,12 @@ int ArmClasses(struct Average av, char *
if(cfenvd_compatible)
{
unlink(ENV_NEW);
- strcpy(temp1, NAME);
- strcat(temp1, "_");
+ (void)strlcpy(temp1, NAME, sizeof(temp1));
+ (void)strlcat(temp1, "_", sizeof(temp1));
temp2[0] = '_';
temp2[1] = '\0';
- strcat(temp2, NAME);
- strcat(temp2, "=");
+ (void)strlcat(temp2, NAME, sizeof(temp2));
+ (void)strlcat(temp2, "=", sizeof(temp2));
for (i=0; i<10; i++)
{
@@ -2518,21 +2518,21 @@ int SetClasses(char *name, double variab
Debug(" Sensitivity too high ..\n");
buffer[0] = '\0';
- strcpy(buffer, name);
+ (void)strlcpy(buffer, name, sizeof(buffer));
if ((delta > 0) && (ldelta > 0))
{
- strcat(buffer, "_high");
+ (void)strlcat(buffer, "_high", sizeof(buffer));
*code = -6;
}
else if ((delta < 0) && (ldelta < 0))
{
- strcat(buffer, "_low");
+ (void)strlcat(buffer, "_low", sizeof(buffer));
*code = -4;
}
else
{
- strcat(buffer, "_normal");
+ (void)strlcat(buffer, "_normal", sizeof(buffer));
*code = -5;
}
@@ -2542,8 +2542,8 @@ int SetClasses(char *name, double variab
if (dev > 2.0 * sqrt(2.0))
{
- strcpy(buffer2, buffer);
- strcat(buffer2, "_microanomaly");
+ (void)strlcpy(buffer2, buffer, sizeof(buffer2));
+ (void)strlcat(buffer2, "_microanomaly", sizeof(buffer2));
Debugging2("!! %s !!\n", buffer2);
*code += -10;
AppendItem(classlist,buffer2,"2");
@@ -2553,21 +2553,21 @@ int SetClasses(char *name, double variab
else
{
buffer[0] = '\0';
- strcpy(buffer, name);
+ (void)strlcpy(buffer, name, sizeof(buffer));
if ((delta > 0) && (ldelta > 0))
{
- strcat(buffer, "_high");
+ (void)strlcat(buffer, "_high", sizeof(buffer));
*code = -6;
}
else if ((delta < 0) && (ldelta < 0))
{
- strcat(buffer, "_low");
+ (void)strlcat(buffer, "_low", sizeof(buffer));
*code = -4;
}
else
{
- strcat(buffer, "_normal");
+ (void)strlcat(buffer, "_normal", sizeof(buffer));
*code = -5;
}
@@ -2577,16 +2577,16 @@ int SetClasses(char *name, double variab
if (dev <= sqrt(2.0))
{
- strcpy(buffer2, buffer);
- strcat(buffer2, "_normal");
+ (void)strlcpy(buffer2, buffer, sizeof(buffer2));
+ (void)strlcat(buffer2, "_normal", sizeof(buffer2));
Debugging2("!! %s !!\n", buffer2);
*code += -20;
AppendItem(classlist,buffer2,"0");
}
else
{
- strcpy(buffer2, buffer);
- strcat(buffer2, "_dev1");
+ (void)strlcpy(buffer2, buffer, sizeof(buffer2));
+ (void)strlcat(buffer2, "_dev1", sizeof(buffer2));
Debugging2("!! %s !!\n", buffer2);
*code += -30;
AppendItem(classlist,buffer2,"0");
@@ -2594,8 +2594,8 @@ int SetClasses(char *name, double variab
if (dev > 2.0*sqrt(2.0))
{
- strcpy(buffer2, buffer);
- strcat(buffer2, "_dev2");
+ (void)strlcpy(buffer2, buffer, sizeof(buffer2));
+ (void)strlcat(buffer2, "_dev2", sizeof(buffer2));
Debugging2("!! %s !!\n", buffer2);
*code += -10;
AppendItem(classlist,buffer2,"2");
@@ -2604,8 +2604,8 @@ int SetClasses(char *name, double variab
if (dev > 3.0*sqrt(2.0))
{
- strcpy(buffer2, buffer);
- strcat(buffer2, "_anomaly");
+ (void)strlcpy(buffer2, buffer, sizeof(buffer2));
+ (void)strlcat(buffer2, "_anomaly", sizeof(buffer2));
Debugging2("!! %s !!\n", buffer2);
*code += -10;
AppendItem(classlist,buffer2,"3");
@@ -2625,13 +2625,13 @@ void SetVariable(char *name,double value
{
char var[CF_BUFSIZE];
- sprintf(var,"value_%s=%d",name,(int)value);
+ (void)snprintf(var,sizeof(var),"value_%s=%d",name,(int)value);
AppendItem(classlist,var,"");
- sprintf(var,"average_%s=%1.1f",name,average);
+ (void)snprintf(var,sizeof(var),"average_%s=%1.1f",name,average);
AppendItem(classlist,var,"");
- sprintf(var,"stddev_%s=%1.1f",name,stddev);
+ (void)snprintf(var,sizeof(var),"stddev_%s=%1.1f",name,stddev);
AppendItem(classlist,var,"");
}
@@ -2646,9 +2646,9 @@ void DoBatch(int dbtype)
double val=0;
float val1=0, val2=0, val3=0, val4=0, val5=0, val6=0, val7=0, val8=0, val9=0, val10=0;
int i = 0, j = 0, n = 0, y = 0, k = 0, w = 0;
- time_to_update = false;
int timeint = -1;
struct Average av;
+ time_to_update = false;
Verbose("Batch mode\n");
@@ -2762,11 +2762,11 @@ void DoBatch(int dbtype)
} else {
update_time = (time_t) timeint;
}
- strcpy(timebuf, ctime(&update_time));
+ (void)strlcpy(timebuf, ctime(&update_time), sizeof(timebuf));
Debug("- Time converted to %s, ", timebuf);
if(strcmp(timekey, ConvTimeKey2(timebuf, dbtype)) != 0)
k++;
- strcpy(timekey, ConvTimeKey2(timebuf, dbtype));
+ (void)strlcpy(timekey, ConvTimeKey2(timebuf, dbtype), sizeof(timekey));
Debug("then to %s\n", timekey);
if (feof(fp))
@@ -2961,7 +2961,7 @@ int OpenDatabase(int create)
char *GenTimeKey2(time_t now, int dbtype)
{
char str[64];
- sprintf(str, "%s", ctime(&now));
+ (void)snprintf(str, sizeof(str), "%s", ctime(&now));
return ConvTimeKey2(str, dbtype);
}
@@ -2986,10 +2986,10 @@ char *ConvTimeKey2(char *str, int dbtype
case DAILY:
break;
case YEARLY:
- sprintf(timekey, "%s%s:", buf2, buf3);
+ (void)snprintf(timekey, (64 * sizeof(char)), "%s%s:", buf2, buf3);
break;
default: /* weekly */
- sprintf(timekey, "%s:", buf1);
+ (void)snprintf(timekey, (64 * sizeof(char)), "%s:", buf1);
break;
}
@@ -2999,15 +2999,15 @@ char *ConvTimeKey2(char *str, int dbtype
timeinmins = 60*hr + min;
if(STEP == 1)
- sprintf(minbuf, "%04d", timeinmins / STEP );
+ (void)snprintf(minbuf, sizeof(minbuf), "%04d", timeinmins / STEP );
else if (STEP < 15)
- sprintf(minbuf, "%03d", timeinmins / STEP );
+ (void)snprintf(minbuf, sizeof(minbuf), "%03d", timeinmins / STEP );
else if (STEP < 145)
- sprintf(minbuf, "%02d", timeinmins / STEP );
+ (void)snprintf(minbuf, sizeof(minbuf), "%02d", timeinmins / STEP );
else
- sprintf(minbuf, "%d", timeinmins / STEP );
+ (void)snprintf(minbuf, sizeof(minbuf), "%d", timeinmins / STEP );
- strcat(timekey, minbuf);
+ (void)strlcat(timekey, minbuf, (64 * sizeof(char)));
return timekey;
}

View File

@ -1,193 +0,0 @@
$OpenBSD: patch-src_cfetoolgraph_c,v 1.2 2005/12/18 20:45:41 pvalchev Exp $
--- src/cfetoolgraph.c.orig Thu Jun 30 01:53:06 2005
+++ src/cfetoolgraph.c Sun Dec 18 12:41:13 2005
@@ -138,7 +138,7 @@ int main(int argc, char **argv)
break;
case 'p':
- strcpy(PATHNAME,optarg);
+ (void)strlcpy(PATHNAME,optarg,sizeof(PATHNAME));
break;
case 'd':
@@ -161,9 +161,9 @@ int main(int argc, char **argv)
}
if(PATHNAME[0] != '\0')
- sprintf(LOCATION, "%s/%s", PATHNAME, NAME);
+ (void)snprintf(LOCATION, sizeof(LOCATION), "%s/%s", PATHNAME, NAME);
else
- sprintf(LOCATION, "./%s", NAME);
+ (void)snprintf(LOCATION, sizeof(LOCATION), "./%s", NAME);
if(daily) {
snprintf(FILENAME, CF_BUFSIZE, "%s/daily.db", LOCATION);
@@ -277,7 +277,7 @@ void ReadAverages(int dbtype)
memset(&value, 0, sizeof(value));
memset(&ENTRY, 0, sizeof(ENTRY));
- strcpy(TIMEKEY, GenTimeKey2(NOW, dbtype));
+ (void)strlcpy(TIMEKEY, GenTimeKey2(NOW, dbtype), sizeof(TIMEKEY));
key.data = TIMEKEY;
key.size = strlen(TIMEKEY) + 1;
@@ -397,13 +397,13 @@ void WriteGraphFiles(int dbtype)
switch(dbtype)
{
case DAILY:
- sprintf(DIRNAME, "%s/daily-%s", LOCATION, ctime(&NOW));
+ (void)snprintf(DIRNAME, sizeof(DIRNAME), "%s/daily-%s", LOCATION, ctime(&NOW));
break;
case YEARLY:
- sprintf(DIRNAME, "%s/yearly-%s", LOCATION, ctime(&NOW));
+ (void)snprintf(DIRNAME, sizeof(DIRNAME), "%s/yearly-%s", LOCATION, ctime(&NOW));
break;
default: /* weekly */
- sprintf(DIRNAME, "%s/weekly-%s", LOCATION, ctime(&NOW));
+ (void)snprintf(DIRNAME, sizeof(DIRNAME), "%s/weekly-%s", LOCATION, ctime(&NOW));
break;
}
@@ -420,13 +420,13 @@ void WriteGraphFiles(int dbtype)
switch(dbtype)
{
case DAILY:
- sprintf(DIRNAME, "%s/daily-snapshot", LOCATION);
+ (void)snprintf(DIRNAME, sizeof(DIRNAME), "%s/daily-snapshot", LOCATION);
break;
case YEARLY:
- sprintf(DIRNAME, "%s/yearly-snapshot", LOCATION);
+ (void)snprintf(DIRNAME, sizeof(DIRNAME), "%s/yearly-snapshot", LOCATION);
break;
default: /* weekly */
- sprintf(DIRNAME, "%s/weekly-snapshot", LOCATION);
+ (void)snprintf(DIRNAME, sizeof(DIRNAME), "%s/weekly-snapshot", LOCATION);
break;
}
}
@@ -444,7 +444,7 @@ void WriteGraphFiles(int dbtype)
printf("Writing data to directory %s\n ", DIRNAME);
- sprintf(FLNAME, "%s/average", DIRNAME);
+ (void)snprintf(FLNAME, sizeof(FLNAME), "%s/average", DIRNAME);
if ((FPAV = fopen(FLNAME, "w")) == NULL)
{
@@ -452,7 +452,7 @@ void WriteGraphFiles(int dbtype)
exit(1);
}
- sprintf(FLNAME, "%s/stddev", DIRNAME);
+ (void)snprintf(FLNAME, sizeof(FLNAME), "%s/stddev", DIRNAME);
if ((FPVAR = fopen(FLNAME, "w")) == NULL)
{
@@ -460,7 +460,7 @@ void WriteGraphFiles(int dbtype)
exit(1);
}
- sprintf(FLNAME,"%s/graph", DIRNAME);
+ (void)snprintf(FLNAME,sizeof(FLNAME),"%s/graph", DIRNAME);
if ((FP = fopen(FLNAME,"w")) == NULL)
{
@@ -488,7 +488,7 @@ void WriteGraphFiles(int dbtype)
memset(&key, 0, sizeof(key));
memset(&value, 0, sizeof(value));
- strcpy(TIMEKEY, GenTimeKey2(NOW, dbtype));
+ (void)strlcpy(TIMEKEY, GenTimeKey2(NOW, dbtype), sizeof(TIMEKEY));
key.data = TIMEKEY;
key.size = strlen(TIMEKEY) + 1;
@@ -542,6 +542,9 @@ void WriteGraphFiles(int dbtype)
void WriteHistogram(int dbtype)
{
int numdays=0;
+ int position, day;
+ int weekly[CF_GRAINS];
+
/* Finally, look at the histogram */
printf("Writing histogram file now!\n");
@@ -554,9 +557,6 @@ void WriteHistogram(int dbtype)
}
}
- int position, day;
- int weekly[CF_GRAINS];
-
switch(dbtype)
{
case DAILY:
@@ -628,7 +628,7 @@ void WriteHistogram(int dbtype)
}
}
- sprintf(FLNAME, "%s/distr", DIRNAME);
+ (void)snprintf(FLNAME, sizeof(FLNAME), "%s/distr", DIRNAME);
if ((FPHIST = fopen(FLNAME, "w")) == NULL)
{
perror("fopen");
@@ -712,7 +712,7 @@ char *CanonifyName(char *str)
char *sp;
memset(buffer, 0, CF_BUFSIZE);
- strcpy(buffer, str);
+ (void)strlcpy(buffer, str, sizeof(buffer));
for (sp = buffer; *sp != '\0'; sp++)
{
@@ -786,7 +786,7 @@ struct Average FindHurstFunction(int sam
memset(&value, 0, sizeof(value));
memset(&ENTRY, 0, sizeof(ENTRY));
- strcpy(TIMEKEY, GenTimeKey2(NOW, dbtype));
+ (void)strlcpy(TIMEKEY, GenTimeKey2(NOW, dbtype), sizeof(TIMEKEY));
key.data = TIMEKEY;
key.size = strlen(TIMEKEY) + 1;
@@ -871,7 +871,7 @@ char *GenTimeKey2(time_t now, int dbtype
{
char str[64];
- sprintf(str, "%s", ctime(&now));
+ (void)snprintf(str, sizeof(str), "%s", ctime(&now));
return ConvTimeKey2(str, dbtype);
}
@@ -897,10 +897,10 @@ char *ConvTimeKey2(char *str, int dbtype
case DAILY:
break;
case YEARLY:
- sprintf(timekey, "%s%s:", buf2, buf3);
+ (void)snprintf(timekey, (64 * sizeof(char)), "%s%s:", buf2, buf3);
break;
default: /* weekly */
- sprintf(timekey, "%s:", buf1);
+ (void)snprintf(timekey, (64 * sizeof(char)), "%s:", buf1);
break;
}
@@ -910,15 +910,15 @@ char *ConvTimeKey2(char *str, int dbtype
timeinmins = 60*hr + min;
if(STEP == 1)
- sprintf(minbuf, "%04d", timeinmins / STEP );
+ (void)snprintf(minbuf, sizeof(minbuf), "%04d", timeinmins / STEP );
else if (STEP < 15)
- sprintf(minbuf, "%03d", timeinmins / STEP );
+ (void)snprintf(minbuf, sizeof(minbuf), "%03d", timeinmins / STEP );
else if (STEP < 145)
- sprintf(minbuf, "%02d", timeinmins / STEP );
+ (void)snprintf(minbuf, sizeof(minbuf), "%02d", timeinmins / STEP );
else
- sprintf(minbuf, "%d", timeinmins / STEP );
+ (void)snprintf(minbuf, sizeof(minbuf), "%d", timeinmins / STEP );
- strcat(timekey, minbuf);
+ (void)strlcat(timekey, minbuf, (64 * sizeof(char)));
return timekey;
}

View File

@ -1,163 +0,0 @@
$OpenBSD: patch-src_cfexecd_c,v 1.5 2005/10/27 21:47:28 sturm Exp $
--- src/cfexecd.c.orig Wed Aug 10 13:25:08 2005
+++ src/cfexecd.c Fri Oct 21 16:35:55 2005
@@ -147,7 +147,7 @@ Banner("Check options");
NOSPLAY = false;
-sprintf(VPREFIX, "cfexecd");
+(void)snprintf(VPREFIX, 40, "cfexecd");
openlog(VPREFIX,LOG_PID|LOG_NOWAIT|LOG_ODELAY,LOG_DAEMON);
while ((c=getopt_long(argc,argv,"L:d:vhpqFV1g",CFDOPTIONS,&optindex)) != EOF)
@@ -216,15 +216,15 @@ LOGGING = true; /* Do
/* XXX Initialize workdir for non privileged users */
-strcpy(CFWORKDIR,WORKDIR);
+(void)strlcpy(CFWORKDIR,WORKDIR,sizeof(CFWORKDIR));
if (getuid() > 0)
{
char *homedir;
if ((homedir = getenv("HOME")) != NULL)
{
- strcpy(CFWORKDIR,homedir);
- strcat(CFWORKDIR,"/.cfagent");
+ (void)strlcpy(CFWORKDIR,homedir,sizeof(CFWORKDIR));
+ (void)strlcat(CFWORKDIR,"/.cfagent",sizeof(CFWORKDIR));
}
}
@@ -246,7 +246,7 @@ strncpy(VLOGDIR,CFWORKDIR,CF_BUFSIZE-1);
VCANONICALFILE = strdup(CanonifyName(VINPUTFILE));
GetNameInfo();
-strcpy(VUQNAME,VSYSNAME.nodename);
+(void)strlcpy(VUQNAME,VSYSNAME.nodename,CF_MAXVARSIZE);
MAILTO[0] = '\0';
MAILFROM[0] = '\0';
@@ -564,7 +564,7 @@ for (ip = SCHEDULE; ip != NULL; ip = ip-
DeleteItemList(VHEAP);
VHEAP = NULL;
GetNameInfo();
- strcpy(VUQNAME,VSYSNAME.nodename);
+ (void)strlcpy(VUQNAME,VSYSNAME.nodename,CF_MAXVARSIZE);
return true;
}
}
@@ -572,7 +572,7 @@ for (ip = SCHEDULE; ip != NULL; ip = ip-
DeleteItemList(VHEAP);
VHEAP = NULL;
GetNameInfo();
-strcpy(VUQNAME,VSYSNAME.nodename);
+(void)strlcpy(VUQNAME,VSYSNAME.nodename,CF_MAXVARSIZE);
return false;
}
@@ -980,7 +980,7 @@ if (!Dialogue(sd,NULL))
goto mail_err;
}
-sprintf(VBUFF,"HELO %s\r\n",VFQNAME);
+(void)snprintf(VBUFF,sizeof(VBUFF),"HELO %s\r\n",VFQNAME);
Debug("%s",VBUFF);
if (!Dialogue(sd,VBUFF))
@@ -990,7 +990,7 @@ if (!Dialogue(sd,VBUFF))
if (strlen(MAILFROM) > 0)
{
- sprintf(VBUFF,"MAIL FROM: <%s>\r\n",MAILFROM);
+ (void)snprintf(VBUFF,sizeof(VBUFF),"MAIL FROM: <%s>\r\n",MAILFROM);
Debug("%s",VBUFF);
}
else
@@ -1000,12 +1000,12 @@ else
if (strlen(domain) > 0)
{
- sprintf(VBUFF,"MAIL FROM: <cfengine@%s>\r\n",domain);
+ (void)snprintf(VBUFF,sizeof(VBUFF),"MAIL FROM: <cfengine@%s>\r\n",domain);
Debug("%s",VBUFF);
}
else
{
- sprintf(VBUFF,"MAIL FROM: <%s>\r\n",to);
+ (void)snprintf(VBUFF,sizeof(VBUFF),"MAIL FROM: <%s>\r\n",to);
Debug("%s",VBUFF);
}
}
@@ -1015,7 +1015,7 @@ if (!Dialogue(sd,VBUFF))
goto mail_err;
}
-sprintf(VBUFF,"RCPT TO: <%s>\r\n",to);
+(void)snprintf(VBUFF,sizeof(VBUFF),"RCPT TO: <%s>\r\n",to);
Debug("%s",VBUFF);
if (!Dialogue(sd,VBUFF))
@@ -1030,12 +1030,12 @@ if (!Dialogue(sd,"DATA\r\n"))
if (anomaly)
{
- sprintf(VBUFF,"Subject: **!! (%s/%s)\r\n",VFQNAME,VIPADDRESS);
+ (void)snprintf(VBUFF,sizeof(VBUFF),"Subject: **!! (%s/%s)\r\n",VFQNAME,VIPADDRESS);
Debug("%s",VBUFF);
}
else
{
- sprintf(VBUFF,"Subject: (%s/%s)\r\n",VFQNAME,VIPADDRESS);
+ (void)snprintf(VBUFF,sizeof(VBUFF),"Subject: (%s/%s)\r\n",VFQNAME,VIPADDRESS);
Debug("%s",VBUFF);
}
@@ -1051,18 +1051,18 @@ sent=send(sd,VBUFF,strlen(VBUFF),0);
if (strlen(MAILFROM) == 0)
{
- sprintf(VBUFF,"From: cfengine@%s\r\n",VFQNAME);
+ (void)snprintf(VBUFF,sizeof(VBUFF),"From: cfengine@%s\r\n",VFQNAME);
Debug("%s",VBUFF);
}
else
{
- sprintf(VBUFF,"From: %s\r\n",MAILFROM);
+ (void)snprintf(VBUFF,sizeof(VBUFF),"From: %s\r\n",MAILFROM);
Debug("%s",VBUFF);
}
sent=send(sd,VBUFF,strlen(VBUFF),0);
-sprintf(VBUFF,"To: %s\r\n\r\n",to);
+(void)snprintf(VBUFF,sizeof(VBUFF),"To: %s\r\n\r\n",to);
Debug("%s",VBUFF);
sent=send(sd,VBUFF,strlen(VBUFF),0);
@@ -1075,14 +1075,14 @@ while(!feof(fp))
if (strlen(VBUFF) > 0)
{
VBUFF[strlen(VBUFF)-1] = '\r';
- strcat(VBUFF, "\n");
+ (void)strlcat(VBUFF, "\n",sizeof(VBUFF));
count++;
sent=send(sd,VBUFF,strlen(VBUFF),0);
}
if ((MAXLINES != INF_LINES) && (count > MAXLINES))
{
- sprintf(VBUFF,"\r\n[Mail truncated by cfengine. File is at %s on %s]\r\n",file,VFQNAME);
+ (void)snprintf(VBUFF,sizeof(VBUFF),"\r\n[Mail truncated by cfengine. File is at %s on %s]\r\n",file,VFQNAME);
sent=send(sd,VBUFF,strlen(VBUFF),0);
break;
}
@@ -1104,7 +1104,7 @@ mail_err:
fclose(fp);
close(sd);
-sprintf(VBUFF, "Cannot mail to %s.", to);
+(void)snprintf(VBUFF, sizeof(VBUFF), "Cannot mail to %s.", to);
CfLog(cflogonly,VBUFF,"");
}

View File

@ -1,30 +0,0 @@
$OpenBSD: patch-src_cfkey_c,v 1.2 2005/07/21 15:16:46 aanriot Exp $
--- src/cfkey.c.orig Thu Apr 7 15:26:44 2005
+++ src/cfkey.c Fri Jul 15 12:24:00 2005
@@ -149,20 +149,21 @@ void Initialize()
umask(077);
/* XXX Initialize workdir for non privileged users */
- strcpy(CFWORKDIR,WORKDIR);
+ (void)strlcpy(CFWORKDIR,WORKDIR,sizeof(CFWORKDIR));
if (geteuid() > 0)
{
char *homedir;
if ((homedir = getenv("HOME")) != NULL)
{
- strcpy(CFWORKDIR,homedir);
- strcat(CFWORKDIR,"/.cfagent");
+ (void)strlcpy(CFWORKDIR,homedir,sizeof(CFWORKDIR));
+ (void)strlcat(CFWORKDIR,"/.cfagent",sizeof(CFWORKDIR));
}
}
-strcpy(VLOCKDIR,CFWORKDIR);
-strcpy(VLOGDIR,CFWORKDIR);
+(void)strlcpy(VLOCKDIR,CFWORKDIR,CF_BUFSIZE);
+(void)strlcpy(VLOGDIR,CFWORKDIR,CF_BUFSIZE);
+
OpenSSL_add_all_algorithms();
ERR_load_crypto_strings();

View File

@ -1,118 +1,21 @@
$OpenBSD: patch-src_cflex_c,v 1.2 2005/12/18 20:44:43 pvalchev Exp $
--- src/cflex.c.orig Sat Oct 1 06:34:57 2005
+++ src/cflex.c Sun Dec 18 12:28:19 2005
@@ -9,6 +11,7 @@
#define YY_FLEX_MINOR_VERSION 5
#include <stdio.h>
+#include <errno.h>
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
@@ -32,7 +35,7 @@
$OpenBSD: patch-src_cflex_c,v 1.3 2007/10/12 20:12:19 sturm Exp $
--- src/cflex.c.orig Tue May 29 20:07:57 2007
+++ src/cflex.c Sun Sep 2 16:02:56 2007
@@ -93,7 +93,7 @@ typedef unsigned int flex_uint32_t;
#else /* ! __cplusplus */
-#if __STDC__
+#ifdef __STDC__
#define YY_USE_PROTOS
#define YY_USE_CONST
@@ -1941,7 +1944,7 @@ char *yytext;
#define INASSIGN 3
#define CFSERVD 4
-#line 1945 "lex.yy.c"
+#line 1948 "lex.yy.c"
@@ -4556,7 +4556,7 @@ static void yy_load_buffer_state (void)
}
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -1998,7 +2001,7 @@ static int yy_top_state YY_PROTO(( void
#ifdef YY_MALLOC_DECL
YY_MALLOC_DECL
#else
-#if __STDC__
+#ifdef __STDC__
#ifndef __cplusplus
#include <stdlib.h>
#endif
@@ -2096,7 +2099,7 @@ YY_DECL
-#line 2100 "lex.yy.c"
+#line 2103 "lex.yy.c"
if ( yy_init )
{
@@ -2376,7 +2379,7 @@ YY_RULE_SETUP
#line 236 "cflex.l"
{
Debug1("LFARROW %s\n",yytext);
- strcpy(LINKFROM,CURRENTOBJECT);
+ (void)strlcpy(LINKFROM,CURRENTOBJECT,CF_BUFSIZE);
ACTION_IS_LINKCHILDREN = true;
FORCELINK='y';
return LARROW;
@@ -2387,7 +2390,7 @@ YY_RULE_SETUP
#line 245 "cflex.l"
{
Debug1("FARROW %s\n",yytext);
- strcpy(LINKFROM,CURRENTOBJECT);
+ (void)strlcpy(LINKFROM,CURRENTOBJECT,CF_BUFSIZE);
ACTION_IS_LINK = true;
FORCELINK='y';
return ARROW;
@@ -2398,7 +2401,7 @@ YY_RULE_SETUP
#line 253 "cflex.l"
{
Debug1("ARROW %s\n",yytext);
- strcpy(LINKFROM,CURRENTOBJECT);
+ (void)strlcpy(LINKFROM,CURRENTOBJECT,CF_BUFSIZE);
ACTION_IS_LINK = true;
FORCELINK='n';
return ARROW;
@@ -2409,7 +2412,7 @@ YY_RULE_SETUP
#line 262 "cflex.l"
{
Debug1("LARROW %s\n",yytext);
- strcpy(LINKFROM,CURRENTOBJECT);
+ (void)strlcpy(LINKFROM,CURRENTOBJECT,CF_BUFSIZE);
ACTION_IS_LINKCHILDREN = true;
FORCELINK='n';
return LARROW;
@@ -2710,7 +2713,7 @@ YY_RULE_SETUP
#line 510 "cflex.l"
ECHO;
YY_BREAK
-#line 2714 "lex.yy.c"
+#line 2717 "lex.yy.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(INCONTROL):
case YY_STATE_EOF(BRACELIST):
@@ -3280,7 +3283,7 @@ YY_BUFFER_STATE b;
#ifndef YY_ALWAYS_INTERACTIVE
#ifndef YY_NEVER_INTERACTIVE
-extern int isatty YY_PROTO(( int ));
-extern int isatty (int );
+#include <unistd.h>
#endif
#endif
@@ -3294,6 +3297,8 @@ FILE *file;
{
+ int oerrno = errno;
+
yy_flush_buffer( b );
b->yy_input_file = file;
@@ -3308,6 +3313,7 @@ FILE *file;
b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
#endif
#endif
+ errno = oerrno;
}
#endif /* __cplusplus */
/* Initializes or reinitializes a buffer.

View File

@ -1,39 +0,0 @@
$OpenBSD: patch-src_cflex_l,v 1.1 2005/10/27 21:47:28 sturm Exp $
--- src/cflex.l.orig Sat Oct 1 08:34:22 2005
+++ src/cflex.l Fri Oct 21 16:35:55 2005
@@ -235,7 +235,7 @@ editfiles: {
{lforcearrow} {
Debug1("LFARROW %s\n",yytext);
- strcpy(LINKFROM,CURRENTOBJECT);
+ (void)strlcpy(LINKFROM,CURRENTOBJECT,CF_BUFSIZE);
ACTION_IS_LINKCHILDREN = true;
FORCELINK='y';
return LARROW;
@@ -244,7 +244,7 @@ editfiles: {
{forcearrow} {
Debug1("FARROW %s\n",yytext);
- strcpy(LINKFROM,CURRENTOBJECT);
+ (void)strlcpy(LINKFROM,CURRENTOBJECT,CF_BUFSIZE);
ACTION_IS_LINK = true;
FORCELINK='y';
return ARROW;
@@ -252,7 +252,7 @@ editfiles: {
{arrow} {
Debug1("ARROW %s\n",yytext);
- strcpy(LINKFROM,CURRENTOBJECT);
+ (void)strlcpy(LINKFROM,CURRENTOBJECT,CF_BUFSIZE);
ACTION_IS_LINK = true;
FORCELINK='n';
return ARROW;
@@ -261,7 +261,7 @@ editfiles: {
{larrow} {
Debug1("LARROW %s\n",yytext);
- strcpy(LINKFROM,CURRENTOBJECT);
+ (void)strlcpy(LINKFROM,CURRENTOBJECT,CF_BUFSIZE);
ACTION_IS_LINKCHILDREN = true;
FORCELINK='n';
return LARROW;

View File

@ -1,39 +0,0 @@
$OpenBSD: patch-src_cflex_l_in,v 1.2 2004/08/08 14:02:11 sturm Exp $
--- src/cflex.l.in.orig Mon Jun 7 14:44:12 2004
+++ src/cflex.l.in Mon Aug 2 13:30:33 2004
@@ -235,7 +235,7 @@ editfiles: {
{lforcearrow} {
Debug1("LFARROW %s\n",yytext);
- strcpy(LINKFROM,CURRENTOBJECT);
+ (void)strlcpy(LINKFROM,CURRENTOBJECT,CF_BUFSIZE);
ACTION_IS_LINKCHILDREN = true;
FORCELINK='y';
return LARROW;
@@ -244,7 +244,7 @@ editfiles: {
{forcearrow} {
Debug1("FARROW %s\n",yytext);
- strcpy(LINKFROM,CURRENTOBJECT);
+ (void)strlcpy(LINKFROM,CURRENTOBJECT,CF_BUFSIZE);
ACTION_IS_LINK = true;
FORCELINK='y';
return ARROW;
@@ -252,7 +252,7 @@ editfiles: {
{arrow} {
Debug1("ARROW %s\n",yytext);
- strcpy(LINKFROM,CURRENTOBJECT);
+ (void)strlcpy(LINKFROM,CURRENTOBJECT,CF_BUFSIZE);
ACTION_IS_LINK = true;
FORCELINK='n';
return ARROW;
@@ -261,7 +261,7 @@ editfiles: {
{larrow} {
Debug1("LARROW %s\n",yytext);
- strcpy(LINKFROM,CURRENTOBJECT);
+ (void)strlcpy(LINKFROM,CURRENTOBJECT,CF_BUFSIZE);
ACTION_IS_LINKCHILDREN = true;
FORCELINK='n';
return LARROW;

View File

@ -1,111 +0,0 @@
$OpenBSD: patch-src_cfrun_c,v 1.4 2005/10/27 21:47:28 sturm Exp $
--- src/cfrun.c.orig Wed Aug 10 05:01:17 2005
+++ src/cfrun.c Thu Oct 27 23:06:44 2005
@@ -234,7 +234,7 @@ for (i = 1; i < argc; i++)
/* XXX Initialize workdir for non privileged users */
- strcpy(CFWORKDIR,WORKDIR);
+ (void)strlcpy(CFWORKDIR,WORKDIR,sizeof(CFWORKDIR));
if (getuid() > 0)
{
@@ -242,7 +242,7 @@ for (i = 1; i < argc; i++)
if ((homedir = getenv("HOME")) != NULL)
{
strncpy(CFWORKDIR,homedir,CF_BUFSIZE-16);
- strcat(CFWORKDIR,"/.cfagent");
+ (void)strlcat(CFWORKDIR,"/.cfagent",sizeof(CFWORKDIR));
}
}
@@ -255,14 +255,15 @@ for (i = 1; i < argc; i++)
Debug("FQNAME = %s, WORKDIR = %s\n",VFQNAME,WORKDIR);
- sprintf(VPREFIX,"cfrun:%s",VFQNAME);
+ (void)snprintf(VPREFIX,40,"cfrun:%s",VFQNAME);
/* Read hosts file */
umask(077);
- strcpy(VLOCKDIR,CFWORKDIR);
- strcpy(VLOGDIR,CFWORKDIR);
+ (void)strlcpy(VLOCKDIR,CFWORKDIR,CF_BUFSIZE);
+ (void)strlcpy(VLOGDIR,CFWORKDIR,CF_BUFSIZE);
+
OpenSSL_add_all_algorithms();
ERR_load_crypto_strings();
@@ -296,7 +297,7 @@ CONN = NewAgentConn();
if (storeinfile)
{
- sprintf(filebuffer, "%s/%s", OUTPUTDIR, host);
+ (void)snprintf(filebuffer, sizeof(filebuffer), "%s/%s", OUTPUTDIR, host);
if ((fp = fopen(filebuffer, "w")) == NULL)
{
return false;
@@ -566,10 +567,10 @@ if (!strchr(VCFRUNHOSTS, '/'))
{
if ((sp=getenv(CF_INPUTSVAR)) != NULL)
{
- strcpy(filename,sp);
+ (void)strlcpy(filename,sp,sizeof(filename));
if (filename[strlen(filename)-1] != '/')
{
- strcat(filename,"/");
+ (void)strlcat(filename,"/",sizeof(filename));
}
}
else
@@ -578,7 +579,7 @@ if (!strchr(VCFRUNHOSTS, '/'))
}
}
-strcat(filename,cfg_fic);
+(void)strlcat(filename,cfg_fic,sizeof(filename));
if ((fp = fopen(filename,"r")) == NULL) /* Open root file */
{
@@ -603,7 +604,7 @@ while (!feof(fp))
if (strncmp(line,"hostnamekeys",6) == 0)
{
- char buf[16];
+ char buf[296];
buf[0] = '\0';
sscanf(line,"hostnamekeys = %295[^# \n]",buf);
Verbose("Hostname keys\n");
@@ -714,8 +715,8 @@ while (!feof(fp))
if ((!strstr(buffer,".")) && (strlen(VDOMAIN) > 0))
{
- strcat(buffer,".");
- strcat(buffer,VDOMAIN);
+ (void)strlcat(buffer,".",sizeof(buffer));
+ (void)strlcat(buffer,VDOMAIN,sizeof(buffer));
}
if (!IsItemIn(VCFRUNHOSTLIST,buffer))
@@ -773,8 +774,8 @@ for (ip = VCFRUNCLASSES; ip != NULL; ip
memset(sendbuffer,0,CF_BUFSIZE);
}
- strcat(sendbuffer,ip->name);
- strcat(sendbuffer," ");
+ (void)strlcat(sendbuffer,ip->name,CF_BUFSIZE);
+ (void)strlcat(sendbuffer," ",CF_BUFSIZE);
sp += strlen(ip->name)+1;
used += strlen(ip->name)+1;
@@ -793,7 +794,7 @@ if (used + strlen(CFD_TERMINATOR) +2 > C
memset(sendbuffer,0,CF_BUFSIZE);
}
-sprintf(sp, "%s", CFD_TERMINATOR);
+(void)snprintf(sp, CF_BUFSIZE, "%s", CFD_TERMINATOR);
if (SendTransaction(sd,sendbuffer,0,CF_DONE) == -1)
{

View File

@ -1,196 +0,0 @@
$OpenBSD: patch-src_cfservd_c,v 1.4 2005/10/27 21:47:28 sturm Exp $
--- src/cfservd.c.orig Thu Sep 22 15:57:18 2005
+++ src/cfservd.c Fri Oct 21 16:35:55 2005
@@ -171,10 +171,10 @@ void CheckOptsAndInit(int argc,char **ar
int c;
SetContext("server");
-sprintf(VPREFIX, "cfservd");
+(void)snprintf(VPREFIX, 40, "cfservd");
CfOpenLog();
-strcpy(VINPUTFILE,CFD_INPUT);
-strcpy(CFLOCK,"cfservd");
+(void)strlcpy(VINPUTFILE,CFD_INPUT,CF_BUFSIZE);
+(void)strlcpy(CFLOCK,"cfservd",sizeof(CFLOCK));
OUTPUT[0] = '\0';
/*
@@ -272,15 +272,15 @@ if ((CFSTARTTIME = time((time_t *)NULL))
/* XXX Initialize workdir for non privileged users */
- strcpy(CFWORKDIR,WORKDIR);
+ (void)strlcpy(CFWORKDIR,WORKDIR,sizeof(CFWORKDIR));
if (getuid() > 0)
{
char *homedir;
if ((homedir = getenv("HOME")) != NULL)
{
- strcpy(CFWORKDIR,homedir);
- strcat(CFWORKDIR,"/.cfagent");
+ (void)strlcpy(CFWORKDIR,homedir,sizeof(CFWORKDIR));
+ (void)strlcat(CFWORKDIR,"/.cfagent",sizeof(CFWORKDIR));
}
}
@@ -293,7 +293,7 @@ strncpy(VLOCKDIR,CFWORKDIR,CF_BUFSIZE-1)
VIFELAPSED = CF_EXEC_IFELAPSED;
VEXPIREAFTER = CF_EXEC_EXPIREAFTER;
-strcpy(VDOMAIN,"undefined.domain");
+(void)strlcpy(VDOMAIN,"undefined.domain",sizeof(VDOMAIN));
VCANONICALFILE = strdup(CanonifyName(VINPUTFILE));
VREPOSITORY = strdup("\0");
@@ -1057,7 +1057,7 @@ if (CFDSTARTTIME < newstat.st_mtime)
DeleteItemList(VIMPORT);
DeleteAuthList(VADMIT);
DeleteAuthList(VDENY);
- strcpy(VDOMAIN,"undefined.domain");
+ (void)strlcpy(VDOMAIN,"undefined.domain",sizeof(VDOMAIN));
VADMIT = VADMITTOP = NULL;
VDENY = VDENYTOP = NULL;
@@ -1437,7 +1437,7 @@ switch (GetCommand(recvbuffer))
if ((tloc = time((time_t *)NULL)) == -1)
{
- sprintf(conn->output,"Couldn't read system clock\n");
+ (void)snprintf(conn->output,CF_BUFSIZE*2,"Couldn't read system clock\n");
CfLog(cfinform,conn->output,"time");
SendTransaction(conn->sd_reply,"BAD: clocks out of synch",0,CF_DONE);
return true;
@@ -1502,7 +1502,7 @@ switch (GetCommand(recvbuffer))
}
- sprintf (sendbuffer,"BAD: Request denied\n");
+ (void)snprintf (sendbuffer,sizeof(sendbuffer),"BAD: Request denied\n");
SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE);
CfLog(cfinform,"Closing connection\n","");
return false;
@@ -1610,7 +1610,7 @@ if ((CFSTARTTIME = time((time_t *)NULL))
if (GetMacroValue(CONTEXTID,"cfrunCommand") == NULL)
{
Verbose("cfservd exec request: no cfrunCommand defined\n");
- sprintf(sendbuffer,"Exec request: no cfrunCommand defined\n");
+ (void)snprintf(sendbuffer,CF_BUFSIZE,"Exec request: no cfrunCommand defined\n");
SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE);
return;
}
@@ -1651,8 +1651,8 @@ else
{
if ((args != NULL) & (strlen(args) > 0))
{
- strcat(ebuff," ");
- strcat(ebuff,args);
+ (void)strlcat(ebuff," ",sizeof(ebuff));
+ (void)strlcat(ebuff,args,sizeof(ebuff));
snprintf(sendbuffer,CF_BUFSIZE,"cfservd Executing %s\n",ebuff);
SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE);
@@ -2568,7 +2568,7 @@ if (S_ISLNK(statbuf.st_mode))
if (readlink(filename,linkbuf,CF_BUFSIZE-1) == -1)
{
- sprintf(sendbuffer,"BAD: unable to read link\n");
+ (void)snprintf(sendbuffer,CF_BUFSIZE,"BAD: unable to read link\n");
CfLog(cferror,sendbuffer,"readlink");
SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE);
return -1;
@@ -2671,12 +2671,12 @@ SendTransaction(conn->sd_reply,sendbuffe
if (cfst.cf_readlink != NULL)
{
- strcpy(sendbuffer,"OK:");
- strcat(sendbuffer,cfst.cf_readlink);
+ (void)strlcpy(sendbuffer,"OK:",CF_BUFSIZE);
+ (void)strlcat(sendbuffer,cfst.cf_readlink,CF_BUFSIZE);
}
else
{
- sprintf(sendbuffer,"OK:");
+ (void)snprintf(sendbuffer,CF_BUFSIZE,"OK:");
}
SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE);
@@ -2878,13 +2878,13 @@ memset(sendbuffer,0,CF_BUFSIZE);
if (ChecksumChanged(filename,digest,cfverbose,true,'m'))
{
- sprintf(sendbuffer,"%s",CFD_TRUE);
+ (void)snprintf(sendbuffer,CF_BUFSIZE,"%s",CFD_TRUE);
Debug("Checksums didn't match\n");
SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE);
}
else
{
- sprintf(sendbuffer,"%s",CFD_FALSE);
+ (void)snprintf(sendbuffer,CF_BUFSIZE,"%s",CFD_FALSE);
Debug("Checksums matched ok\n");
SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE);
}
@@ -2902,7 +2902,7 @@ Debug("CfOpenDirectory(%s)\n",dirname);
if (*dirname != '/')
{
- sprintf(sendbuffer,"BAD: request to access a non-absolute filename\n");
+ (void)snprintf(sendbuffer,CF_BUFSIZE,"BAD: request to access a non-absolute filename\n");
SendTransaction(conn->sd_reply,sendbuffer,0,CF_DONE);
return -1;
}
@@ -2934,7 +2934,7 @@ for (dirp = readdir(dirh); dirp != NULL;
offset += strlen(dirp->d_name) + 1; /* + zero byte separator */
}
-strcpy(sendbuffer+offset,CFD_TERMINATOR);
+(void)strlcpy(sendbuffer+offset,CFD_TERMINATOR,CF_BUFSIZE - offset);
SendTransaction(conn->sd_reply,sendbuffer,offset+2+strlen(CFD_TERMINATOR),CF_DONE);
Debug("END CfOpenDirectory(%s)\n",dirname);
closedir(dirh);
@@ -2949,7 +2949,7 @@ void Terminate(int sd)
memset(buffer,0,CF_BUFSIZE);
-strcpy(buffer,CFD_TERMINATOR);
+(void)strlcpy(buffer,CFD_TERMINATOR,sizeof(buffer));
if (SendTransaction(sd,buffer,strlen(buffer)+1,CF_DONE) == -1)
{
@@ -3168,7 +3168,7 @@ Debug("Checking to see if we have seen t
if ((errno = db_create(&dbp,NULL,0)) != 0)
{
- sprintf(OUTPUT,"Couldn't open average database %s\n",keydb);
+ (void)snprintf(OUTPUT,sizeof(OUTPUT),"Couldn't open average database %s\n",keydb);
CfLog(cferror,OUTPUT,"db_open");
return false;
}
@@ -3179,7 +3179,7 @@ if ((errno = dbp->open(dbp,keydb,NULL,DB
if ((errno = dbp->open(dbp,NULL,keydb,NULL,DB_BTREE,DB_CREATE,0644)) != 0)
#endif
{
- sprintf(OUTPUT,"Couldn't open average database %s\n",keydb);
+ (void)snprintf(OUTPUT,sizeof(OUTPUT),"Couldn't open average database %s\n",keydb);
CfLog(cferror,OUTPUT,"db_open");
return false;
}
@@ -3252,7 +3252,7 @@ if ((DHCPLIST != NULL) && IsFuzzyItemIn(
if ((errno = db_create(&dbp,NULL,0)) != 0)
{
- sprintf(OUTPUT,"Couldn't open average database %s\n",keydb);
+ (void)snprintf(OUTPUT,sizeof(OUTPUT),"Couldn't open average database %s\n",keydb);
CfLog(cferror,OUTPUT,"db_open");
return;
}
@@ -3263,7 +3263,7 @@ if ((DHCPLIST != NULL) && IsFuzzyItemIn(
if ((errno = dbp->open(dbp,NULL,keydb,NULL,DB_BTREE,DB_CREATE,0644)) != 0)
#endif
{
- sprintf(OUTPUT,"Couldn't open average database %s\n",keydb);
+ (void)snprintf(OUTPUT,sizeof(OUTPUT),"Couldn't open average database %s\n",keydb);
CfLog(cferror,OUTPUT,"db_open");
return;
}

View File

@ -1,61 +0,0 @@
$OpenBSD: patch-src_cfshow_c,v 1.1 2005/07/21 15:16:46 aanriot Exp $
--- src/cfshow.c.orig Thu Feb 10 15:19:37 2005
+++ src/cfshow.c Tue Jul 19 12:02:08 2005
@@ -131,7 +131,7 @@ while ((c=getopt_long(argc,argv,"hdvaVls
}
-strcpy(CFWORKDIR,WORKDIR);
+(void)strlcpy(CFWORKDIR,WORKDIR,sizeof(CFWORKDIR));
if (getuid() > 0)
{
@@ -139,8 +139,8 @@ if (getuid() > 0)
if ((homedir = getenv("HOME")) != NULL)
{
- strcpy(CFWORKDIR,homedir);
- strcat(CFWORKDIR,"/.cfagent");
+ (void)strlcpy(CFWORKDIR,homedir,sizeof(CFWORKDIR));
+ (void)strlcat(CFWORKDIR,"/.cfagent",sizeof(CFWORKDIR));
}
}
}
@@ -248,7 +248,7 @@ while (dbcp->c_get(dbcp, &key, &value, D
char tbuf[CF_BUFSIZE];
memcpy(&then,value.data,sizeof(then));
- strcpy(hostname,(char *)key.data);
+ (void)strlcpy(hostname,(char *)key.data,sizeof(hostname));
if (value.data != NULL)
{
@@ -444,6 +444,7 @@ char *ChecksumDump(unsigned char digest[
{ unsigned int i;
static char buffer[EVP_MAX_MD_SIZE*4];
int len = 1;
+ int s = 0;
for (i = 0; buffer[i] != 0; i++)
{
@@ -460,15 +461,17 @@ else
switch(len)
{
- case 20: sprintf(buffer,"SHA= ");
+ case 20: (void)snprintf(buffer,sizeof(buffer),"SHA= ");
break;
- case 16: sprintf(buffer,"MD5= ");
+ case 16: (void)snprintf(buffer,sizeof(buffer),"MD5= ");
break;
}
for (i = 0; i < len; i++)
{
- sprintf((char *)(buffer+4+2*i),"%02x", digest[i]);
+ s = sizeof(buffer) - (4+2*i);
+ if (s > 0)
+ (void)snprintf((char *)(buffer+4+2*i),s,"%02x", digest[i]);
}
return buffer;

View File

@ -1,28 +0,0 @@
$OpenBSD: patch-src_comparray_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/comparray.c.orig 2004-06-10 10:50:03.000000000 -0400
+++ src/comparray.c 2004-06-10 11:30:47.000000000 -0400
@@ -39,6 +39,7 @@ int FixCompressedArrayValue(int i,char *
{ struct CompressedArray *ap;
char *sp;
+ size_t buflen;
for (ap = *start; ap != NULL; ap = ap->next)
{
@@ -57,13 +58,14 @@ if ((ap = (struct CompressedArray *)mall
FatalError("");
}
-if ((sp = malloc(strlen(value)+2)) == NULL)
+buflen = strlen(value) + 2;
+if ((sp = malloc(buflen)) == NULL)
{
CfLog(cferror,"Can't allocate memory in SetCompressedArray()","malloc");
FatalError("");
}
-strcpy(sp,value);
+(void)strlcpy(sp,value,buflen);
ap->key = i;
ap->value = sp;
ap->next = *start;

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-src_crypto_c,v 1.3 2005/07/21 15:16:46 aanriot Exp $
--- src/crypto.c.orig Wed Apr 6 10:53:12 2005
+++ src/crypto.c Fri Jul 15 12:24:01 2005
@@ -294,7 +294,7 @@ snprintf(buffer,CF_BUFSIZE,"%d%d%25s",(i
$OpenBSD: patch-src_crypto_c,v 1.4 2007/10/12 20:12:19 sturm Exp $
--- src/crypto.c.orig Mon Jul 10 13:53:47 2006
+++ src/crypto.c Sun Sep 2 15:44:05 2007
@@ -294,7 +294,7 @@ snprintf(buffer,CF_BUFSIZE,"%d%d%25s",(int)CFSTARTTIME
EVP_DigestUpdate(&context,buffer,CF_BUFSIZE);

View File

@ -1,476 +0,0 @@
$OpenBSD: patch-src_do_c,v 1.5 2005/10/27 21:47:28 sturm Exp $
--- src/do.c.orig Thu Sep 8 16:31:21 2005
+++ src/do.c Fri Oct 21 16:35:55 2005
@@ -76,9 +76,9 @@ for (ip = VMOUNTLIST; ip != NULL; ip=ip-
continue;
}
- strcpy(VBUFF,ip->name);
+ (void)strlcpy(VBUFF,ip->name,sizeof(VBUFF));
AddSlash(VBUFF);
- strcat(VBUFF,dirp->d_name);
+ (void)strlcat(VBUFF,dirp->d_name,sizeof(VBUFF));
if (IsHomeDir(VBUFF))
{
@@ -231,13 +231,13 @@ do
case crayos:
if (buf1[0] == '/')
{
- strcpy(host,VDEFAULTBINSERVER.name);
- strcpy(mounton,buf3);
+ (void)strlcpy(host,VDEFAULTBINSERVER.name,sizeof(host));
+ (void)strlcpy(mounton,buf3,sizeof(mounton));
}
else
{
sscanf(buf1,"%[^:]",host);
- strcpy(mounton,buf3);
+ (void)strlcpy(mounton,buf3,sizeof(mounton));
}
break;
@@ -247,13 +247,13 @@ do
case hp:
if (buf3[0] == '/')
{
- strcpy(host,VDEFAULTBINSERVER.name);
- strcpy(mounton,buf1);
+ (void)strlcpy(host,VDEFAULTBINSERVER.name,sizeof(host));
+ (void)strlcpy(mounton,buf1,sizeof(mounton));
}
else
{
sscanf(buf3,"%[^:]",host);
- strcpy(mounton,buf1);
+ (void)strlcpy(mounton,buf1,sizeof(mounton));
}
break;
@@ -262,18 +262,18 @@ do
if (buf1[0] == '/')
{
- strcpy(host,VDEFAULTBINSERVER.name);
- strcpy(mounton,buf2);
+ (void)strlcpy(host,VDEFAULTBINSERVER.name,sizeof(host));
+ (void)strlcpy(mounton,buf2,sizeof(host));
}
else
{
- strcpy(host,buf1);
- strcpy(mounton,buf3);
+ (void)strlcpy(host,buf1,sizeof(host));
+ (void)strlcpy(mounton,buf3,sizeof(mounton));
}
break;
- case cfnt: strcpy(mounton,buf2);
- strcpy(host,buf1);
+ case cfnt: (void)strlcpy(mounton,buf2,sizeof(mounton));
+ (void)strlcpy(host,buf1,sizeof(host));
break;
case unused1:
case unused2:
@@ -345,12 +345,12 @@ for (ptr = VMAKEPATH; ptr != NULL; ptr=p
pathbuff[0]='\0';
basename[0]='\0';
- strcpy(pathbuff,ip2->name);
+ (void)strlcpy(pathbuff,ip2->name,sizeof(pathbuff));
AddSlash(pathbuff);
- strcat(pathbuff,ip1->name);
+ (void)strlcat(pathbuff,ip1->name,sizeof(pathbuff));
AddSlash(pathbuff);
- strcat(pathbuff,"*/");
- strcat(pathbuff,ptr->path+5);
+ (void)strlcat(pathbuff,"*/",sizeof(pathbuff));
+ (void)strlcat(pathbuff,ptr->path+5,sizeof(pathbuff));
ExpandWildCardsAndDo(pathbuff,basename,DirectoriesWrapper,ptr);
}
@@ -636,7 +636,7 @@ if (strcmp(VDEFAULTBINSERVER.name,mailho
return;
}
-snprintf(lmailpath,CF_BUFSIZE,"%s:%s",mailhost,VMAILDIR[VSYSTEMHARDCLASS]);
+snprintf(lmailpath,CF_MAXVARSIZE,"%s:%s",mailhost,VMAILDIR[VSYSTEMHARDCLASS]);
if (IsItemIn(VMOUNTED,lmailpath)) /* Remote file system mounted on */
@@ -646,9 +646,9 @@ if (IsItemIn(VMOUNTED,lmailpath))
return;
}
-strcpy(mailserver,VMAILDIR[VSYSTEMHARDCLASS]);
+(void)strlcpy(mailserver,VMAILDIR[VSYSTEMHARDCLASS],sizeof(mailserver));
AddSlash(mailserver);
-strcat(mailserver,".");
+(void)strlcat(mailserver,".",sizeof(mailserver));
MakeDirectoriesFor(mailserver,'n'); /* Check directory is in place */
@@ -716,9 +716,9 @@ if (always || (strncmp(VMAILSERVER,VFQNA
continue;
}
- strcpy(VBUFF,spooldir);
+ (void)strlcpy(VBUFF,spooldir,sizeof(VBUFF));
AddSlash(VBUFF);
- strcat(VBUFF,dirp->d_name);
+ (void)strlcat(VBUFF,dirp->d_name,sizeof(VBUFF));
if (stat(VBUFF,&statbuf) != -1)
{
@@ -1194,9 +1194,9 @@ if (!IsPrivileged())
}
pathbuff[0]='\0';
basename[0]='\0';
- strcpy(pathbuff,ip2->name);
+ (void)strlcpy(pathbuff,ip2->name,sizeof(pathbuff));
AddSlash(pathbuff);
- strcat(pathbuff,ip1->name);
+ (void)strlcat(pathbuff,ip1->name,sizeof(pathbuff));
ExpandWildCardsAndDo(pathbuff,basename,RecHomeTidyWrapper,NULL);
}
@@ -1434,6 +1434,7 @@ void GetSetuidLog()
struct Item *ip;
FILE *fp;
char *sp;
+ size_t buflen;
if (!IsPrivileged()) /* Ignore this if not root */
{
@@ -1460,7 +1461,8 @@ else
FatalError("GetSetuidList() couldn't allocate memory #1");
}
- if ((sp = malloc(strlen(VBUFF)+2)) == NULL)
+ buflen = strlen(VBUFF) + 2;
+ if ((sp = malloc(buflen)) == NULL)
{
perror("malloc");
FatalError("GetSetuidList() couldn't allocate memory #2");
@@ -1477,7 +1479,7 @@ else
Debug2("SETUID-LOG: %s\n",VBUFF);
- strcpy(sp,VBUFF);
+ (void)strlcpy(sp,VBUFF,buflen);
ip->name = sp;
ip->next = NULL;
filetop = ip;
@@ -1768,7 +1770,7 @@ for (dp = VDISABLELIST; dp != NULL; dp=d
}
else
{
- strcpy(path,workname);
+ (void)strlcpy(path,workname,sizeof(path));
ChopLastNode(path);
AddSlash(path);
if (BufferOverflow(path,dp->destination))
@@ -1779,13 +1781,13 @@ for (dp = VDISABLELIST; dp != NULL; dp=d
ReleaseCurrentLock();
continue;
}
- strcat(path,dp->destination);
+ (void)strlcat(path,dp->destination,sizeof(path));
}
}
else
{
- strcpy(path,workname);
- strcat(path,".cfdisabled");
+ (void)strlcpy(path,workname,sizeof(path));
+ (void)strlcat(path,".cfdisabled",sizeof(path));
}
snprintf(OUTPUT,CF_BUFSIZE*2,"Disabling/renaming file %s to %s (pending repository move)\n",workname,path);
@@ -1913,15 +1915,15 @@ for (mp = VMOUNTABLES; mp != NULL; mp=mp
Debug("Mount: checking %s\n",mp->filesystem);
- strcpy(maketo,mountdir);
+ (void)strlcpy(maketo,mountdir,sizeof(maketo));
if (maketo[strlen(maketo)-1] == '/')
{
- strcat(maketo,".");
+ (void)strlcat(maketo,".",sizeof(maketo));
}
else
{
- strcat(maketo,"/.");
+ (void)strlcat(maketo,"/.",sizeof(maketo));
}
if (strcmp(host,VDEFAULTBINSERVER.name) == 0) /* A host never mounts itself nfs */
@@ -1933,11 +1935,11 @@ for (mp = VMOUNTABLES; mp != NULL; mp=mp
/* HvB: Bas van der Vlies */
if ( mp->readonly )
{
- strcpy(mountmode, "ro");
+ (void)strlcpy(mountmode, "ro", sizeof(mountmode));
}
else
{
- strcpy(mountmode, "rw");
+ (void)strlcpy(mountmode, "rw", sizeof(mountmode));
}
if (IsHomeDir(mountdir))
@@ -2007,15 +2009,15 @@ for (mp = VMISCMOUNT; mp != NULL; mp=mp-
mp->done = 'y';
}
- strcpy(maketo,mp->onto);
+ (void)strlcpy(maketo,mp->onto,sizeof(maketo));
if (maketo[strlen(maketo)-1] == '/')
{
- strcat(maketo,".");
+ (void)strlcat(maketo,".",sizeof(maketo));
}
else
{
- strcat(maketo,"/.");
+ (void)strlcat(maketo,"/.",sizeof(maketo));
}
if (strcmp(host,VDEFAULTBINSERVER.name) == 0) /* A host never mounts itself nfs */
@@ -2170,8 +2172,8 @@ for (ptr=VUNMOUNT; ptr != NULL; ptr=ptr-
{
if (VSYSTEMHARDCLASS == aix)
{
- strcpy (VBUFF,fs);
- strcat (VBUFF,":");
+ (void)strlcpy (VBUFF,fs,sizeof(VBUFF));
+ (void)strlcat (VBUFF,":",sizeof(VBUFF));
item = LocateNextItemContaining(filelist,VBUFF);
@@ -2195,8 +2197,8 @@ for (ptr=VUNMOUNT; ptr != NULL; ptr=ptr-
if (VSYSTEMHARDCLASS == ultrx) /* ensure name is not just a substring */
{
- strcpy (VBUFF,ptr->name);
- strcat (VBUFF,":");
+ (void)strlcpy (VBUFF,ptr->name,sizeof(VBUFF));
+ (void)strlcat (VBUFF,":",sizeof(VBUFF));
DeleteItemContaining(&filelist,VBUFF);
}
else
@@ -2577,14 +2579,14 @@ for (ip = VTIMEZONE; ip != NULL; ip=ip->
#ifdef NT
tzset();
- strcpy(tz,timezone());
+ (void)strlcpy(tz,timezone(),sizeof(tz));
#else
#ifndef AOS
#ifndef SUN4
tzset();
- strcpy(tz,tzname[0]);
+ (void)strlcpy(tz,tzname[0],sizeof(tz));
#else
@@ -2592,7 +2594,7 @@ for (ip = VTIMEZONE; ip != NULL; ip=ip->
{
printf("Couldn't read system clock\n\n");
}
- strcpy(tz,localtime(&tloc)->tm_zone);
+ (void)strlcpy(tz,localtime(&tloc)->tm_zone,sizeof(tz));
#endif /* SUN4 */
#endif /* AOS */
@@ -2750,8 +2752,8 @@ for (ptr = VPKG; ptr != NULL; ptr=ptr->n
}
/* Finally add the name to the list. */
- strcat(package_install_list[ptr->pkgmgr], ptr->name);
- strcat(package_install_list[ptr->pkgmgr], " ");
+ (void)strlcat(package_install_list[ptr->pkgmgr], ptr->name, CF_BUFSIZE);
+ (void)strlcat(package_install_list[ptr->pkgmgr], " ", CF_BUFSIZE);
}
}
@@ -2890,14 +2892,14 @@ if (S_ISDIR(statbuf.st_mode))
filecount++;
- strcpy(buff,name);
+ (void)strlcpy(buff,name,sizeof(buff));
if (buff[strlen(buff)] != '/')
{
- strcat(buff,"/");
+ (void)strlcat(buff,"/",sizeof(buff));
}
- strcat(buff,dirp->d_name);
+ (void)strlcat(buff,dirp->d_name,sizeof(buff));
if (lstat(buff,&localstat) == -1)
{
@@ -2925,14 +2927,14 @@ if (S_ISDIR(statbuf.st_mode))
if (sizeinbytes < SENSIBLEFSSIZE)
{
- snprintf(OUTPUT,CF_BUFSIZE*2,"File system %s is suspiciously small! (%d bytes)\n",name,sizeinbytes);
+ snprintf(OUTPUT,CF_BUFSIZE*2,"File system %s is suspiciously small! (%ld bytes)\n",name,sizeinbytes);
CfLog(cferror,OUTPUT,"");
return(false);
}
if (filecount < SENSIBLEFILECOUNT)
{
- snprintf(OUTPUT,CF_BUFSIZE*2,"Filesystem %s has only %d files/directories.\n",name,filecount);
+ snprintf(OUTPUT,CF_BUFSIZE*2,"Filesystem %s has only %ld files/directories.\n",name,filecount);
CfLog(cferror,OUTPUT,"");
return(false);
}
@@ -2980,7 +2982,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))
@@ -2989,7 +2991,7 @@ for (dirp = readdir(dirh); dirp != NULL;
return true;
}
- strcat(pcwd,dirp->d_name);
+ (void)strlcat(pcwd,dirp->d_name,sizeof(pcwd));
if (lstat(dirp->d_name,&statbuf) == -1)
{
@@ -3033,9 +3035,9 @@ void InstallMountedItem(char *host,char
{ char buf[CF_BUFSIZE];
-strcpy (buf,host);
-strcat (buf,":");
-strcat (buf,mountdir);
+(void)strlcpy (buf,host,sizeof(buf));
+(void)strlcat (buf,":",sizeof(buf));
+(void)strlcat (buf,mountdir,sizeof(buf));
if (IsItemIn(VMOUNTED,buf))
{
@@ -3138,16 +3140,16 @@ if (MatchStringInFstab(mountpt))
CfLog(cfinform,"---------------------------------------------------","");
/* delete current fstab entry and unmount if necessary */
- snprintf(mountspec,CF_BUFSIZE,".+:%s",mountpt);
+ snprintf(mountspec,MAXPATHLEN,".+:%s",mountpt);
mntentry = LocateItemContainingRegExp(VMOUNTED,mountspec);
if (mntentry)
{
sscanf(mntentry->name,"%[^:]:",mountspec); /* extract current host */
- strcat(mountspec,":");
- strcat(mountspec,mountpt);
+ (void)strlcat(mountspec,":",sizeof(mountspec));
+ (void)strlcat(mountspec,mountpt,sizeof(mountspec));
}
else /* mountpt isn't mounted, so Unmount can use dummy host name */
- snprintf(mountspec,CF_BUFSIZE,"host:%s",mountpt);
+ snprintf(mountspec,MAXPATHLEN,"host:%s",mountpt);
/* delete current fstab entry and unmount if necessary (don't rmdir) */
cleaner.name = mountspec;
@@ -3296,14 +3298,14 @@ for (ip1 = VHOMEPATLIST; ip1 != NULL; ip
}
pathbuff[0]='\0';
basename[0]='\0';
- strcpy(pathbuff,ip2->name);
+ (void)strlcpy(pathbuff,ip2->name,sizeof(pathbuff));
AddSlash(pathbuff);
- strcat(pathbuff,ip1->name);
+ (void)strlcat(pathbuff,ip1->name,sizeof(pathbuff));
AddSlash(pathbuff);
if (strncmp(ptr->path,"home/",5) == 0) /* home/subdir */
{
- strcat(pathbuff,"*");
+ (void)strlcat(pathbuff,"*",sizeof(pathbuff));
AddSlash(pathbuff);
if (*(ptr->path+4) != '/')
@@ -3314,7 +3316,7 @@ for (ip1 = VHOMEPATLIST; ip1 != NULL; ip
}
else
{
- strcat(pathbuff,ptr->path+5);
+ (void)strlcat(pathbuff,ptr->path+5,sizeof(pathbuff));
}
ExpandWildCardsAndDo(pathbuff,basename,RecFileCheck,ptr);
@@ -3349,7 +3351,7 @@ void EditItemsInResolvConf(struct Item *
}
else
{
- strncpy(buf,work,CF_MAXVARSIZE-1);
+ (void)strlcpy(buf,work,sizeof(buf));
}
DeleteItemMatching(list,buf); /* del+prep = move to head of list */
@@ -3421,7 +3423,7 @@ if (strlen(extract) == 0)
{
if (isdir)
{
- strcat(buffer,"/");
+ (void)strlcat(buffer,"/",CF_EXPANDSIZE);
}
(*function)(buffer,argptr);
return;
@@ -3429,20 +3431,20 @@ if (strlen(extract) == 0)
if (! IsWildCard(extract))
{
- strcat(buffer,"/");
+ (void)strlcat(buffer,"/",CF_EXPANDSIZE);
if (BufferOverflow(buffer,extract))
{
snprintf(OUTPUT,CF_BUFSIZE*2,"Culprit %s\n",extract);
CfLog(cferror,OUTPUT,"");
exit(0);
}
- strcat(buffer,extract);
+ (void)strlcat(buffer,extract,CF_EXPANDSIZE);
ExpandWildCardsAndDo(rest,buffer,function,argptr);
return;
}
else
{
- strcat(buffer,"/");
+ (void)strlcat(buffer,"/",CF_EXPANDSIZE);
if ((dirh=opendir(buffer)) == NULL)
{
@@ -3452,7 +3454,7 @@ else
}
count = 0;
- strcpy(construct,buffer); /* save relative path */
+ (void)strlcpy(construct,buffer,sizeof(construct)); /* save relative path */
for (dp = readdir(dirh); dp != 0; dp = readdir(dirh))
{
@@ -3462,8 +3464,8 @@ else
}
count++;
- strcpy(buffer,construct);
- strcat(buffer,dp->d_name);
+ (void)strlcpy(buffer,construct,CF_EXPANDSIZE);
+ (void)strlcat(buffer,dp->d_name,CF_EXPANDSIZE);
if (stat(buffer,&statbuf) == -1)
{

View File

@ -1,119 +0,0 @@
$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 */

View File

@ -1,84 +0,0 @@
$OpenBSD: patch-src_eval_c,v 1.3 2004/10/01 21:22:15 sturm Exp $
--- src/eval.c.orig Wed Aug 11 00:50:29 2004
+++ src/eval.c Fri Oct 1 23:14:47 2004
@@ -253,7 +253,7 @@ sscanf(str,"%*s %s %s %s %s",buf2,buf3,b
/* Hours */
sscanf(buf4,"%[^:]",buf);
-sprintf(out,"Hr%s",buf);
+(void)snprintf(out,sizeof(out),"Hr%s",buf);
AddClassToHeap(out);
memset(VHR,0,3);
strncpy(VHR,buf,2);
@@ -261,7 +261,7 @@ strncpy(VHR,buf,2);
/* Minutes */
sscanf(buf4,"%*[^:]:%[^:]",buf);
-sprintf(out,"Min%s",buf);
+(void)snprintf(out,sizeof(out),"Min%s",buf);
AddClassToHeap(out);
memset(VMINUTE,0,3);
strncpy(VMINUTE,buf,2);
@@ -301,19 +301,19 @@ switch ((i / 5))
switch ((i / 15))
{
case 0: AddClassToHeap("Q1");
- sprintf(out,"Hr%s_Q1",VHR);
+ (void)snprintf(out,sizeof(out),"Hr%s_Q1",VHR);
AddClassToHeap(out);
break;
case 1: AddClassToHeap("Q2");
- sprintf(out,"Hr%s_Q2",VHR);
+ (void)snprintf(out,sizeof(out),"Hr%s_Q2",VHR);
AddClassToHeap(out);
break;
case 2: AddClassToHeap("Q3");
- sprintf(out,"Hr%s_Q3",VHR);
+ (void)snprintf(out,sizeof(out),"Hr%s_Q3",VHR);
AddClassToHeap(out);
break;
case 3: AddClassToHeap("Q4");
- sprintf(out,"Hr%s_Q4",VHR);
+ (void)snprintf(out,sizeof(out),"Hr%s_Q4",VHR);
AddClassToHeap(out);
break;
}
@@ -321,7 +321,7 @@ switch ((i / 15))
/* Day */
-sprintf(out,"Day%s",buf3);
+(void)snprintf(out,sizeof(out),"Day%s",buf3);
AddClassToHeap(out);
memset(VDAY,0,3);
strncpy(VDAY,buf3,2);
@@ -341,9 +341,9 @@ for (i = 0; i < 12; i++)
/* Year */
-strcpy(VYEAR,buf5);
+strncpy(VYEAR,buf5,4);
-sprintf(out,"Yr%s",buf5);
+(void)snprintf(out,sizeof(out),"Yr%s",buf5);
AddClassToHeap(out);
}
@@ -589,7 +589,7 @@ while(*sp != '\0')
if (IsHardClass(cbuff))
{ char err[CF_BUFSIZE];
yyerror("Illegal exception");
- sprintf (err,"Cannot negate the reserved class [%s]\n",cbuff);
+ (void)snprintf (err,sizeof(err),"Cannot negate the reserved class [%s]\n",cbuff);
FatalError(err);
}
@@ -899,7 +899,7 @@ for (sp = class; *sp != '\0'; sp++)
if (bracklevel != 0)
{
- sprintf(OUTPUT,"Bracket mismatch, in [class=%s], level = %d\n",class,bracklevel);
+ (void)snprintf(OUTPUT,sizeof(OUTPUT),"Bracket mismatch, in [class=%s], level = %d\n",class,bracklevel);
yyerror(OUTPUT);;
FatalError("Aborted");
}

View File

@ -1,48 +0,0 @@
$OpenBSD: patch-src_filedir_c,v 1.2 2005/07/21 15:16:46 aanriot Exp $
--- src/filedir.c.orig Sun May 29 07:40:33 2005
+++ src/filedir.c Fri Jul 15 12:24:01 2005
@@ -169,7 +169,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))
@@ -178,7 +178,7 @@ for (dirp = readdir(dirh); dirp != NULL;
return true;
}
- strcat(pcwd,dirp->d_name);
+ (void)strlcat(pcwd,dirp->d_name,sizeof(pcwd));
if (lstat(dirp->d_name,&statbuf) == -1)
{
@@ -1181,7 +1181,7 @@ int CheckHomeSubDir(char *testpath,char
if (strncmp(tidypath,"home/",5) == 0)
{
- strcpy(buffer,testpath);
+ (void)strlcpy(buffer,testpath,sizeof(buffer));
for (ChopLastNode(buffer); strlen(buffer) != 0; ChopLastNode(buffer))
{
@@ -1202,7 +1202,7 @@ if (strncmp(tidypath,"home/",5) == 0)
subdirstart = tidypath + 4; /* Ptr to start of subdir */
- strcpy(buffer,testpath);
+ (void)strlcpy(buffer,testpath,sizeof(buffer));
ChopLastNode(buffer); /* Filename only */
@@ -1272,7 +1272,7 @@ if (name == NULL || strlen(name) == 0)
strncpy(VBUFF,pathto,CF_BUFSIZE-1);
AddSlash(VBUFF);
-strcat(VBUFF,name);
+(void)strlcat(VBUFF,name,sizeof(VBUFF));
if (ignores != NULL)
{

View File

@ -1,80 +0,0 @@
$OpenBSD: patch-src_filenames_c,v 1.3 2005/07/21 15:16:46 aanriot Exp $
--- src/filenames.c.orig Tue Feb 8 06:50:01 2005
+++ src/filenames.c Fri Jul 15 12:24:01 2005
@@ -121,7 +121,7 @@ if (str == NULL)
if (!IsFileSep(str[strlen(str)-1]))
{
- strcat(str,FILE_SEPARATOR_STR);
+ (void)strlcat(str,FILE_SEPARATOR_STR,CF_BUFSIZE);
}
}
@@ -225,7 +225,7 @@ char *CanonifyName(char *str)
char *sp;
memset(buffer,0,CF_BUFSIZE);
-strcpy(buffer,str);
+(void)strlcpy(buffer,str,sizeof(buffer));
for (sp = buffer; *sp != '\0'; sp++)
{
@@ -246,7 +246,7 @@ char *Space2Score(char *str)
char *sp;
memset(buffer,0,CF_BUFSIZE);
-strcpy(buffer,str);
+(void)strlcpy(buffer,str,sizeof(buffer));
for (sp = buffer; *sp != '\0'; sp++)
{
@@ -267,7 +267,7 @@ char *ASUniqueName(char *str) /* generat
struct Item *ip;
memset(buffer,0,CF_BUFSIZE);
-strcpy(buffer,str);
+(void)strlcpy(buffer,str,sizeof(buffer));
for (ip = VADDCLASSES; ip != NULL; ip=ip->next)
{
@@ -276,8 +276,8 @@ for (ip = VADDCLASSES; ip != NULL; ip=ip
break;
}
- strcat(buffer,".");
- strcat(buffer,ip->name);
+ (void)strlcat(buffer,".",sizeof(buffer));
+ (void)strlcat(buffer,ip->name,sizeof(buffer));
}
return buffer;
@@ -371,9 +371,9 @@ if (strstr(pathbuf, _PATH_RSRCFORKSPEC)
return true;
}
- strcpy(currentpath,pathbuf);
+ (void)strlcpy(currentpath,pathbuf,sizeof(currentpath));
DeleteSlash(currentpath);
- strcat(currentpath,".cf-moved");
+ (void)strlcat(currentpath,".cf-moved",sizeof(currentpath));
snprintf(OUTPUT,CF_BUFSIZE,"Moving obstructing file/link %s to %s to make directory",pathbuf,currentpath);
CfLog(cferror,OUTPUT,"");
@@ -646,7 +646,7 @@ for (sp = src+rootlen; *sp != '\0'; sp++
return false;
}
- strcat(dest,node);
+ (void)strlcat(dest,node,CF_BUFSIZE);
}
return true;
@@ -708,7 +708,7 @@ if (strlen(str) >= CF_BUFSIZE)
{
char *tmp;
tmp = malloc(40+strlen(str));
- sprintf(tmp,"String too long in ToUpperStr: %s",str);
+ snprintf(tmp,CF_BUFSIZE,"String too long in ToUpperStr: %s",str);
FatalError(tmp);
}

View File

@ -1,51 +0,0 @@
$OpenBSD: patch-src_filters_c,v 1.3 2005/07/21 15:16:46 aanriot Exp $
--- src/filters.c.orig Tue Feb 8 06:50:01 2005
+++ src/filters.c Fri Jul 15 12:24:01 2005
@@ -177,7 +177,7 @@ else
break;
}
- sprintf(ebuff,"%d",i);
+ (void)snprintf(ebuff,sizeof(ebuff),"%d",i);
break;
case filterexecregex:
for (sp = ebuff+strlen(ebuff)-1; (*sp != '(') && (sp > ebuff); sp--)
@@ -1027,15 +1027,15 @@ int FilterProcSTimeMatch(char *name1,cha
char year[5],month[4],hr[3],min[3],day[3],timestr[256];
memset(year,0,5);
-strcpy(year,VYEAR);
+(void)strlcpy(year,VYEAR,sizeof(year));
memset(month,0,4);
-strcpy(month,VMONTH);
+(void)strlcpy(month,VMONTH,sizeof(month));
memset(day,0,3);
-strcpy(day,VDAY);
+(void)strlcpy(day,VDAY,sizeof(day));
memset(hr,0,3);
-strcpy(hr,VHR);
+(void)strlcpy(hr,VHR,sizeof(hr));
memset(min,0,3);
-strcpy(min,VMINUTE);
+(void)strlcpy(min,VMINUTE,sizeof(min));
fromtime = Date2Number(fromexpr,now);
totime = Date2Number(toexpr,now);
@@ -1155,7 +1155,7 @@ int FilterOwnerMatch(struct stat *lstatp
char buffer[64];
struct passwd *pw;
-sprintf(buffer,"%d",lstatptr->st_uid);
+(void)snprintf(buffer,sizeof(buffer),"%d",lstatptr->st_uid);
PrependItem(&attrib,buffer,"");
if ((pw = getpwuid(lstatptr->st_uid)) != NULL)
@@ -1187,7 +1187,7 @@ int FilterGroupMatch(struct stat *lstatp
char buffer[64];
struct group *gr;
-sprintf(buffer,"%d",lstatptr->st_gid);
+(void)snprintf(buffer,sizeof(buffer),"%d",lstatptr->st_gid);
PrependItem(&attrib,buffer,"");
if ((gr = getgrgid(lstatptr->st_gid)) != NULL)

View File

@ -1,407 +0,0 @@
$OpenBSD: patch-src_functions_c,v 1.5 2005/10/27 21:47:28 sturm Exp $
--- src/functions.c.orig Sat Aug 13 15:10:56 2005
+++ src/functions.c Fri Oct 21 16:35:55 2005
@@ -247,13 +247,13 @@ switch (fn = FunctionStringToCode(name))
{
if (strcmp(value,CF_NOCLASS) == 0)
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
return value;
}
if (strcmp(value,CF_ANYCLASS) == 0)
{
- strcpy(value,CF_NOCLASS);
+ (void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
return value;
}
}
@@ -347,46 +347,46 @@ FunctionArgs(args,argv,1);
if (lstat(args,&statbuf) == -1)
{
- strcpy(value,CF_NOCLASS);
+ (void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
return;
}
else
{
if (fn == fn_fileexists)
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
return;
}
}
-strcpy(value,CF_NOCLASS);
+(void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
switch(fn)
{
case fn_isdir:
if (S_ISDIR(statbuf.st_mode))
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
return;
}
break;
case fn_islink:
if (S_ISLNK(statbuf.st_mode))
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
return;
}
break;
case fn_isplain:
if (S_ISREG(statbuf.st_mode))
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
return;
}
break;
}
- strcpy(value,CF_NOCLASS);
+ (void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
}
/*********************************************************************/
@@ -401,7 +401,7 @@ if (strchr(args,','))
return;
}
-strcpy(value,CF_NOCLASS);
+(void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
if (!FuzzyMatchParse(args))
{
@@ -416,7 +416,7 @@ for (ip = IPADDRESSES; ip != NULL; ip =
if (FuzzySetMatch(args,ip->name) == 0)
{
Debug("IPRange Matched\n");
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
return;
}
}
@@ -427,12 +427,12 @@ Debug("Checking IP Range against RDNS %s
if (FuzzySetMatch(args,VIPADDRESS) == 0)
{
Debug("IPRange Matched\n");
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
return;
}
Debug("IPRange did not match\n");
-strcpy(value,CF_NOCLASS);
+(void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
}
/*********************************************************************/
@@ -445,7 +445,7 @@ Debug("SRDEBUG args=%s value=%s\n",args,
if (!FuzzyHostParse(args))
{
- strcpy(value,CF_NOCLASS);
+ (void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
return;
}
@@ -455,12 +455,12 @@ if (!FuzzyHostParse(args))
if (FuzzyHostMatch(args,VDEFAULTBINSERVER.name) == 0)
{
Debug("SRDEBUG SUCCESS!\n");
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
}
else
{
Debug("SRDEBUG FAILURE\n");
- strcpy(value,CF_NOCLASS);
+ (void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
}
return;
@@ -474,7 +474,7 @@ void HandleCompareStat(enum builtin fn,c
char argv[CF_MAXFARGS][CF_EXPANDSIZE];
FunctionArgs(args,argv,2);
-strcpy(value,CF_NOCLASS);
+(void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
if (stat(argv[0],&frombuf) == -1)
{
@@ -491,7 +491,7 @@ switch(fn)
case fn_newerthan:
if (frombuf.st_mtime < tobuf.st_mtime)
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
return;
}
break;
@@ -499,7 +499,7 @@ switch(fn)
case fn_accessedbefore:
if (frombuf.st_atime < tobuf.st_atime)
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
return;
}
break;
@@ -507,13 +507,13 @@ switch(fn)
case fn_changedbefore:
if (frombuf.st_ctime < tobuf.st_ctime)
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
return;
}
break;
}
-strcpy(value,CF_NOCLASS);
+(void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
}
@@ -560,7 +560,7 @@ if (*args == '/')
if (ShellCommandReturnsZero(command))
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
return;
}
}
@@ -569,7 +569,7 @@ if (*args == '/')
yyerror("ExecResult(/command) must specify an absolute path");
}
- strcpy(value,CF_NOCLASS);
+ (void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
}
@@ -587,11 +587,11 @@ Debug("HandleIsDefined(%s)\n",args);
if (GetMacroValue(CONTEXTID,args))
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
return;
}
-strcpy(value,CF_NOCLASS);
+(void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
}
/*********************************************************************/
@@ -607,7 +607,7 @@ value[0] = '\0';
if (PARSING)
{
- strcpy(value,"doinstall");
+ (void)strlcpy(value,"doinstall",CF_EXPANDSIZE);
return;
}
@@ -661,11 +661,11 @@ FunctionArgs(args,argv,2);
if (strcmp(argv[0],argv[1]) == 0)
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
}
else
{
- strcpy(value,CF_NOCLASS);
+ (void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
}
}
@@ -689,11 +689,11 @@ if ((a != CF_NOVAL) && (b != CF_NOVAL))
{
if (a > b)
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
}
else
{
- strcpy(value,CF_NOCLASS);
+ (void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
}
return;
}
@@ -701,11 +701,11 @@ if ((a != CF_NOVAL) && (b != CF_NOVAL))
{
if (a < b)
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
}
else
{
- strcpy(value,CF_NOCLASS);
+ (void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
}
return;
}
@@ -717,22 +717,22 @@ if (strcmp(argv[0],argv[1]) > 0)
{
if (ch == '+')
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
}
else
{
- strcpy(value,CF_NOCLASS);
+ (void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
}
}
else
{
if (ch == '+')
{
- strcpy(value,CF_NOCLASS);
+ (void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
}
else
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
}
}
}
@@ -760,11 +760,11 @@ ret = LocateNextItemMatching(list,argv[0
if (ret != NULL)
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
}
else
{
- strcpy(value,CF_NOCLASS);
+ (void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
}
DeleteItemList(list);
@@ -1169,7 +1169,7 @@ first[0] = '\0';
if (psize < 2)
{
- strcpy(value,"silly");
+ (void)strlcpy(value,"silly",CF_EXPANDSIZE);
CfLog(cferror,"Partitioning of size < 2 is silly","");
return;
}
@@ -1178,7 +1178,7 @@ Verbose("Searching for my peer group in
if (!((strcmp("random",policy) == 0) || (strcmp("first",policy) == 0)))
{
- strcpy(value,"silly");
+ (void)strlcpy(value,"silly",CF_EXPANDSIZE);
CfLog(cferror,"Partition leader policy is first/random only","");
return;
}
@@ -1333,7 +1333,7 @@ value[0] = '\0';
if (psize < 2)
{
- strcpy(value,"silly");
+ (void)strlcpy(value,"silly",CF_EXPANDSIZE);
CfLog(cferror,"Partitioning of size < 2 is silly","");
return;
}
@@ -1342,7 +1342,7 @@ Verbose("Searching for my peer group nei
if (!(strcmp("random",policy) == 0 || strcmp("first",policy) == 0))
{
- strcpy(value,"silly");
+ (void)strlcpy(value,"silly",CF_EXPANDSIZE);
CfLog(cferror,"Partition leader policy is first/random only","");
return;
}
@@ -1465,7 +1465,7 @@ for (ip = SplitStringAsItemList(args,','
AppendItem(&METHODRETURNVARS,ip->name,CLASSBUFF);
}
-strcpy(value,"noinstall");
+(void)strlcpy(value,"noinstall",CF_EXPANDSIZE);
}
/*********************************************************************/
@@ -1481,7 +1481,7 @@ for (ip = SplitStringAsItemList(args,','
AppendItem(&METHODRETURNCLASSES,args,CLASSBUFF);
}
-strcpy(value,"noinstall");
+(void)strlcpy(value,"noinstall",CF_EXPANDSIZE);
}
/*********************************************************************/
@@ -1507,7 +1507,7 @@ Debug("ShowState(%s)\n",args);
if (PARSING)
{
- strcpy(value,"doinstall");
+ (void)strlcpy(value,"doinstall",CF_EXPANDSIZE);
return;
}
@@ -1693,12 +1693,12 @@ if (stat(buffer,&statbuf) == 0)
printf("%s: -----------------------------------------------------------------------------------\n",VPREFIX);
snprintf(buffer,CF_BUFSIZE,"State of %s peaked at %s\n",args,ctime(&statbuf.st_mtime));
- strcpy(value,buffer);
+ (void)strlcpy(value,buffer,CF_EXPANDSIZE);
}
else
{
snprintf(buffer,CF_BUFSIZE,"State parameter %s is not known or recorded\n",args);
- strcpy(value,buffer);
+ (void)strlcpy(value,buffer,CF_EXPANDSIZE);
}
DeleteItemList(addresses);
@@ -1725,7 +1725,7 @@ FunctionArgs(args,argv,1);
if (PARSING)
{
- strcpy(value,"doinstall");
+ (void)strlcpy(value,"doinstall",CF_EXPANDSIZE);
return;
}
@@ -1736,7 +1736,7 @@ if (time >= 0)
CheckFriendConnections(time);
}
-strcpy(value,""); /* No reply */
+(void)strlcpy(value,"",CF_EXPANDSIZE); /* No reply */
}
/*********************************************************************/
@@ -1810,11 +1810,11 @@ Debug("PrepModule(%s,%s)\n",argv[0],argv
if (CheckForModule(argv[0],argv[1]))
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
}
else
{
- strcpy(value,CF_NOCLASS);
+ (void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
}
}

View File

@ -1,77 +0,0 @@
$OpenBSD: patch-src_granules_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/granules.c.orig 2004-06-10 23:26:55.000000000 -0400
+++ src/granules.c 2004-06-10 23:03:34.000000000 -0400
@@ -49,47 +49,47 @@ timekey[0] = '\0';
/* Day */
-sprintf(timekey,"%s:",buf1);
+(void)snprintf(timekey,sizeof(timekey),"%s:",buf1);
/* Hours */
sscanf(buf4,"%[^:]",buf);
-sprintf(out,"Hr%s",buf);
-strcat(timekey,out);
+(void)snprintf(out,sizeof(out),"Hr%s",buf);
+(void)strlcat(timekey,out,sizeof(timekey));
/* Minutes */
sscanf(buf4,"%*[^:]:%[^:]",buf);
-sprintf(out,"Min%s",buf);
-strcat(timekey,":");
+(void)snprintf(out,sizeof(out),"Min%s",buf);
+(void)strlcat(timekey,":",sizeof(timekey));
sscanf(buf,"%d",&i);
switch ((i / 5))
{
- case 0: strcat(timekey,"Min00_05");
+ case 0: (void)strlcat(timekey,"Min00_05",sizeof(timekey));
break;
- case 1: strcat(timekey,"Min05_10");
+ case 1: (void)strlcat(timekey,"Min05_10",sizeof(timekey));
break;
- case 2: strcat(timekey,"Min10_15");
+ case 2: (void)strlcat(timekey,"Min10_15",sizeof(timekey));
break;
- case 3: strcat(timekey,"Min15_20");
+ case 3: (void)strlcat(timekey,"Min15_20",sizeof(timekey));
break;
- case 4: strcat(timekey,"Min20_25");
+ case 4: (void)strlcat(timekey,"Min20_25",sizeof(timekey));
break;
- case 5: strcat(timekey,"Min25_30");
+ case 5: (void)strlcat(timekey,"Min25_30",sizeof(timekey));
break;
- case 6: strcat(timekey,"Min30_35");
+ case 6: (void)strlcat(timekey,"Min30_35",sizeof(timekey));
break;
- case 7: strcat(timekey,"Min35_40");
+ case 7: (void)strlcat(timekey,"Min35_40",sizeof(timekey));
break;
- case 8: strcat(timekey,"Min40_45");
+ case 8: (void)strlcat(timekey,"Min40_45",sizeof(timekey));
break;
- case 9: strcat(timekey,"Min45_50");
+ case 9: (void)strlcat(timekey,"Min45_50",sizeof(timekey));
break;
- case 10: strcat(timekey,"Min50_55");
+ case 10: (void)strlcat(timekey,"Min50_55",sizeof(timekey));
break;
- case 11: strcat(timekey,"Min55_00");
+ case 11: (void)strlcat(timekey,"Min55_00",sizeof(timekey));
break;
}
@@ -102,7 +102,7 @@ char *GenTimeKey(time_t now)
{ char str[64];
-sprintf(str,"%s",ctime(&now));
+(void)snprintf(str,sizeof(str),"%s",ctime(&now));
return ConvTimeKey(str);
}

View File

@ -1,66 +0,0 @@
$OpenBSD: patch-src_ifconf_c,v 1.3 2005/10/27 21:47:28 sturm Exp $
--- src/ifconf.c.orig Thu Jun 30 04:36:09 2005
+++ src/ifconf.c Fri Oct 21 16:35:55 2005
@@ -113,7 +113,7 @@ if (vbroadcast[0] == '\0')
return;
}
-strcpy(IFR.ifr_name,vifdev);
+(void)strlcpy(IFR.ifr_name,vifdev,sizeof(IFR.ifr_name));
IFR.ifr_addr.sa_family = AF_INET;
if ((sk = socket(AF_INET,SOCK_DGRAM,IPPROTO_IP)) == -1)
@@ -129,7 +129,7 @@ if (ioctl(sk,SIOCGIFFLAGS, (caddr_t) &IF
}
flags = IFR.ifr_flags;
-strcpy(IFR.ifr_name,vifdev); /* copy this each time */
+(void)strlcpy(IFR.ifr_name,vifdev,sizeof(IFR.ifr_name)); /* copy this each time */
if (ioctl(sk,SIOCGIFMETRIC, (caddr_t) &IFR) == -1) /* Get the routing priority */
{
@@ -174,7 +174,7 @@ else
Verbose("Address given by nameserver: %s\n",inet_ntoa(inaddr));
}
-strcpy(IFR.ifr_name,vifdev);
+(void)strlcpy(IFR.ifr_name,vifdev,sizeof(IFR.ifr_name));
if (ioctl(sk,SIOCGIFADDR, (caddr_t) &IFR) == -1) /* Get the device status flags */
{
@@ -211,7 +211,7 @@ netmask.sin_addr = ((struct sockaddr_in
Verbose("Found netmask: %s\n",inet_ntoa(netmask.sin_addr));
-strcpy(VBUFF,inet_ntoa(netmask.sin_addr));
+(void)strlcpy(VBUFF,inet_ntoa(netmask.sin_addr),sizeof(VBUFF));
if (strcmp(VBUFF,vnetmask))
{
@@ -225,7 +225,7 @@ if (ioctl(sk,SIOCGIFBRDADDR, (caddr_t) &
}
sin = (struct sockaddr_in *) &IFR.ifr_addr;
-strcpy(VBUFF,inet_ntoa(sin->sin_addr));
+(void)strlcpy(VBUFF,inet_ntoa(sin->sin_addr),sizeof(VBUFF));
Verbose("Found broadcast address: %s\n",inet_ntoa(sin->sin_addr));
@@ -287,7 +287,7 @@ else
/* broadcast addr */
-strcpy(IFR.ifr_name,vifdev);
+(void)strlcpy(IFR.ifr_name,vifdev,sizeof(IFR.ifr_name));
broadcast.sin_addr.s_addr = inet_addr(VNUMBROADCAST);
IFR.ifr_addr = *((struct sockaddr *) &broadcast);
sin = (struct sockaddr_in *) &IFR.ifr_addr;
@@ -345,7 +345,7 @@ ba = broadcast / (256 * 256 * 256);
bb = (broadcast / (256 * 256)) % 256;
bc = broadcast / (256) % 256;
bd = broadcast % 256;
-sprintf(VNUMBROADCAST,"%u.%u.%u.%u",ba,bb,bc,bd);
+(void)snprintf(VNUMBROADCAST,sizeof(VNUMBROADCAST),"%u.%u.%u.%u",ba,bb,bc,bd);
}
/****************************************************************/

View File

@ -1,180 +0,0 @@
$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))
{

View File

@ -1,494 +0,0 @@
$OpenBSD: patch-src_install_c,v 1.5 2005/10/27 21:47:28 sturm Exp $
--- src/install.c.orig Thu Sep 8 09:43:45 2005
+++ src/install.c Fri Oct 21 16:35:56 2005
@@ -113,7 +113,7 @@ else
FatalError("Redefinition of basic system variable");
}
- strcpy(VFACULTY,value);
+ (void)strlcpy(VFACULTY,value,sizeof(VFACULTY));
break;
case cfdomain:
@@ -124,7 +124,7 @@ else
if (strlen(value) > 0)
{
- strcpy(VDOMAIN,value);
+ (void)strlcpy(VDOMAIN,value,sizeof(VDOMAIN));
}
else
{
@@ -134,12 +134,12 @@ else
if (!StrStr(VSYSNAME.nodename,VDOMAIN))
{
snprintf(VFQNAME,CF_BUFSIZE,"%s.%s",VSYSNAME.nodename,ToLowerStr(VDOMAIN));
- strcpy(VUQNAME,VSYSNAME.nodename);
+ (void)strlcpy(VUQNAME,VSYSNAME.nodename,CF_MAXVARSIZE);
}
else
{
int n = 0;
- strcpy(VFQNAME,VSYSNAME.nodename);
+ (void)strlcpy(VFQNAME,VSYSNAME.nodename,CF_MAXVARSIZE);
while(VSYSNAME.nodename[n++] != '.')
{
@@ -155,7 +155,7 @@ else
FatalError("The fully qualified name is longer than CF_MAXVARSIZE!!");
}
- strcpy(buffer,VFQNAME);
+ (void)strlcpy(buffer,VFQNAME,sizeof(buffer));
AddClassToHeap(CanonifyName(buffer));
}
@@ -170,7 +170,7 @@ else
break;
}
- strcpy(VSYSADM,value);
+ (void)strlcpy(VSYSADM,value,sizeof(VSYSADM));
break;
case cfnetmask:
@@ -185,7 +185,7 @@ else
yyerror("Multiple declaration of variable netmask");
FatalError("Redefinition of basic system variable");
}
- strcpy(VNETMASK,value);
+ (void)strlcpy(VNETMASK,value,sizeof(VNETMASK));
AddNetworkClass(VNETMASK);
break;
@@ -347,7 +347,7 @@ else
break;
case cfnfstype:
- strcpy(VNFSTYPE,value);
+ (void)strlcpy(VNFSTYPE,value,sizeof(VNFSTYPE));
break;
case cfmethodname:
@@ -427,7 +427,7 @@ else
{
}
- sprintf(rename,"_%s",CLASSTEXT[VSYSTEMHARDCLASS]);
+ (void)snprintf(rename,sizeof(rename),"_%s",CLASSTEXT[VSYSTEMHARDCLASS]);
AddClassToHeap(rename);
break;
@@ -448,7 +448,7 @@ else
yyerror("Silly interface name, (should be something link eth0)");
}
- strcpy(VIFNAMEOVERRIDE,value);
+ (void)strlcpy(VIFNAMEOVERRIDE,value,sizeof(VIFNAMEOVERRIDE));
VIFDEV[VSYSTEMHARDCLASS] = VIFNAMEOVERRIDE; /* override */
Debug("Overriding interface with %s\n",VIFDEV[VSYSTEMHARDCLASS]);
break;
@@ -548,7 +548,7 @@ switch(GetCommAttribute(item))
case cfowner:
if (strlen(value) < CF_BUFSIZE)
{
- strcpy(VUIDNAME,value);
+ (void)strlcpy(VUIDNAME,value,CF_BUFSIZE);
}
else
{
@@ -559,7 +559,7 @@ switch(GetCommAttribute(item))
case cfgroup:
if (strlen(value) < CF_BUFSIZE)
{
- strcpy(VGIDNAME,value);
+ (void)strlcpy(VGIDNAME,value,CF_MAXVARSIZE);
}
else
{
@@ -641,13 +641,13 @@ switch(GetCommAttribute(item))
break;
case cfflags: ParseFlagString(value,&PLUSFLAG,&MINUSFLAG);
break;
- case cfowner: strcpy(VUIDNAME,value);
+ case cfowner: (void)strlcpy(VUIDNAME,value,CF_BUFSIZE);
break;
- case cfgroup: strcpy(VGIDNAME,value);
+ case cfgroup: (void)strlcpy(VGIDNAME,value,CF_BUFSIZE);
break;
- case cfdest: strcpy(DESTINATION,value);
+ case cfdest: (void)strlcpy(DESTINATION,value,CF_BUFSIZE);
break;
- case cfaction: strcpy(IMAGEACTION,value);
+ case cfaction: (void)strlcpy(IMAGEACTION,value,CF_BUFSIZE);
break;
case cfcompat: HandleCharSwitch("oldserver",value,&COMPATIBILITY);
break;
@@ -820,7 +820,7 @@ Debug1("HandleOptionalMountItem(%s)\n",v
switch(GetCommAttribute(item))
{
case cfmountoptions:
- strcpy(MOUNTOPTS, value);
+ (void)strlcpy(MOUNTOPTS, value, CF_BUFSIZE);
break;
case cfreadonly:
@@ -1007,7 +1007,7 @@ switch(GetCommAttribute(item))
case cfinclude:
case cfpattern:
- strcpy(CURRENTITEM,value);
+ (void)strlcpy(CURRENTITEM,value,CF_BUFSIZE);
if (*value == '/')
{
yyerror("search pattern begins with / must be a relative name");
@@ -1083,9 +1083,9 @@ switch(GetCommAttribute(item))
break;
case cfflags: ParseFlagString(value,&PLUSFLAG,&MINUSFLAG);
break;
- case cfowner: strcpy(VUIDNAME,value);
+ case cfowner: (void)strlcpy(VUIDNAME,value,CF_BUFSIZE);
break;
- case cfgroup: strcpy(VGIDNAME,value);
+ case cfgroup: (void)strlcpy(VGIDNAME,value,CF_BUFSIZE);
break;
case cfdefine: HandleDefine(value);
break;
@@ -1291,9 +1291,9 @@ switch(GetCommAttribute(item))
break;
case cffilter: PrependItem(&VFILTERBUILD,value,CF_ANYCLASS);
break;
- case cfowner: strcpy(VUIDNAME,value);
+ case cfowner: (void)strlcpy(VUIDNAME,value,CF_BUFSIZE);
break;
- case cfgroup: strcpy(VGIDNAME,value);
+ case cfgroup: (void)strlcpy(VGIDNAME,value,CF_BUFSIZE);
break;
case cfchdir: HandleChDir(value);
break;
@@ -1333,7 +1333,7 @@ Debug1("HandleOptionalPackagesAttribute(
switch(GetCommAttribute(item))
{
- case cfversion: strcpy(PKGVER,value);
+ case cfversion: (void)strlcpy(PKGVER,value,CF_BUFSIZE);
break;
case cfcmp: CMPSENSE = (enum cmpsense) GetCmpSense(value);
break;
@@ -1465,9 +1465,9 @@ switch(GetCommAttribute(item))
break;
case cfsetinform: HandleCharSwitch("inform",value,&INFORMP);
break;
- case cfowner: strcpy(VUIDNAME,value);
+ case cfowner: (void)strlcpy(VUIDNAME,value,CF_BUFSIZE);
break;
- case cfgroup: strcpy(VGIDNAME,value);
+ case cfgroup: (void)strlcpy(VGIDNAME,value,CF_BUFSIZE);
break;
case cfdefine: HandleDefine(value);
break;
@@ -1534,7 +1534,7 @@ if (!IsAbsoluteFileName(value))
yyerror("chdir is not an absolute directory name");
}
-strcpy(CHDIR,value);
+(void)strlcpy(CHDIR,value,CF_BUFSIZE);
}
/*******************************************************************/
@@ -1547,7 +1547,7 @@ if (!IsAbsoluteFileName(value))
yyerror("chdir is not an absolute directory name");
}
-strcpy(CHROOT,value);
+(void)strlcpy(CHROOT,value,sizeof(CHROOT));
}
/*******************************************************************/
@@ -1558,7 +1558,7 @@ void HandleFileItem(char *item)
if (strcmp(item,"home") == 0)
{
ACTIONPENDING=true;
- strcpy(CURRENTOBJECT,"home");
+ (void)strlcpy(CURRENTOBJECT,"home",CF_BUFSIZE);
return;
}
@@ -1588,19 +1588,19 @@ if (VBROADCAST[0] != '\0')
if (strcmp("ones",item) == 0)
{
- strcpy(VBROADCAST,"one");
+ (void)strlcpy(VBROADCAST,"one",sizeof(VBROADCAST));
return;
}
if (strcmp("zeroes",item) == 0)
{
- strcpy(VBROADCAST,"zero");
+ (void)strlcpy(VBROADCAST,"zero",sizeof(VBROADCAST));
return;
}
if (strcmp("zeros",item) == 0)
{
- strcpy(VBROADCAST,"zero");
+ (void)strlcpy(VBROADCAST,"zero",sizeof(VBROADCAST));
return;
}
@@ -1880,7 +1880,7 @@ if (VMAILSERVER[0] != '\0')
FatalError("Redefinition of mailserver");
}
-strcpy(VMAILSERVER,path);
+(void)strlcpy(VMAILSERVER,path,sizeof(VMAILSERVER));
Debug1("Installing mailserver (%s) for group (%s)",path,GROUPBUFF);
}
@@ -2598,9 +2598,9 @@ switch (action)
{
switch (MOUNTMODE)
{
- case 'o': strcpy(MOUNTOPTS,"ro");
+ case 'o': (void)strlcpy(MOUNTOPTS,"ro",CF_BUFSIZE);
break;
- case 'w': strcpy(MOUNTOPTS,"rw");
+ case 'w': (void)strlcpy(MOUNTOPTS,"rw",CF_BUFSIZE);
break;
default: printf("Install pending, miscmount, shouldn't happen\n");
MOUNTOPTS[0] = '\0'; /* no mount mode set! */
@@ -2616,8 +2616,8 @@ switch (action)
MOUNTFROM, MOUNTONTO);
return;
}
- strcat(MOUNTOPTS,",");
- strcat(MOUNTOPTS,op->name);
+ (void)strlcat(MOUNTOPTS,",",CF_BUFSIZE);
+ (void)strlcat(MOUNTOPTS,op->name,CF_BUFSIZE);
}
AppendMiscMount(MOUNTFROM,MOUNTONTO,MOUNTOPTS);
}
@@ -3481,11 +3481,11 @@ for (sp = Get2DListEnt(tp); sp != NULL;
if (strlen(type) == 0)
{
- sprintf(ebuff,"all");
+ (void)snprintf(ebuff,sizeof(ebuff),"all");
}
else
{
- sprintf(ebuff,"%s",type);
+ (void)snprintf(ebuff,sizeof(ebuff),"%s",type);
}
if ((ptr->type = strdup(ebuff)) == NULL)
@@ -3613,7 +3613,7 @@ if (!strstr(function,"("))
}
/* First look at bare args to cache an arg fingerprint */
-strcpy(work,function);
+(void)strlcpy(work,function,sizeof(work));
if (work[strlen(work)-1] != ')')
{
@@ -4857,12 +4857,12 @@ Debug1("InstallImageItem (%s) (+%o)(-%o)
if (strlen(action) == 0) /* default action */
{
- strcat(action,"fix");
+ (void)strlcat(action,"fix",CF_BUFSIZE);
}
if (!(strcmp(action,"silent") == 0 || strcmp(action,"warn") == 0 || strcmp(action,"fix") == 0))
{
- sprintf(VBUFF,"Illegal action in image/copy item: %s",action);
+ (void)snprintf(VBUFF,sizeof(VBUFF),"Illegal action in image/copy item: %s",action);
yyerror(VBUFF);
return;
}
@@ -4953,7 +4953,7 @@ for (spl = Get2DListEnt(tp); spl != NULL
if (strlen(destination) == 0)
{
- strcpy(buf2,spl);
+ (void)strlcpy(buf2,spl,sizeof(buf2));
}
else
{
@@ -5284,11 +5284,11 @@ if (strlen(CURRENTITEM) != 0)
if (strcmp(value,"link") == 0 || strcmp(value,"links") == 0)
{
- strcpy(CURRENTITEM,"link");
+ (void)strlcpy(CURRENTITEM,"link",CF_BUFSIZE);
}
else if (strcmp(value,"plain") == 0 || strcmp(value,"file") == 0)
{
- strcpy(CURRENTITEM,"file");
+ (void)strlcpy(CURRENTITEM,"file",CF_BUFSIZE);
}
else
{
@@ -5407,7 +5407,7 @@ void HandleNetmask(char *value)
{
if (strlen(DESTINATION) == 0)
{
- strcpy(DESTINATION,value);
+ (void)strlcpy(DESTINATION,value,CF_BUFSIZE);
}
else
{
@@ -5422,7 +5422,7 @@ void HandleIPAddress(char *value)
{
if (strlen(LINKTO) == 0)
{
- strcpy(LINKTO,value);
+ (void)strlcpy(LINKTO,value,CF_BUFSIZE);
}
else
{
@@ -5443,19 +5443,19 @@ if (strlen(CURRENTOBJECT) != 0)
if (strcmp("ones",value) == 0)
{
- strcpy(CURRENTOBJECT,"one");
+ (void)strlcpy(CURRENTOBJECT,"one",CF_BUFSIZE);
return;
}
if (strcmp("zeroes",value) == 0)
{
- strcpy(CURRENTOBJECT,"zero");
+ (void)strlcpy(CURRENTOBJECT,"zero",CF_BUFSIZE);
return;
}
if (strcmp("zeros",value) == 0)
{
- strcpy(CURRENTOBJECT,"zero");
+ (void)strlcpy(CURRENTOBJECT,"zero",CF_BUFSIZE);
return;
}
@@ -5468,6 +5468,7 @@ void AppendToActionSequence (char *actio
{ int j = 0;
char *sp,cbuff[CF_BUFSIZE],actiontxt[CF_BUFSIZE];
+ size_t tmplen;
Debug1("Installing item (%s) in the action sequence list\n",action);
@@ -5499,8 +5500,10 @@ while (*sp != '\0')
if (IsHardClass(cbuff))
{
- char *tmp = malloc(strlen(action)+30);
- sprintf(tmp,"Error in action sequence: %s\n",action);
+ char *tmp;
+ tmplen = strlen(action)+30;
+ tmp = malloc(tmplen);
+ (void)snprintf(tmp,tmplen,"Error in action sequence: %s\n",action);
yyerror(tmp);
free(tmp);
yyerror("You cannot add a reserved class!");
@@ -5509,7 +5512,7 @@ while (*sp != '\0')
if (j == 1)
{
- strcpy(actiontxt,cbuff);
+ (void)strlcpy(actiontxt,cbuff,sizeof(actiontxt));
continue;
}
else if (!IsSpecialClass(cbuff))
@@ -5536,7 +5539,7 @@ if (isalpha((int)user[0]))
return;
}
- sprintf(id,"%d",pw->pw_uid);
+ (void)snprintf(id,sizeof(id),"%d",pw->pw_uid);
AppendItem(&VACCESSLIST,id,NULL);
}
else
@@ -5634,7 +5637,7 @@ void HandleServer(char *value)
{
Debug("Server in copy set to : %s\n",value);
-strcpy(CFSERVER,value);
+(void)strlcpy(CFSERVER,value,CF_MAXVARSIZE);
}
/*******************************************************************/
@@ -5656,7 +5659,7 @@ if (strlen(value) > CF_BUFSIZE)
yyerror(OUTPUT);
}
*/
-strcpy(ALLCLASSBUFFER,value);
+(void)strlcpy(ALLCLASSBUFFER,value,sizeof(ALLCLASSBUFFER));
for (sp = value; *sp != '\0'; sp++)
{
@@ -5686,7 +5689,7 @@ if (strlen(value) > CF_BUFSIZE)
yyerror("class list too long - can't handle it!");
}
-strcpy(ELSECLASSBUFFER,value);
+(void)strlcpy(ELSECLASSBUFFER,value,sizeof(ELSECLASSBUFFER));
for (sp = value; *sp != '\0'; sp++)
{
@@ -5716,7 +5719,7 @@ if (strlen(value) > CF_BUFSIZE)
yyerror("class list too long - can't handle it!");
}
-strcpy(FAILOVERBUFFER,value);
+(void)strlcpy(FAILOVERBUFFER,value,sizeof(FAILOVERBUFFER));
for (sp = value; *sp != '\0'; sp++)
{
@@ -6329,8 +6332,8 @@ switch(GetCommAttribute(attribute))
{
if (strlen(copyhost)+strlen(VDOMAIN) < CF_MAXVARSIZE-2)
{
- strcat(copyhost,".");
- strcat(copyhost,VDOMAIN);
+ (void)strlcat(copyhost,".",sizeof(copyhost));
+ (void)strlcat(copyhost,VDOMAIN,sizeof(copyhost));
}
else
{
@@ -6363,6 +6366,7 @@ void PrependTidy(struct TidyPattern **li
{ struct TidyPattern *tp;
char *spe = NULL,*sp, buffer[CF_EXPANDSIZE];
+ size_t spelen = 0;
if ((tp = (struct TidyPattern *)malloc(sizeof(struct TidyPattern))) == NULL)
{
@@ -6392,10 +6396,14 @@ if ((tp->elsedef = strdup(buffer)) == NU
AddInstallable(tp->defines);
AddInstallable(tp->elsedef);
-if ((classes!= NULL) && (spe = malloc(strlen(classes)+2)) == NULL)
+if (classes!= NULL)
{
- perror("Can't allocate memory in PrependItem()");
- FatalError("");
+ spelen = strlen(classes)+2;
+ if ((spe = malloc(spelen)) == NULL)
+ {
+ perror("Can't allocate memory in PrependItem()");
+ FatalError("");
+ }
}
if (travlinks == '?')
@@ -6421,7 +6429,7 @@ tp->rmdirs =tidydirs;
if (classes != NULL)
{
- strcpy(spe,classes);
+ (void)strlcpy(spe,classes,spelen);
tp->classes = spe;
}
else

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-src_instrument_c,v 1.1 2007/10/12 20:12:19 sturm Exp $
--- src/instrument.c.orig Sun Sep 2 16:20:59 2007
+++ src/instrument.c Sun Sep 2 16:22:24 2007
@@ -331,7 +331,7 @@ while (dbcp->c_get(dbcp, &key, &value, DB_NEXT) == 0)
tthen = (time_t)then;
- snprintf(datebuf,CF_BUFSIZE-1,"%s",ctime(&tthen));
+ snprintf(datebuf,CF_MAXVARSIZE-1,"%s",ctime(&tthen));
datebuf[strlen(datebuf)-9] = '\0'; /* Chop off second and year */
snprintf(addr,15,"%s",hostname+1);

View File

@ -1,30 +0,0 @@
$OpenBSD: patch-src_ip_c,v 1.1 2005/07/21 15:16:47 aanriot Exp $
--- src/ip.c.orig Tue Feb 8 06:50:02 2005
+++ src/ip.c Fri Jul 15 12:24:01 2005
@@ -344,7 +344,7 @@ if ((iaddr.s_addr = inet_addr(ipaddress)
if ((hp == NULL) || (hp->h_name == NULL))
{
- strcpy(hostbuffer,"(Non registered IP)");
+ (void)strlcpy(hostbuffer,"(Non registered IP)",sizeof(hostbuffer));
return hostbuffer;
}
@@ -352,7 +352,7 @@ if ((iaddr.s_addr = inet_addr(ipaddress)
}
else
{
- strcpy(hostbuffer,"(non registered IP)");
+ (void)strlcpy(hostbuffer,"(non registered IP)",sizeof(hostbuffer));
}
#endif
@@ -541,7 +541,7 @@ while (dbcp->c_get(dbcp, &key, &value, D
time_t then;
memcpy(&then,value.data,sizeof(then));
- strcpy(hostname,(char *)key.data);
+ (void)strlcpy(hostname,(char *)key.data,sizeof(hostname));
if (value.data != NULL)
{

View File

@ -1,277 +0,0 @@
$OpenBSD: patch-src_item-ext_c,v 1.3 2005/07/21 15:16:47 aanriot Exp $
--- src/item-ext.c.orig Tue Feb 22 07:21:39 2005
+++ src/item-ext.c Fri Jul 15 12:24:01 2005
@@ -190,6 +190,7 @@ void InsertItemAfter (struct Item **file
{ struct Item *ip;
char *sp;
+ size_t splen;
EditVerbose("Inserting %s \n",string);
@@ -199,7 +200,8 @@ if ((ip = (struct Item *)malloc(sizeof(s
FatalError("");
}
-if ((sp = malloc(strlen(string)+1)) == NULL)
+splen = strlen(string) + 1;
+if ((sp = malloc(splen)) == NULL)
{
CfLog(cferror,"","Can't allocate memory in InsertItemAfter()");
FatalError("");
@@ -218,7 +220,7 @@ if (CURRENTLINEPTR == NULL) /* File is
(*filestart)->next = ip;
}
- strcpy(sp,string);
+ (void)strlcpy(sp,string,splen);
ip->name = sp;
ip->classes = NULL;
CURRENTLINEPTR = ip;
@@ -230,7 +232,7 @@ else
CURRENTLINENUMBER++;
CURRENTLINEPTR->next = ip;
CURRENTLINEPTR = ip;
- strcpy(sp,string);
+ (void)strlcpy(sp,string,splen);
ip->name = sp;
ip->classes = NULL;
}
@@ -795,7 +797,7 @@ for (ip = *list; ip != NULL; ip=ip->next
FatalError("");;
}
- strcpy(ip->name,buff);
+ (void)strlcpy(ip->name,buff,CF_BUFSIZE);
NUMBEROFEDITS++;
return true;
@@ -849,7 +851,7 @@ for (ip = *list; ip != NULL; ip=ip->next
FatalError("");;
}
- strcpy(ip->name,buff);
+ (void)strlcpy(ip->name,buff,CF_BUFSIZE);
NUMBEROFEDITS++;
return true;
@@ -916,7 +918,7 @@ for (ip = *list; ip != NULL; ip=ip->next
FatalError("");;
}
- strcpy(ip->name,buff);
+ (void)strlcpy(ip->name,buff,CF_BUFSIZE);
NUMBEROFEDITS++;
regfree(&rx);
@@ -937,6 +939,7 @@ int UnCommentItemMatching(struct Item **
char *sp, *sp1, *sp2, *spc;
regex_t rx,rxcache;
regmatch_t pmatch;
+ size_t splen;
if (CfRegcomp(&rxcache,string, REG_EXTENDED) != 0)
{
@@ -974,7 +977,8 @@ for (ip = *list; ip != NULL; ip=ip->next
EditVerbose("Uncomment line %s\n",ip->name);
CURRENTLINEPTR = ip->next;
- if ((sp = malloc(strlen(ip->name)+2)) == NULL)
+ splen = strlen(ip->name)+2;
+ if ((sp = malloc(splen)) == NULL)
{
CfLog(cferror,"No Memory in UnCommentNLines\n","malloc");
regfree(&rx);
@@ -1001,11 +1005,11 @@ for (ip = *list; ip != NULL; ip=ip->next
*sp2 = '\0';
}
- strcat(sp,sp1+strlen(comm));
+ (void)strlcat(sp,sp1+strlen(comm),splen);
if (sp2 != ip->name+strlen(ip->name))
{
- strcat(sp,sp2+strlen(end));
+ (void)strlcat(sp,sp2+strlen(end),splen);
}
if (strcmp(sp,ip->name) != 0)
@@ -1031,6 +1035,7 @@ int UnCommentItemContaining(struct Item
{ struct Item *ip;
char *sp, *sp1, *sp2, *spc;
+ size_t splen;
for (ip = *list; ip != NULL; ip=ip->next)
{
@@ -1050,7 +1055,8 @@ for (ip = *list; ip != NULL; ip=ip->next
EditVerbose("Uncomment line %s\n",ip->name);
CURRENTLINEPTR = ip->next;
- if ((sp = malloc(strlen(ip->name)+2)) == NULL)
+ splen = strlen(ip->name)+2;
+ if ((sp = malloc(splen)) == NULL)
{
CfLog(cferror,"No memory in UnCommentNLines\n","malloc");
return false;
@@ -1076,11 +1082,11 @@ for (ip = *list; ip != NULL; ip=ip->next
*sp2 = '\0';
}
- strcat(sp,sp1+strlen(comm));
+ (void)strlcat(sp,sp1+strlen(comm),splen);
if (sp2 != ip->name+strlen(ip->name))
{
- strcat(sp,sp2+strlen(end));
+ (void)strlcat(sp,sp2+strlen(end),splen);
}
if (strcmp(sp,ip->name) != 0)
@@ -1109,6 +1115,7 @@ int CommentToRegExp(struct Item **filest
char *sp;
regex_t rx,rxcache;
regmatch_t pmatch;
+ size_t splen;
Debug2("CommentToRegExp(list,%s %s)\n",comm,string);
@@ -1168,16 +1175,17 @@ for (ip = CURRENTLINEPTR; ip != NULL; ip
NUMBEROFEDITS++;
CURRENTLINEPTR = ip->next;
- if ((sp = malloc(strlen(ip->name)+strlen(comm)+strlen(end)+2)) == NULL)
+ splen = strlen(ip->name)+strlen(comm)+strlen(end)+2;
+ if ((sp = malloc(splen)) == NULL)
{
CfLog(cferror,"No memory in CommentToRegExp\n","malloc");
regfree(&rx);
return false;
}
- strcpy (sp,comm);
- strcat (sp,ip->name);
- strcat (sp,end);
+ (void)strlcpy (sp,comm,splen);
+ (void)strlcat (sp,ip->name,splen);
+ (void)strlcat (sp,end,splen);
free (ip->name);
ip->name = sp;
@@ -1374,7 +1382,7 @@ for (ip = *liststart; ip != NULL; ip=ip-
{
sp += match.rm_eo - match.rm_so - 1;
VBUFF[i] = '\0';
- strcat(VBUFF,replace);
+ (void)strlcat(VBUFF,replace,sizeof(VBUFF));
i += strlen(replace)-1;
memcpy(&rx,&rxcache,sizeof(rx)); /* To fix a bug on some implementations where rx gets emptied */
@@ -1469,12 +1477,12 @@ char *search, *replace;
start = ip->name + match.rm_so;
EditVerbose("Doing SingleReplace of \"%s\" with \"%s\" on line %d\n",start,replace,i);
bzero(VBUFF,CF_BUFSIZE);
- strcpy(VBUFF,ip->name);
+ (void)strlcpy(VBUFF,ip->name,sizeof(VBUFF));
VBUFF[match.rm_so] = '\0'; /* ...head of string */
- strcat(VBUFF,replace); /* ...replacement string */
+ (void)strlcat(VBUFF,replace,sizeof(VBUFF)); /* ...replacement string */
sp = ip->name;
sp += match.rm_eo;
- strcat(VBUFF,sp); /* ...tail of string */
+ (void)strlcat(VBUFF,sp,sizeof(VBUFF)); /* ...tail of string */
Debug("SRDEBUG old line num %d is: \"%s\"\n",i,ip->name);
Debug("SRDEBUG new line num %d is: \"%s\"\n",i,VBUFF);
CURRENTLINEPTR = ip;
@@ -1497,6 +1505,7 @@ int CommentSeveralLines(struct Item **fi
{ struct Item *ip;
int ctr, N = -99, done = false;
char *sp;
+ size_t splen;
Debug2("CommentNLines(list,%s)\n",string);
@@ -1552,15 +1561,16 @@ for (ip = CURRENTLINEPTR; ip != NULL; ip
NUMBEROFEDITS++;
CURRENTLINEPTR = ip->next;
- if ((sp = malloc(strlen(ip->name)+strlen(comm)+strlen(end)+2)) == NULL)
+ splen = strlen(ip->name)+strlen(comm)+strlen(end)+2;
+ if ((sp = malloc(splen)) == NULL)
{
CfLog(cferror,"No memory in CommentNLines\n","malloc");
return false;
}
- strcpy (sp,comm);
- strcat (sp,ip->name);
- strcat (sp,end);
+ (void)strlcpy (sp,comm,splen);
+ (void)strlcat (sp,ip->name,splen);
+ (void)strlcat (sp,end,splen);
free (ip->name);
ip->name = sp;
@@ -1590,6 +1600,7 @@ int UnCommentSeveralLines (struct Item *
{ struct Item *ip;
int ctr, N = -99, done = false;
char *sp, *sp1, *sp2, *spc;
+ size_t splen;
Debug2("UnCommentNLines(list,%s)\n",string);
@@ -1640,7 +1651,8 @@ for (ip = CURRENTLINEPTR; ip != NULL; ip
EditVerbose("Uncomment line %s\n",ip->name);
CURRENTLINEPTR = ip->next;
- if ((sp = malloc(strlen(ip->name)+2)) == NULL)
+ splen = strlen(ip->name)+2;
+ if ((sp = malloc(splen)) == NULL)
{
CfLog(cferror,"No memory in UnCommentNLines\n","malloc");
return false;
@@ -1666,11 +1678,11 @@ for (ip = CURRENTLINEPTR; ip != NULL; ip
*sp2 = '\0';
}
- strcat(sp,sp1+strlen(comm));
+ (void)strlcat(sp,sp1+strlen(comm),splen);
if (sp2 != ip->name+strlen(ip->name))
{
- strcat(sp,sp2+strlen(end));
+ (void)strlcat(sp,sp2+strlen(end),splen);
}
ctr++;
@@ -1855,7 +1867,7 @@ for (ip = *filestart; ip != NULL; ip=ip-
free(ip->name);
ip->name = (char *) malloc(strlen(replace)+1);
- strcpy(ip->name,replace);
+ (void)strlcpy(ip->name,replace,strlen(replace));
EditVerbose("Edit: With (%s)\n",replace);
}
}
@@ -1866,6 +1878,7 @@ for (ip = *filestart; ip != NULL; ip=ip-
void AppendToLine(struct Item *current,char *text,char *filename)
{ char *new;
+ size_t buflen;
if (strstr(current->name,text))
{
@@ -1874,9 +1887,10 @@ if (strstr(current->name,text))
EditVerbose("Appending %s to line %-60s...\n",text,current->name);
-new = malloc(strlen(current->name)+strlen(text)+1);
-strcpy(new,current->name);
-strcat(new,text);
+buflen = strlen(current->name)+strlen(text)+1;
+new = malloc(buflen);
+(void)strlcpy(new,current->name,buflen);
+(void)strlcat(new,text,buflen);
NUMBEROFEDITS++;
free(current->name);

View File

@ -1,65 +0,0 @@
$OpenBSD: patch-src_item-file_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/item-file.c.orig 2004-06-10 10:50:04.000000000 -0400
+++ src/item-file.c 2004-06-10 13:49:58.000000000 -0400
@@ -107,19 +107,19 @@ if (stat(file,&statbuf) == -1)
return false;
}
-strcpy(new,file);
-strcat(new,CF_EDITED);
+(void)strlcpy(new,file,sizeof(new));
+(void)strlcat(new,CF_EDITED,sizeof(new));
-strcpy(backup,file);
+(void)strlcpy(backup,file,sizeof(backup));
-sprintf(stamp, "_%d_%s", CFSTARTTIME, CanonifyName(ctime(&STAMPNOW)));
+(void)snprintf(stamp, sizeof(stamp), "_%d_%s", CFSTARTTIME, CanonifyName(ctime(&STAMPNOW)));
if (IMAGEBACKUP == 's')
{
- strcat(backup,stamp);
+ (void)strlcat(backup,stamp,sizeof(backup));
}
-strcat(backup,CF_SAVED);
+(void)strlcat(backup,CF_SAVED,sizeof(backup));
unlink(new); /* Just in case of races */
@@ -258,6 +258,7 @@ void InsertFileAfter (struct Item **file
char *sp;
FILE *fp;
char linebuf[CF_BUFSIZE];
+ size_t splen;
EditVerbose("Edit: Inserting file %s \n",string);
@@ -275,7 +276,8 @@ while(!feof(fp) && ReadLine(linebuf,CF_B
FatalError("");
}
- if ((sp = malloc(strlen(linebuf)+1)) == NULL)
+ splen = strlen(linebuf)+1;
+ if ((sp = malloc(splen)) == NULL)
{
CfLog(cferror,"","Can't allocate memory in InsertItemAfter()");
FatalError("");
@@ -294,7 +296,7 @@ while(!feof(fp) && ReadLine(linebuf,CF_B
(*filestart)->next = ip;
}
- strcpy(sp,linebuf);
+ (void)strlcpy(sp,linebuf,splen);
ip->name = sp;
ip->classes = NULL;
CURRENTLINEPTR = ip;
@@ -306,7 +308,7 @@ while(!feof(fp) && ReadLine(linebuf,CF_B
CURRENTLINEPTR->next = ip;
CURRENTLINEPTR=ip;
CURRENTLINENUMBER++;
- strcpy(sp,linebuf);
+ (void)strlcpy(sp,linebuf,splen);
ip->name = sp;
ip->classes = NULL;
}

View File

@ -1,165 +0,0 @@
$OpenBSD: patch-src_item_c,v 1.5 2005/10/27 21:47:28 sturm Exp $
--- src/item.c.orig Thu Aug 11 04:22:28 2005
+++ src/item.c Fri Oct 21 16:35:56 2005
@@ -212,6 +212,7 @@ void PrependItem (struct Item **liststar
{ struct Item *ip;
char *sp,*spe = NULL;
+ size_t splen, spelen = 0;
if (!PARSING && (ACTION == editfiles))
{
@@ -229,19 +230,24 @@ if ((ip = (struct Item *)malloc(sizeof(s
FatalError("");
}
-if ((sp = malloc(strlen(itemstring)+2)) == NULL)
+splen = strlen(itemstring) + 2;
+if ((sp = malloc(splen)) == NULL)
{
CfLog(cferror,"","malloc");
FatalError("");
}
-if ((classes != NULL) && (spe = malloc(strlen(classes)+2)) == NULL)
+if (classes != NULL)
{
- CfLog(cferror,"","malloc");
- FatalError("");
+ spelen = strlen(classes) + 2;
+ if ((spe = malloc(spelen)) == NULL)
+ {
+ CfLog(cferror,"","malloc");
+ FatalError("");
+ }
}
-strcpy(sp,itemstring);
+(void)strlcpy(sp,itemstring,splen);
ip->name = sp;
ip->next = *liststart;
ip->counter = 0;
@@ -249,7 +255,7 @@ ip->counter = 0;
if (classes != NULL)
{
- strcpy(spe,classes);
+ (void)strlcpy(spe,classes,spelen);
ip->classes = spe;
}
else
@@ -302,6 +308,7 @@ void AppendItem (struct Item **liststart
{ struct Item *ip, *lp;
char *sp,*spe = NULL;
+ size_t splen, spelen = 0;
if (!PARSING && (ACTION == editfiles))
{
@@ -319,7 +326,8 @@ if ((ip = (struct Item *)malloc(sizeof(s
FatalError("");
}
-if ((sp = malloc(strlen(itemstring)+CF_EXTRASPC)) == NULL)
+splen = strlen(itemstring) + CF_EXTRASPC;
+if ((sp = malloc(splen)) == NULL)
{
CfLog(cferror,"","malloc");
FatalError("");
@@ -338,20 +346,24 @@ else
lp->next = ip;
}
-if ((classes != NULL) && (spe = malloc(strlen(classes)+2)) == NULL)
+if (classes != NULL)
{
- CfLog(cferror,"","malloc");
- FatalError("");
+ spelen = strlen(classes) + 2;
+ if ((spe = malloc(spelen)) == NULL)
+ {
+ CfLog(cferror,"","malloc");
+ FatalError("");
+ }
}
-strcpy(sp,itemstring);
+(void)strlcpy(sp,itemstring,splen);
ip->name = sp;
ip->next = NULL;
ip->counter = 0;
if (classes != NULL)
{
- strcpy(spe,classes);
+ (void)strlcpy(spe,classes,spelen);
ip->classes = spe;
}
else
@@ -369,6 +381,7 @@ void InstallItem (struct Item **liststar
{ struct Item *ip, *lp;
char *sp,*spe = NULL;
+ size_t splen, spelen = 0;
if (!PARSING && (ACTION == editfiles))
{
@@ -387,7 +400,8 @@ if ((ip = (struct Item *)malloc(sizeof(s
FatalError("");
}
-if ((sp = malloc(strlen(itemstring)+CF_EXTRASPC)) == NULL)
+splen = strlen(itemstring) + CF_EXTRASPC;
+if ((sp = malloc(splen)) == NULL)
{
CfLog(cferror,"","malloc");
FatalError("");
@@ -406,13 +420,17 @@ else
lp->next = ip;
}
-if ((classes!= NULL) && (spe = malloc(strlen(classes)+2)) == NULL)
+if (classes!= NULL)
{
- CfLog(cferror,"","malloc");
- FatalError("");
+ spelen = strlen(classes) + 2;
+ if ((spe = malloc(spelen)) == NULL)
+ {
+ CfLog(cferror,"","malloc");
+ FatalError("");
+ }
}
-strcpy(sp,itemstring);
+(void)strlcpy(sp,itemstring,splen);
if (PIFELAPSED != -1)
{
@@ -437,7 +455,7 @@ ip->next = NULL;
if (classes != NULL)
{
- strcpy(spe,classes);
+ (void)strlcpy(spe,classes,spelen);
ip->classes = spe;
}
else
@@ -1072,7 +1090,7 @@ char *s1, *s2;
return 1;
}
sscanf(sp,"%ld",&cmp);
- Debug("SRDEBUG extracted int %d\n",cmp,sp);
+ Debug("SRDEBUG extracted int %d from %s\n",cmp,sp);
/* HvB basename is */
strncpy(host_basename, s2, strlen(s2) - strlen(sp));
@@ -1121,7 +1139,7 @@ struct Item *SplitStringAsItemList(char
Debug("SplitStringAsItemList(%s,%c)\n",string,sep);
-sprintf(format,"%%255[^%c]",sep); /* set format string to search */
+(void)snprintf(format,sizeof(format),"%%255[^%c]",sep); /* set format string to search */
for (sp = string; *sp != '\0'; sp++)
{

View File

@ -1,327 +0,0 @@
$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;
}

View File

@ -1,48 +0,0 @@
$OpenBSD: patch-src_locks_c,v 1.4 2005/10/27 21:47:28 sturm Exp $
--- src/locks.c.orig Fri Jul 15 11:17:23 2005
+++ src/locks.c Fri Oct 21 16:35:56 2005
@@ -74,7 +74,7 @@ DB *DBP;
void PreLockState()
{
- strcpy(CFLOCK,"pre-lock-state");
+ (void)strlcpy(CFLOCK,"pre-lock-state",CF_BUFSIZE);
}
/********************************************************************/
@@ -82,7 +82,7 @@ void PreLockState()
void SaveExecLock()
{
-strcpy(SAVELOCK,CFLOCK);
+(void)strlcpy(SAVELOCK,CFLOCK,CF_BUFSIZE);
}
@@ -91,7 +91,7 @@ strcpy(SAVELOCK,CFLOCK);
void RestoreExecLock()
{
-strcpy(CFLOCK,SAVELOCK);
+(void)strlcpy(CFLOCK,SAVELOCK,CF_BUFSIZE);
}
/********************************************************************/
@@ -364,7 +364,7 @@ if (PutLock(CFLAST) == -1)
LockLog(getpid(),"Lock removed normally ",CFLOCK,"");
-strcpy(CFLOCK,"no_active_lock");
+(void)strlcpy(CFLOCK,"no_active_lock",CF_BUFSIZE);
}
@@ -721,7 +721,7 @@ if ((tim = time((time_t *)NULL)) == -1)
Debug("Cfengine: couldn't read system clock\n");
}
-sprintf(buffer,"%s",ctime(&tim));
+(void)snprintf(buffer,sizeof(buffer),"%s",ctime(&tim));
Chop(buffer);

View File

@ -1,37 +0,0 @@
$OpenBSD: patch-src_macro_c,v 1.5 2005/10/27 21:47:28 sturm Exp $
--- src/macro.c.orig Mon Aug 15 10:06:46 2005
+++ src/macro.c Fri Oct 21 16:35:56 2005
@@ -200,6 +200,7 @@ void AddMacroValue(char *scope,char *nam
{ char *sp, buffer[CF_BUFSIZE],exp[CF_EXPANDSIZE];
struct cfObject *ptr;
int slot;
+ size_t buflen;
Debug("AddMacroValue(%s.%s=%s)\n",scope,name,value);
@@ -237,13 +238,14 @@ ptr = ObjectContext(scope);
snprintf(buffer,CF_BUFSIZE,"%s=%s",name,exp);
-if ((sp = malloc(strlen(buffer)+1)) == NULL)
+buflen = strlen(buffer) + 1;
+if ((sp = malloc(buflen)) == NULL)
{
perror("malloc");
FatalError("aborting");
}
-strcpy(sp,buffer);
+(void)strlcpy(sp,buffer,buflen);
slot = Hash(name);
@@ -363,7 +365,7 @@ if (strstr(name,"."))
if (ptr == NULL)
{
- strcpy(vname,name);
+ (void)strlcpy(vname,name,sizeof(vname));
ptr = ObjectContext(scope);
}

View File

@ -1,53 +0,0 @@
$OpenBSD: patch-src_methods_c,v 1.5 2005/10/27 21:47:28 sturm Exp $
--- src/methods.c.orig Fri Sep 9 01:56:25 2005
+++ src/methods.c Fri Oct 21 16:35:56 2005
@@ -351,29 +351,29 @@ options[0] = '\0';
if (INFORM)
{
- strcat(options,"-I ");
+ (void)strlcat(options,"-I ",sizeof(options));
}
if (IGNORELOCK)
{
- strcat(options,"-K ");
+ (void)strlcat(options,"-K ",sizeof(options));
}
if (VERBOSE)
{
- strcat(options,"-v ");
+ (void)strlcat(options,"-v ",sizeof(options));
}
if (DEBUG || D2)
{
- strcat(options,"-d2 ");
+ (void)strlcat(options,"-d2 ",sizeof(options));
}
ptr = IsDefinedMethod(name,digeststring);
-strcat(options,"-Z ");
-strcat(options,digeststring);
-strcat(options," ");
+(void)strlcat(options,"-Z ",sizeof(options));
+(void)strlcat(options,digeststring,sizeof(options));
+(void)strlcat(options," ",sizeof(options));
snprintf(execstr,CF_BUFSIZE-1,"%s/bin/cfagent -f %s %s",CFWORKDIR,GetMethodFilename(ptr),options);
@@ -1145,10 +1145,10 @@ for (dirp = readdir(dirh); dirp != NULL;
SplitMethodName(dirp->d_name,client,server,name,digeststring,extra);
Debug("This request came from %s - our reply should be sent there!\n",client);
- strcpy(METHODREPLYTO,client);
+ (void)strlcpy(METHODREPLYTO,client,sizeof(METHODREPLYTO));
Debug("This request referred to us as %s - a plausible identity\n",client);
- strcpy(METHODFOR,server);
+ (void)strlcpy(METHODFOR,server,sizeof(METHODFOR));
if (strcmp(methodname,name) == 0)
{

View File

@ -1,169 +0,0 @@
$OpenBSD: patch-src_misc_c,v 1.5 2005/10/27 21:47:28 sturm Exp $
--- src/misc.c.orig Fri Jul 15 11:15:25 2005
+++ src/misc.c Fri Oct 21 16:35:56 2005
@@ -540,17 +540,17 @@ char *ChecksumPrint(char type,unsigned c
switch(type)
{
- case 's': sprintf(buffer,"SHA= ");
+ case 's': (void)snprintf(buffer,sizeof(buffer),"SHA= ");
len = 20;
break;
- case 'm': sprintf(buffer,"MD5= ");
+ case 'm': (void)snprintf(buffer,sizeof(buffer),"MD5= ");
len = 16;
break;
}
for (i = 0; i < len; i++)
{
- sprintf((char *)(buffer+4+2*i),"%02x", digest[i]);
+ (void)snprintf((char *)(buffer+4+2*i),sizeof(buffer),"%02x", digest[i]);
}
return buffer;
@@ -894,17 +894,17 @@ char strmajor[CF_MAXVARSIZE];
release += strlen(RELEASE_FLAG);
if (sscanf(release, "%d", &major) == 1)
{
- sprintf(strmajor, "%d", major);
+ (void)snprintf(strmajor, sizeof(strmajor), "%d", major);
}
}
if (major != -1 && vendor != "")
{
classbuf[0] = '\0';
- strcat(classbuf, vendor);
+ (void)strlcat(classbuf, vendor, sizeof(classbuf));
AddClassToHeap(classbuf);
- strcat(classbuf, "_");
- strcat(classbuf, strmajor);
+ (void)strlcat(classbuf, "_", sizeof(classbuf));
+ (void)strlcat(classbuf, strmajor, sizeof(classbuf));
AddClassToHeap(classbuf);
}
@@ -1062,15 +1062,15 @@ Verbose("Looking for redhat linux info i
release += strlen(RELEASE_FLAG);
if (sscanf(release, "%d.%d", &major, &minor) == 2)
{
- sprintf(strmajor, "%d", major);
- sprintf(strminor, "%d", minor);
+ (void)snprintf(strmajor, sizeof(strmajor), "%d", major);
+ (void)snprintf(strminor, sizeof(strminor), "%d", minor);
}
/* red hat 9 is *not* red hat 9.0.
* and same thing with RHEL AS 3
*/
else if (sscanf(release, "%d", &major) == 1)
{
- sprintf(strmajor, "%d", major);
+ (void)snprintf(strmajor, sizeof(strmajor), "%d", major);
minor = -2;
};
}
@@ -1078,21 +1078,21 @@ Verbose("Looking for redhat linux info i
if (major != -1 && minor != -1 && vendor != "")
{
classbuf[0] = '\0';
- strcat(classbuf, vendor);
+ (void)strlcat(classbuf, vendor, sizeof(classbuf));
AddClassToHeap(classbuf);
- strcat(classbuf, "_");
+ (void)strlcat(classbuf, "_", sizeof(classbuf));
if(edition != "")
{
- strcat(classbuf, edition);
+ (void)strlcat(classbuf, edition, sizeof(classbuf));
AddClassToHeap(classbuf);
- strcat(classbuf, "_");
+ (void)strlcat(classbuf, "_", sizeof(classbuf));
}
- strcat(classbuf, strmajor);
+ (void)strlcat(classbuf, strmajor, sizeof(classbuf));
AddClassToHeap(classbuf);
if (minor != -2)
{
- strcat(classbuf, "_");
- strcat(classbuf, strminor);
+ (void)strlcat(classbuf, "_", sizeof(classbuf));
+ (void)strlcat(classbuf, strminor, sizeof(classbuf));
AddClassToHeap(classbuf);
}
}
@@ -1139,13 +1139,13 @@ FILE *fp;
if(!strncmp(relstring, SUSE_SLES8_ID, strlen(SUSE_SLES8_ID)))
{
classbuf[0] = '\0';
- strcat(classbuf, "SLES8");
+ (void)strlcat(classbuf, "SLES8", sizeof(classbuf));
AddClassToHeap(classbuf);
}
else if(!strncmp(relstring, SUSE_SLES9_ID, strlen(SUSE_SLES9_ID)))
{
classbuf[0] = '\0';
- strcat(classbuf, "SLES9");
+ (void)strlcat(classbuf, "SLES9", sizeof(classbuf));
AddClassToHeap(classbuf);
}
@@ -1166,19 +1166,19 @@ FILE *fp;
{
release += strlen(SUSE_RELEASE_FLAG);
sscanf(release, "%d.%d", &major, &minor);
- sprintf(strmajor, "%d", major);
- sprintf(strminor, "%d", minor);
+ (void)snprintf(strmajor, sizeof(strmajor), "%d", major);
+ (void)snprintf(strminor, sizeof(strminor), "%d", minor);
}
if(major != -1 && minor != -1)
{
classbuf[0] = '\0';
- strcat(classbuf, "SuSE");
+ (void)strlcat(classbuf, "SuSE", sizeof(classbuf));
AddClassToHeap(classbuf);
- strcat(classbuf, "_");
- strcat(classbuf, strmajor);
+ (void)strlcat(classbuf, "_", sizeof(classbuf));
+ (void)strlcat(classbuf, strmajor, sizeof(classbuf));
AddClassToHeap(classbuf);
- strcat(classbuf, "_");
- strcat(classbuf, strminor);
+ (void)strlcat(classbuf, "_", sizeof(classbuf));
+ (void)strlcat(classbuf, strminor, sizeof(classbuf));
AddClassToHeap(classbuf);
}
@@ -1297,8 +1297,8 @@ char strminor[CF_MAXVARSIZE];
release += strlen(RELEASE_FLAG);
if (sscanf(release, "%d.%d", &major, &minor) == 2)
{
- sprintf(strmajor, "%d", major);
- sprintf(strminor, "%d", minor);
+ (void)snprintf(strmajor, sizeof(strmajor), "%d", major);
+ (void)snprintf(strminor, sizeof(strminor), "%d", minor);
}
else
{
@@ -1310,15 +1310,15 @@ char strminor[CF_MAXVARSIZE];
if (major != -1 && minor != -1 && vendor != "")
{
classbuf[0] = '\0';
- strcat(classbuf, vendor);
+ (void)strlcat(classbuf, vendor, sizeof(classbuf));
AddClassToHeap(classbuf);
- strcat(classbuf, "_");
- strcat(classbuf, strmajor);
+ (void)strlcat(classbuf, "_", sizeof(classbuf));
+ (void)strlcat(classbuf, strmajor, sizeof(classbuf));
AddClassToHeap(classbuf);
if (minor != -2)
{
- strcat(classbuf, "_");
- strcat(classbuf, strminor);
+ (void)strlcat(classbuf, "_", sizeof(classbuf));
+ (void)strlcat(classbuf, strminor, sizeof(classbuf));
AddClassToHeap(classbuf);
}
}

View File

@ -1,21 +0,0 @@
$OpenBSD: patch-src_modes_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/modes.c.orig 2004-06-10 23:27:06.000000000 -0400
+++ src/modes.c 2004-06-10 23:17:28.000000000 -0400
@@ -189,7 +189,7 @@ void CheckModeState(enum modestate state
{
if ((stateA != wild) && (stateB != wild) && (stateA != stateB))
{
- sprintf(VBUFF,"Mode string constant (%c) used out of context",ch);
+ (void)snprintf(VBUFF,sizeof(VBUFF),"Mode string constant (%c) used out of context",ch);
yyerror(VBUFF);
}
@@ -221,7 +221,7 @@ switch(action)
*m |= ((~value) & 07777 & affected);
return;
default:
- sprintf(VBUFF,"Mode directive %c is unknown",action);
+ (void)snprintf(VBUFF,sizeof(VBUFF),"Mode directive %c is unknown",action);
yyerror(VBUFF);
return;
}

View File

@ -1,30 +0,0 @@
$OpenBSD: patch-src_modules_c,v 1.3 2004/10/01 21:22:15 sturm Exp $
--- src/modules.c.orig Mon Aug 16 18:52:40 2004
+++ src/modules.c Fri Oct 1 23:14:49 2004
@@ -73,7 +73,7 @@ else
}
AddSlash(ebuff);
-strcat(ebuff,actiontxt);
+(void)strlcat(ebuff,actiontxt,sizeof(ebuff));
if (stat(ebuff,&statbuf) == -1)
{
@@ -92,7 +92,7 @@ if ((statbuf.st_uid != 0) && (statbuf.st
snprintf(OUTPUT,CF_BUFSIZE*2,"Plug-in `%s\'",actiontxt);
Banner(OUTPUT);
-strcat(ebuff," ");
+(void)strlcat(ebuff," ",sizeof(ebuff));
if (BufferOverflow(ebuff,args))
{
@@ -101,7 +101,7 @@ if (BufferOverflow(ebuff,args))
return false;
}
-strcat(ebuff,args);
+(void)strlcat(ebuff,args,sizeof(ebuff));
ExpandVarstring(ebuff,command,NULL);
Verbose("Exec module [%s]\n",command);

View File

@ -1,31 +0,0 @@
$OpenBSD: patch-src_mount_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/mount.c.orig 2004-06-10 10:50:04.000000000 -0400
+++ src/mount.c 2004-06-10 12:25:16.000000000 -0400
@@ -76,7 +76,7 @@ for (mp = VMOUNTED; mp != NULL; mp=mp->n
if (strcmp(sp,lastlink) == 0)
{
- strcpy(server,mp->name+strlen(host)+1);
+ (void)strlcpy(server,mp->name+strlen(host)+1,CF_BUFSIZE);
return(true);
}
}
@@ -110,15 +110,15 @@ for (mp = VMOUNTABLES; mp !=NULL; mp=mp-
}
}
- strcpy(VBUFF,dir);
+ (void)strlcpy(VBUFF,dir,sizeof(VBUFF));
if (VBUFF[strlen(VBUFF)-1] == '/')
{
- strcat(VBUFF,"..");
+ (void)strlcat(VBUFF,"..",sizeof(VBUFF));
}
else
{
- strcat(VBUFF,"/..");
+ (void)strlcat(VBUFF,"/..",sizeof(VBUFF));
}
if (stat(VBUFF,&parentstat) == -1)

View File

@ -1,116 +0,0 @@
$OpenBSD: patch-src_nameinfo_c,v 1.5 2005/10/27 21:47:28 sturm Exp $
--- src/nameinfo.c.orig Tue Jul 26 08:26:33 2005
+++ src/nameinfo.c Fri Oct 21 16:35:56 2005
@@ -59,6 +59,7 @@ void GetNameInfo()
time_t tloc;
struct hostent *hp;
struct sockaddr_in cin;
+ size_t buflen;
#ifdef AIX
char real_version[_SYS_NMLN];
#endif
@@ -127,12 +128,13 @@ for (i = 0; CLASSATTRIBUTES[i][0] != '\0
}
}
-if ((sp = malloc(strlen(VSYSNAME.nodename)+1)) == NULL)
+buflen = strlen(VSYSNAME.nodename) + 1;
+if ((sp = malloc(buflen)) == NULL)
{
FatalError("malloc failure in initialize()");
}
-strcpy(sp,VSYSNAME.nodename);
+(void)strlcpy(sp,VSYSNAME.nodename,buflen);
SetDomainName(sp);
for (sp2=sp; *sp2 != '\0'; sp2++) /* Add some domain hierarchy classes */
@@ -204,7 +206,7 @@ if (VERBOSE || DEBUG || D2 || D3)
}
-sprintf(VBUFF,"%d_bit",sizeof(long)*8);
+(void)snprintf(VBUFF,sizeof(VBUFF),"%d_bit",sizeof(long)*8);
AddClassToHeap(VBUFF);
Verbose("Additional hard class defined as: %s\n",CanonifyName(VBUFF));
@@ -285,8 +287,8 @@ if (! found)
CfLog(cferror,"Cfengine: I don't understand what architecture this is!","");
}
-strcpy(VBUFF,"compiled_on_");
-strcat(VBUFF,CanonifyName(AUTOCONF_SYSNAME));
+(void)strlcpy(VBUFF,"compiled_on_",sizeof(VBUFF));
+(void)strlcat(VBUFF,CanonifyName(AUTOCONF_SYSNAME),sizeof(VBUFF));
AddClassToHeap(CanonifyName(VBUFF));
@@ -303,7 +305,7 @@ else
memset(&cin,0,sizeof(cin));
cin.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr;
Verbose("Address given by nameserver: %s\n",inet_ntoa(cin.sin_addr));
- strcpy(VIPADDRESS,inet_ntoa(cin.sin_addr));
+ (void)strlcpy(VIPADDRESS,inet_ntoa(cin.sin_addr),18);
for (i=0; hp->h_aliases[i]!= NULL; i++)
{
@@ -414,7 +416,7 @@ for (j = 0,len = 0,ifp = list.ifc_req; l
}
/* Old style compat */
- strcpy(ip,inet_ntoa(sin->sin_addr));
+ (void)strlcpy(ip,inet_ntoa(sin->sin_addr),sizeof(ip));
AppendItem(&IPADDRESSES,ip,"");
for (sp = ip+strlen(ip)-1; *sp != '.'; sp--)
@@ -425,8 +427,8 @@ for (j = 0,len = 0,ifp = list.ifc_req; l
/* New style */
- strcpy(ip,"ipv4_");
- strcat(ip,inet_ntoa(sin->sin_addr));
+ (void)strlcpy(ip,"ipv4_",sizeof(ip));
+ (void)strlcat(ip,inet_ntoa(sin->sin_addr),sizeof(ip));
AddClassToHeap(CanonifyName(ip));
snprintf(name,CF_MAXVARSIZE-1,"ipv4[%s]",CanonifyName(ifp->ifr_name));
AddMacroValue(CONTEXTID,name,inet_ntoa(sin->sin_addr));
@@ -567,9 +569,9 @@ void AddNetworkClass(char *netmask) /* F
if ((nm.s_addr = inet_addr(netmask)) != -1 && (ip.s_addr = inet_addr(VIPADDRESS)) != -1)
{
ip.s_addr &= nm.s_addr; /* Will not work with IPv6 */
- strcpy(ipbuf,inet_ntoa(ip));
+ (void)strlcpy(ipbuf,inet_ntoa(ip),sizeof(ipbuf));
- strcpy(nmbuf,inet_ntoa(nm));
+ (void)strlcpy(nmbuf,inet_ntoa(nm),sizeof(nmbuf));
while( (sp = strrchr(nmbuf,'.')) && strcmp(sp,".0") == 0 )
{
@@ -592,22 +594,22 @@ void SetDomainName(char *sp) /
if (gethostname(fqn, sizeof(fqn)) != -1)
{
- strcpy(VFQNAME,fqn);
- strcpy(buffer,VFQNAME);
+ (void)strlcpy(VFQNAME,fqn,CF_MAXVARSIZE);
+ (void)strlcpy(buffer,VFQNAME,sizeof(buffer));
AddClassToHeap(CanonifyName(buffer));
AddClassToHeap(CanonifyName(ToLowerStr(buffer)));
if (strstr(fqn,"."))
{
ptr = strchr(fqn, '.');
- strcpy(VDOMAIN, ++ptr);
+ (void)strlcpy(VDOMAIN, ++ptr, sizeof(VDOMAIN));
}
}
if (strstr(VFQNAME,".") == 0 && (strcmp(VDOMAIN,CF_START_DOMAIN) != 0))
{
- strcat(VFQNAME,".");
- strcat(VFQNAME,VDOMAIN);
+ (void)strlcat(VFQNAME,".",CF_MAXVARSIZE);
+ (void)strlcat(VFQNAME,VDOMAIN,CF_MAXVARSIZE);
}
AddClassToHeap(CanonifyName(VDOMAIN));

View File

@ -1,34 +0,0 @@
$OpenBSD: patch-src_package_c,v 1.3 2005/07/21 15:16:47 aanriot Exp $
--- src/package.c.orig Mon Feb 28 17:19:20 2005
+++ src/package.c Fri Jul 15 13:42:23 2005
@@ -335,14 +335,14 @@ int InstallPackage(char *name, enum pkgm
strncpy(instcmd, rawinstcmd, CF_BUFSIZE*2);
ptr = instcmd + strlen(rawinstcmd);
*percent = '%';
- strcat(ptr, name);
+ (void)strlcat(ptr, name, (CF_BUFSIZE*2 - strlen(rawinstcmd)));
ptr += strlen(name);
percent += 2;
strncpy(ptr, percent, (CF_BUFSIZE*2 - (ptr-instcmd)));
}
else
{
- sprintf(instcmd, "%s %s", rawinstcmd, name);
+ (void)snprintf(instcmd, CF_BUFSIZE*2, "%s %s", rawinstcmd, name);
}
Verbose("Installing package(s) %s using %s\n", name, instcmd);
if ((pp = cfpopen(instcmd, "r")) == NULL)
@@ -443,11 +443,11 @@ int DPKGPackageCheck(char *package,char
treat "" as "no version" */
if (strncmp (evrstart, "(none)", strlen ("(none)")) == 0) {
- sprintf (evrstart, "\"\"");
+ (void)snprintf (evrstart, strlen("(none)"), "\"\"");
}
if (strncmp (version, "(none)", strlen ("(none)")) == 0) {
- sprintf (version, "\"\"");
+ (void)snprintf (version, strlen("(none)"), "\"\"");
}
/* the evrstart shall be a version number which we will

View File

@ -1,237 +0,0 @@
$OpenBSD: patch-src_parse_c,v 1.5 2005/10/27 21:47:28 sturm Exp $
--- src/parse.c.orig Fri Sep 9 01:54:30 2005
+++ src/parse.c Fri Oct 21 16:35:56 2005
@@ -258,7 +258,7 @@ SetStrategies();
Debug1("\n\n==============================BEGIN NEW ACTION %s=============\n\n",ACTIONTEXT[action]);
ACTION = action;
-strcpy(ACTIONBUFF,ACTIONTEXT[action]);
+(void)strlcpy(ACTIONBUFF,ACTIONTEXT[action],CF_BUFSIZE);
switch (ACTION)
{
@@ -284,7 +284,7 @@ switch (ACTION)
}
Debug1("\nResetting CLASS to ANY\n\n");
-strcpy(CLASSBUFF,CF_ANYCLASS); /* default class */
+(void)strlcpy(CLASSBUFF,CF_ANYCLASS,CF_BUFSIZE); /* default class */
}
/*******************************************************************/
@@ -300,7 +300,7 @@ Debug1("HandleLVALUE(%s) in action %s\n"
if ((CONTROLVAR = ScanVariable(id)) != nonexistentvar)
{
- strcpy(CURRENTITEM,id);
+ (void)strlcpy(CURRENTITEM,id,CF_BUFSIZE);
return;
}
else
@@ -341,7 +341,7 @@ Debug1("HandleLVALUE(%s) in action %s\n"
yyerror("Reserved class name (choose a different name)");
}
- strcpy(GROUPBUFF,id);
+ (void)strlcpy(GROUPBUFF,id,CF_BUFSIZE);
}
break;
@@ -360,14 +360,14 @@ Debug1("HandleBraceObjectID(%s) in actio
switch (ACTION)
{
case acls:
- strcpy(CURRENTOBJECT,id);
+ (void)strlcpy(CURRENTOBJECT,id,CF_BUFSIZE);
InstallACL(id,CLASSBUFF);
break;
case strategies:
if (strlen(STRATEGYNAME) == 0)
{
- strcpy(STRATEGYNAME,id);
+ (void)strlcpy(STRATEGYNAME,id,CF_BUFSIZE);
InstallStrategy(id,CLASSBUFF);
}
else
@@ -379,7 +379,7 @@ switch (ACTION)
case editfiles:
if (strlen(CURRENTOBJECT) == 0)
{
- strcpy(CURRENTOBJECT,id);
+ (void)strlcpy(CURRENTOBJECT,id,CF_BUFSIZE);
EDITGROUPLEVEL = 0;
FOREACHLEVEL = 0;
SEARCHREPLACELEVEL = 0;
@@ -393,7 +393,7 @@ switch (ACTION)
case filters:
if (strlen(FILTERNAME)==0)
{
- strcpy(FILTERNAME,id);
+ (void)strlcpy(FILTERNAME,id,CF_BUFSIZE);
InstallFilter(id);
}
else
@@ -419,7 +419,7 @@ switch (ACTION)
case filters:
case strategies:
- strcpy(CURRENTITEM,id);
+ (void)strlcpy(CURRENTITEM,id,CF_BUFSIZE);
break;
case editfiles:
@@ -434,7 +434,7 @@ switch (ACTION)
HandleEdit(CURRENTOBJECT,id,NULL);
}
- strcpy(CURRENTITEM,id);
+ (void)strlcpy(CURRENTITEM,id,CF_BUFSIZE);
break;
}
}
@@ -470,7 +470,7 @@ else
Debug1("Simple class = (%s)\n",id);
}
-strcpy(CLASSBUFF,id);
+(void)strlcpy(CLASSBUFF,id,CF_BUFSIZE);
}
/*******************************************************************/
@@ -487,13 +487,13 @@ switch (ACTION)
break;
case filters:
- strcpy(FILTERDATA,qstring);
+ (void)strlcpy(FILTERDATA,qstring,CF_BUFSIZE);
ACTIONPENDING = true;
InstallPending(ACTION);
break;
case strategies:
- strcpy(STRATEGYDATA,qstring);
+ (void)strlcpy(STRATEGYDATA,qstring,CF_BUFSIZE);
ACTIONPENDING = true;
InstallPending(ACTION);
break;
@@ -507,7 +507,7 @@ switch (ACTION)
{
yyerror("Processes syntax error");
}
- strcpy(RESTART,qstring);
+ (void)strlcpy(RESTART,qstring,CF_BUFSIZE);
ACTIONPENDING = true;
InstallPending(ACTION);
@@ -531,7 +531,7 @@ switch (ACTION)
yyerror("Missing process search expression");
}
Debug1("Installing expression %s\n",qstring);
- strcpy(EXPR,qstring);
+ (void)strlcpy(EXPR,qstring,CF_BUFSIZE);
HAVE_RESTART = false;
}
else if (HAVE_RESTART)
@@ -645,7 +645,7 @@ if (!IsDefinedClass(CLASSBUFF))
if (IsBuiltinFunction(fn))
{
local[0] = '\0';
- strcpy(local,EvaluateFunction(fn,local));
+ (void)strlcpy(local,EvaluateFunction(fn,local),sizeof(local));
switch (ACTION)
{
@@ -852,8 +852,8 @@ switch (ACTION)
InstallPending(ACTION);
InitializeAction();
Debug1("\nFound SetOptionString\n");
- strcpy(CURRENTOBJECT,"SetOptionString");
- strcpy(EXPR,"SetOptionString");
+ (void)strlcpy(CURRENTOBJECT,"SetOptionString",CF_BUFSIZE);
+ (void)strlcpy(EXPR,"SetOptionString",CF_BUFSIZE);
}
else if (HAVE_RESTART)
{
@@ -898,7 +898,7 @@ Debug("HandleServerRule(%s=%s)\n",object
if (*buffer == '/')
{
Debug("\n\nNew admit/deny object=%s\n",buffer);
- strcpy(CURRENTAUTHPATH,object);
+ (void)strlcpy(CURRENTAUTHPATH,object,CF_BUFSIZE);
}
else
{
@@ -1038,7 +1038,7 @@ if ((yyin = fopen(filename,"r")) == NULL
exit (1);
}
-strcpy(VCURRENTFILE,filename);
+(void)strlcpy(VCURRENTFILE,filename,CF_BUFSIZE);
Debug("\n##########################################################################\n");
Debug("# BEGIN PARSING %s\n",VCURRENTFILE);
@@ -1119,7 +1119,7 @@ void RecordMacroId(char *name)
{
Debug("RecordMacroId(%s)\n",name);
-strcpy(CURRENTITEM,name);
+(void)strlcpy(CURRENTITEM,name,CF_BUFSIZE);
if (strcmp(name,"this") == 0)
{
@@ -1149,7 +1149,7 @@ if ((sp=getenv(CF_INPUTSVAR)) != NULL)
{
if (!IsAbsoluteFileName(filename)) /* Don't prepend to absolute names */
{
- strcpy(result,sp);
+ (void)strlcpy(result,sp,CF_BUFSIZE);
if (! IsAbsoluteFileName(result))
{
@@ -1164,13 +1164,13 @@ if ((sp=getenv(CF_INPUTSVAR)) != NULL)
{
if (!IsAbsoluteFileName(filename)) /* Don't prepend to absolute names */
{
- strcpy(result,CFWORKDIR);
+ (void)strlcpy(result,CFWORKDIR,CF_BUFSIZE);
AddSlash(result);
- strcat(result,"inputs/");
+ (void)strlcat(result,"inputs/",CF_BUFSIZE);
}
}
-strcat(result,filename);
+(void)strlcat(result,filename,CF_BUFSIZE);
return result;
}
@@ -1201,8 +1201,8 @@ void InitializeAction()
HAVE_RESTART = false;
VAGE = 99999;
strncpy(FINDERTYPE,"*",CF_BUFSIZE);
- strcpy(VUIDNAME,"*");
- strcpy(VGIDNAME,"*");
+ (void)strlcpy(VUIDNAME,"*",CF_MAXVARSIZE);
+ (void)strlcpy(VGIDNAME,"*",CF_MAXVARSIZE);
HAVE_RESTART = 0;
FILEACTION=warnall;
PIFELAPSED=-1;
@@ -1223,7 +1223,7 @@ void InitializeAction()
PARSEMETHODRETURNCLASSES[0] = '\0';
METHODFORCE[0] = '\0';
CHROOT[0] = '\0';
- strcpy(VIFNAME,"");
+ (void)strlcpy(VIFNAME,"",sizeof(VIFNAME));
PTRAVLINKS = (short) '?';
IMAGEBACKUP = 'y';
ENCRYPT = 'n';
@@ -1266,7 +1266,7 @@ void InitializeAction()
memset(ALLCLASSBUFFER,0,CF_BUFSIZE);
memset(ELSECLASSBUFFER,0,CF_BUFSIZE);
- strcpy(CFSERVER,"localhost");
+ (void)strlcpy(CFSERVER,"localhost",CF_MAXVARSIZE);
IMGCOMP = DISCOMP='>';
IMGSIZE = DISABLESIZE=CF_NOSIZE;

View File

@ -1,72 +0,0 @@
$OpenBSD: patch-src_patches_c,v 1.2 2005/07/21 15:16:47 aanriot Exp $
--- src/patches.c.orig Tue Feb 8 06:50:02 2005
+++ src/patches.c Fri Jul 15 12:24:01 2005
@@ -135,7 +135,7 @@ if (gethostname(buffer,CF_BUFSIZE) == -1
exit(1);
}
-strcpy(sys->nodename,buffer);
+(void)strlcpy(sys->nodename,buffer,sizeof(sys->nodename));
if (strcmp(buffer,AUTOCONF_HOSTNAME) != 0)
{
@@ -143,10 +143,10 @@ if (strcmp(buffer,AUTOCONF_HOSTNAME) !=
Verbose("This host does not have uname, so I can't tell if it is the exact same OS\n");
}
-strcpy(sys->sysname,AUTOCONF_SYSNAME);
-strcpy(sys->release,"cfengine-had-to-guess");
-strcpy(sys->machine,"missing-uname(2)");
-strcpy(sys->version,"unknown");
+(void)strlcpy(sys->sysname,AUTOCONF_SYSNAME,sizeof(sys->sysname));
+(void)strlcpy(sys->release,"cfengine-had-to-guess",sizeof(sys->release));
+(void)strlcpy(sys->machine,"missing-uname(2)",sizeof(sys->machine));
+(void)strlcpy(sys->version,"unknown",sizeof(sys->version));
/* Extract a version number if possible */
@@ -155,8 +155,8 @@ for (sp = sys->sysname; *sp != '\0'; sp+
{
if (isdigit(*sp))
{
- strcpy(sys->release,sp);
- strcpy(sys->version,sp);
+ (void)strlcpy(sys->release,sp,sizeof(sys->release));
+ (void)strlcpy(sys->version,sp,sizeof(sys->version));
*sp = '\0';
break;
}
@@ -205,6 +205,7 @@ return NULL;
#ifndef HAVE_STRDUP
char *strdup(char *str)
+size_t buflen;
{ char *sp;
@@ -213,13 +214,14 @@ if (str == NULL)
return NULL;
}
-if ((sp = malloc(strlen(str)+1)) == NULL)
+buflen = strlen(str) + 1;
+if ((sp = malloc(buflen)) == NULL)
{
perror("malloc");
return NULL;
}
-strcpy(sp,str);
+(void)strlcpy(sp,str,buflen);
return sp;
}
@@ -271,7 +273,7 @@ char *strerror(int err)
{ static char buffer[20];
-sprintf(buffer,"Error number %d\n",err);
+(void)snprintf(buffer,sizeof(buffer),"Error number %d\n",err);
return buffer;
}

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-src_popen_c,v 1.2 2005/07/21 15:16:47 aanriot Exp $
--- src/popen.c.orig Thu Mar 10 15:47:10 2005
+++ src/popen.c Fri Jul 15 12:24:01 2005
@@ -412,7 +412,7 @@ FILE *cfpopen_sh(char *command,char *typ
$OpenBSD: patch-src_popen_c,v 1.3 2007/10/12 20:12:19 sturm Exp $
--- src/popen.c.orig Fri Jan 13 21:39:00 2006
+++ src/popen.c Sun Sep 2 15:44:05 2007
@@ -416,7 +416,7 @@ FILE *cfpopen_sh(char *command,char *type)
}
}
@ -10,7 +10,7 @@ $OpenBSD: patch-src_popen_c,v 1.2 2005/07/21 15:16:47 aanriot Exp $
_exit(1);
}
else
@@ -561,7 +561,7 @@ FILE *cfpopen_shsetuid(char *command,cha
@@ -565,7 +565,7 @@ FILE *cfpopen_shsetuid(char *command,char *type,uid_t
}
}

View File

@ -1,12 +0,0 @@
$OpenBSD: patch-src_process_c,v 1.2 2005/07/21 15:16:47 aanriot Exp $
--- src/process.c.orig Tue Feb 8 06:50:02 2005
+++ src/process.c Fri Jul 15 12:24:01 2005
@@ -414,7 +414,7 @@ for (ip = procdata; ip != NULL; ip=ip->n
if (pp->action == 'm')
{
- sprintf(saveuid,"%d",pid);
+ (void)snprintf(saveuid,sizeof(saveuid),"%d",pid);
PrependItem(killlist,saveuid,"");
}
else

View File

@ -1,44 +0,0 @@
$OpenBSD: patch-src_proto_c,v 1.4 2005/10/27 21:47:28 sturm Exp $
--- src/proto.c.orig Fri Jul 15 04:25:15 2005
+++ src/proto.c Fri Oct 21 16:35:56 2005
@@ -133,14 +133,14 @@ if (!SKIPIDENTIFY)
if ((strstr(hp->h_name,".") == 0) && (strlen(VDOMAIN) > 0))
{
- strcat(dnsname,".");
- strcat(dnsname,VDOMAIN);
+ (void)strlcat(dnsname,".",sizeof(dnsname));
+ (void)strlcat(dnsname,VDOMAIN,sizeof(dnsname));
}
#endif
}
else
{
- strcat(dnsname,"skipident");
+ (void)strlcat(dnsname,"skipident",sizeof(dnsname));
}
user_ptr = getpwuid(getuid());
@@ -151,19 +151,19 @@ uname = user_ptr ? user_ptr->pw_name : "
if ((strlen(VDOMAIN) > 0) && !IsIPV6Address(dnsname) && !strchr(dnsname,'.'))
{
Debug("Appending domain %s to %s\n",VDOMAIN,dnsname);
- strcat(dnsname,".");
+ (void)strlcat(dnsname,".",sizeof(dnsname));
strncat(dnsname,VDOMAIN,CF_MAXVARSIZE/2);
}
if (strncmp(dnsname,localip,strlen(localip)) == 0)
{
/* Seems to be a bug in some resolvers that adds garbage, when it just returns the input */
- strcpy(dnsname,localip);
+ (void)strlcpy(dnsname,localip,sizeof(dnsname));
}
if (strlen(dnsname) == 0)
{
- strcpy(dnsname,localip);
+ (void)strlcpy(dnsname,localip,sizeof(dnsname));
}
snprintf(sendbuff,CF_BUFSIZE-1,"CAUTH %s %s %s %d",localip,dnsname,uname,CFSIGNATURE);

View File

@ -1,14 +0,0 @@
$OpenBSD: patch-src_prototypes_h,v 1.4 2005/10/27 21:47:28 sturm Exp $
--- src/prototypes.h.orig Fri Sep 9 01:57:05 2005
+++ src/prototypes.h Fri Oct 21 16:35:56 2005
@@ -200,8 +200,8 @@ int EmbeddedWrite ARGLIST((char *new,int
/* dce_acl.c */
-/*struct CFACE;
- int CheckDFSACE ARGLIST((struct CFACE *aces, char method, char *filename, enum fileactions action));*/
+/*struct CFACE; */
+ int CheckDFSACE ARGLIST((struct CFACE *aces, char method, char *filename, enum fileactions action));
/* df.c */

View File

@ -1,21 +0,0 @@
$OpenBSD: patch-src_repository_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/repository.c.orig 2004-06-10 10:50:03.000000000 -0400
+++ src/repository.c 2004-06-10 11:29:44.000000000 -0400
@@ -85,7 +85,7 @@ if ((strlen(localrepository) == 0) || HO
Debug2("Repository(%s)\n",file);
-strcpy (node,file);
+(void)strlcpy (node,file,sizeof(node));
buffer[0] = '\0';
@@ -106,7 +106,7 @@ if (BufferOverflow(buffer,node))
return false;
}
-strcat(buffer,node);
+(void)strlcat(buffer,node,sizeof(buffer));
if (!MakeDirectoriesFor(buffer,'y'))
{

View File

@ -1,31 +0,0 @@
$OpenBSD: patch-src_sensible_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/sensible.c.orig 2004-06-10 10:50:04.000000000 -0400
+++ src/sensible.c 2004-06-10 13:35:54.000000000 -0400
@@ -107,15 +107,15 @@ for (sp = nodename; *sp != '\0'; sp++)
}
}
-strcpy(vbuff,path);
+(void)strlcpy(vbuff,path,sizeof(vbuff));
AddSlash(vbuff);
-strcat(vbuff,nodename);
+(void)strlcat(vbuff,nodename,sizeof(vbuff));
if (suspicious && NONALPHAFILES)
{
snprintf(OUTPUT,CF_BUFSIZE,"Suspicious filename %s in %s has no alphanumeric content (security)",CanonifyName(nodename),path);
CfLog(cfsilent,OUTPUT,"");
- strcpy(newname,vbuff);
+ (void)strlcpy(newname,vbuff,sizeof(newname));
for (sp = newname+strlen(path); *sp != '\0'; sp++)
{
@@ -125,7 +125,7 @@ if (suspicious && NONALPHAFILES)
}
}
- strcat(newname,".cf-nonalpha");
+ (void)strlcat(newname,".cf-nonalpha",sizeof(newname));
snprintf(OUTPUT,CF_BUFSIZE,"Renaming file %s to %s",vbuff,newname);
CfLog(cfsilent,OUTPUT,"");

View File

@ -1,12 +0,0 @@
$OpenBSD: patch-src_sockaddr_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/sockaddr.c.orig 2004-06-10 10:50:04.000000000 -0400
+++ src/sockaddr.c 2004-06-10 12:25:48.000000000 -0400
@@ -70,7 +70,7 @@ switch (sa->sa_family)
#ifdef AF_LOCAL
case AF_LOCAL:
Debug("Local socket\n") ;
- strcpy(addrbuf, "127.0.0.1") ;
+ (void)strlcpy(addrbuf, "127.0.0.1",sizeof(addrbuf));
break;
#endif

View File

@ -1,59 +0,0 @@
$OpenBSD: patch-src_tidy_c,v 1.2 2005/07/21 15:16:47 aanriot Exp $
--- src/tidy.c.orig Mon Apr 4 04:54:12 2005
+++ src/tidy.c Fri Jul 15 12:24:01 2005
@@ -76,8 +76,8 @@ if (level == 2)
if (LOGTIDYHOMEFILES)
{
int tempfd;
- strcpy(VLOGFILE,name);
- strcat(VLOGFILE,"/.cfengine.rm");
+ (void)strlcpy(VLOGFILE,name,CF_BUFSIZE);
+ (void)strlcat(VLOGFILE,"/.cfengine.rm",CF_BUFSIZE);
/* Unlink here to avoid an exploit which could be used to
overwrite a system file with root privileges. */
@@ -95,7 +95,7 @@ if (level == 2)
}
else if ((VLOGFP = fdopen(tempfd,"w")) == NULL)
{
- sprintf(OUTPUT,"Couldn't open a file %s\n",VLOGFILE);
+ (void)snprintf(OUTPUT,sizeof(OUTPUT),"Couldn't open a file %s\n",VLOGFILE);
CfLog(cferror,OUTPUT,"fdopen");
VLOGFP = stderr;
}
@@ -123,7 +123,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))
@@ -131,7 +131,7 @@ for (dirp = readdir(dirh); dirp != NULL;
return true;
}
- strcat(pcwd,dirp->d_name);
+ (void)strlcat(pcwd,dirp->d_name,sizeof(pcwd));
if (TRAVLINKS)
{
@@ -398,7 +398,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))
@@ -408,7 +408,7 @@ for (dirp = readdir(dirh); dirp != NULL;
level = tp->maxrecurse - maxrecurse;
- strcat(pcwd,dirp->d_name);
+ (void)strlcat(pcwd,dirp->d_name,sizeof(pcwd));
if (lstat(dirp->d_name,&statbuf) == -1) /* Check for links first */
{

View File

@ -1,388 +0,0 @@
$OpenBSD: patch-src_varstring_c,v 1.4 2005/07/21 15:16:47 aanriot Exp $
--- src/varstring.c.orig Wed Apr 20 13:11:14 2005
+++ src/varstring.c Fri Jul 15 13:36:19 2005
@@ -354,7 +354,7 @@ for (sp = string; /* No exit */ ; sp++)
FatalError("Can't expand varstring");
}
- strcat(buffer,currentitem);
+ (void)strlcat(buffer,currentitem,CF_EXPANDSIZE);
sp += strlen(currentitem);
if (*sp == '$')
@@ -368,7 +368,7 @@ for (sp = string; /* No exit */ ; sp++)
varstring = '}';
break;
default:
- strcat(buffer,"$");
+ (void)strlcat(buffer,"$",CF_EXPANDSIZE);
continue;
}
sp++;
@@ -406,7 +406,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,VERSION);
+ (void)strlcat(buffer,VERSION,CF_EXPANDSIZE);
break;
case cffaculty:
@@ -420,7 +420,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,VFACULTY);
+ (void)strlcat(buffer,VFACULTY,CF_EXPANDSIZE);
break;
@@ -431,7 +431,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,VDEFAULTBINSERVER.name);
+ (void)strlcat(buffer,VDEFAULTBINSERVER.name,CF_EXPANDSIZE);
}
else
{
@@ -439,7 +439,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,VUQNAME);
+ (void)strlcat(buffer,VUQNAME,CF_EXPANDSIZE);
}
break;
@@ -448,7 +448,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,VFQNAME);
+ (void)strlcat(buffer,VFQNAME,CF_MAXVARSIZE);
break;
case cfnetmask:
@@ -456,7 +456,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,VNETMASK);
+ (void)strlcat(buffer,VNETMASK,CF_EXPANDSIZE);
break;
@@ -465,7 +465,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,VIPADDRESS);
+ (void)strlcat(buffer,VIPADDRESS,CF_EXPANDSIZE);
break;
case cfbinserver:
@@ -479,7 +479,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,"$(binserver)");
+ (void)strlcat(buffer,"$(binserver)",CF_EXPANDSIZE);
break;
case cfsysadm:
@@ -492,7 +492,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,VSYSADM);
+ (void)strlcat(buffer,VSYSADM,CF_EXPANDSIZE);
break;
case cfdomain:
@@ -505,7 +505,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,ToLowerStr(VDOMAIN));
+ (void)strlcat(buffer,ToLowerStr(VDOMAIN),CF_EXPANDSIZE);
break;
case cfnfstype:
@@ -513,7 +513,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,VNFSTYPE);
+ (void)strlcat(buffer,VNFSTYPE,CF_EXPANDSIZE);
break;
case cftimezone:
@@ -526,7 +526,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,VTIMEZONE->name);
+ (void)strlcat(buffer,VTIMEZONE->name,CF_EXPANDSIZE);
break;
case cfclass:
@@ -534,7 +534,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,CLASSTEXT[VSYSTEMHARDCLASS]);
+ (void)strlcat(buffer,CLASSTEXT[VSYSTEMHARDCLASS],CF_EXPANDSIZE);
break;
case cfarch:
@@ -542,7 +542,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,VARCH);
+ (void)strlcat(buffer,VARCH,CF_EXPANDSIZE);
break;
case cfarch2:
@@ -550,7 +550,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,VARCH2);
+ (void)strlcat(buffer,VARCH2,CF_EXPANDSIZE);
break;
@@ -568,7 +568,7 @@ for (sp = string; /* No exit */ ; sp++)
}
else
{
- strcat(buffer,Space2Score(ctime(&tloc)));
+ (void)strlcat(buffer,Space2Score(ctime(&tloc)),CF_EXPANDSIZE);
Chop(buffer);
}
@@ -581,7 +581,7 @@ for (sp = string; /* No exit */ ; sp++)
}
else
{
- strcat(buffer,VYEAR);
+ (void)strlcat(buffer,VYEAR,CF_EXPANDSIZE);
}
break;
@@ -592,7 +592,7 @@ for (sp = string; /* No exit */ ; sp++)
}
else
{
- strcat(buffer,VMONTH);
+ (void)strlcat(buffer,VMONTH,CF_EXPANDSIZE);
}
break;
@@ -603,7 +603,7 @@ for (sp = string; /* No exit */ ; sp++)
}
else
{
- strcat(buffer,VDAY);
+ (void)strlcat(buffer,VDAY,CF_EXPANDSIZE);
}
break;
case cfhr:
@@ -613,7 +613,7 @@ for (sp = string; /* No exit */ ; sp++)
}
else
{
- strcat(buffer,VHR);
+ (void)strlcat(buffer,VHR,CF_EXPANDSIZE);
}
break;
@@ -624,7 +624,7 @@ for (sp = string; /* No exit */ ; sp++)
}
else
{
- strcat(buffer,VMINUTE);
+ (void)strlcat(buffer,VMINUTE,CF_EXPANDSIZE);
}
break;
@@ -632,14 +632,14 @@ for (sp = string; /* No exit */ ; sp++)
if (strlen(ALLCLASSBUFFER) == 0)
{
snprintf(name,CF_MAXVARSIZE,"$(%s)",currentitem);
- strcat(buffer,name);
+ (void)strlcat(buffer,name,CF_EXPANDSIZE);
}
if (ExpandOverflow(buffer,ALLCLASSBUFFER))
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,ALLCLASSBUFFER);
+ (void)strlcat(buffer,ALLCLASSBUFFER,CF_EXPANDSIZE);
break;
case cfspc:
@@ -647,7 +647,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer," ");
+ (void)strlcat(buffer," ",CF_EXPANDSIZE);
break;
case cftab:
@@ -655,7 +655,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,"\t");
+ (void)strlcat(buffer,"\t",CF_EXPANDSIZE);
break;
case cflf:
@@ -663,7 +663,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,"\012");
+ (void)strlcat(buffer,"\012",CF_EXPANDSIZE);
break;
case cfcr:
@@ -671,7 +671,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,"\015");
+ (void)strlcat(buffer,"\015",CF_EXPANDSIZE);
break;
case cfn:
@@ -679,7 +679,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,"\n");
+ (void)strlcat(buffer,"\n",CF_EXPANDSIZE);
break;
case cfdblquote:
@@ -687,14 +687,14 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,"\"");
+ (void)strlcat(buffer,"\"",CF_EXPANDSIZE);
break;
case cfquote:
if (ExpandOverflow(buffer," "))
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,"\'");
+ (void)strlcat(buffer,"\'",CF_EXPANDSIZE);
break;
case cfcolon:
@@ -702,7 +702,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,":");
+ (void)strlcat(buffer,":",CF_EXPANDSIZE);
break;
@@ -714,7 +714,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,"$");
+ (void)strlcat(buffer,"$",CF_EXPANDSIZE);
}
else
{
@@ -722,7 +722,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,"$(dollar)");
+ (void)strlcat(buffer,"$(dollar)",CF_EXPANDSIZE);
}
break;
@@ -744,7 +744,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,VREPOSITORY);
+ (void)strlcat(buffer,VREPOSITORY,CF_EXPANDSIZE);
}
break;
@@ -766,7 +766,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,env);
+ (void)strlcat(buffer,env,CF_EXPANDSIZE);
Debug("Expansion gave (%s)\n",buffer);
break;
@@ -782,7 +782,7 @@ for (sp = string; /* No exit */ ; sp++)
{
snprintf(name,CF_MAXVARSIZE,"$(%s)",currentitem);
}
- strcat(buffer,name);
+ (void)strlcat(buffer,name,CF_EXPANDSIZE);
}
sp += strlen(currentitem);
@@ -816,7 +816,7 @@ for (sp = string; /* No exit */ ; sp++)
sscanf(sp,"%[^$]",currentitem);
- strcat(buffer,currentitem);
+ (void)strlcat(buffer,currentitem,CF_EXPANDSIZE);
sp += strlen(currentitem);
if (*sp == '$')
@@ -830,7 +830,7 @@ for (sp = string; /* No exit */ ; sp++)
varstring = '}';
break;
default:
- strcat(buffer,"$");
+ (void)strlcat(buffer,"$",CF_EXPANDSIZE);
continue;
}
sp++;
@@ -844,7 +844,7 @@ for (sp = string; /* No exit */ ; sp++)
}
else
{
- sprintf(scanstr,"%%[^%c]",varstring); /* select the correct terminator */
+ (void)snprintf(scanstr,sizeof(scanstr),"%%[^%c]",varstring); /* select the correct terminator */
sscanf(++sp,scanstr,currentitem); /* reduce item */
switch (ScanVariable(currentitem))
@@ -854,7 +854,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,bserver);
+ (void)strlcat(buffer,bserver,CF_EXPANDSIZE);
break;
}
@@ -915,7 +915,7 @@ if (!IsVarString(varstring))
return liststart;
}
-sprintf(format,"%%[^%c]",sep); /* set format string to search */
+(void)snprintf(format,sizeof(format),"%%[^%c]",sep); /* set format string to search */
i = 0; /* extract variable */

View File

@ -1,12 +0,0 @@
$OpenBSD: patch-src_wrapper_c,v 1.2 2005/07/21 15:16:47 aanriot Exp $
--- src/wrapper.c.orig Sun Mar 20 04:10:11 2005
+++ src/wrapper.c Fri Jul 15 12:24:01 2005
@@ -308,7 +308,7 @@ ptr=(struct File *)vp;
ExpandVarstring(dir,directory,"");
AddSlash(directory);
-strcat(directory,".");
+(void)strlcat(directory,".",sizeof(directory));
MakeDirectoriesFor(directory,'n');

View File

@ -1,6 +1,4 @@
@comment $OpenBSD: PLIST,v 1.9 2005/10/27 21:47:28 sturm Exp $
@comment doc/
@comment doc/cfengine-${V}/
@comment $OpenBSD: PLIST,v 1.10 2007/10/12 20:12:19 sturm Exp $
@info info/cfengine-Anomalies.info
@info info/cfengine-Reference.info
@info info/cfengine-Tutorial.info