revive cfengine port

this is version 2.1.6, from and maintained by
William Yodlowsky <bsd at openbsd.rutgers.edu>
This commit is contained in:
sturm 2004-06-17 11:21:42 +00:00
parent 6a7749ca29
commit aec4c941c3
57 changed files with 5675 additions and 0 deletions

View File

@ -0,0 +1,27 @@
# $OpenBSD: Makefile,v 1.16 2004/06/17 11:21:42 sturm Exp $
COMMENT= "GNU system administration tool for networks"
DISTNAME= cfengine-2.1.6
CATEGORIES= sysutils
HOMEPAGE= http://www.cfengine.org/
MAINTAINER= William Yodlowsky <bsd@openbsd.rutgers.edu>
# License: GPL
PERMIT_PACKAGE_CDROM= Yes
PERMIT_PACKAGE_FTP= Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
MASTER_SITES= ftp://ftp.iu.hio.no/pub/cfengine/
CONFIGURE_STYLE= gnu
CONFIGURE_ARGS+= --with-docs
LIB_DEPENDS= lib/db4/db.4:db-4.*:databases/db/v4
CONFIGURE_ENV= ac_cv_lib_pthread_main=no
.include <bsd.port.mk>

View File

@ -0,0 +1,3 @@
MD5 (cfengine-2.1.6.tar.gz) = 7b6ca6339d0dd6bdcaa3dd2765dd3d08
RMD160 (cfengine-2.1.6.tar.gz) = ffce455311c5df2bb2585736e59192ad7a6f4e06
SHA1 (cfengine-2.1.6.tar.gz) = bdcad92039ed479f59978b5709c42e0e2ebb03f5

View File

@ -0,0 +1,11 @@
$OpenBSD: patch-configure,v 1.1 2004/06/17 11:21:42 sturm Exp $
--- configure.orig 2004-05-05 11:20:34.000000000 -0400
+++ configure 2004-05-12 11:59:56.000000000 -0400
@@ -9126,6 +9126,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

View File

@ -0,0 +1,32 @@
$OpenBSD: patch-doc_Makefile_in,v 1.1 2004/06/17 11:21:42 sturm Exp $
--- doc/Makefile.in.orig 2004-05-05 17:20:31.000000000 +0200
+++ doc/Makefile.in 2004-06-15 16:25:20.000000000 +0200
@@ -70,7 +70,7 @@ MANS = $(man_MANS)
docDATA_INSTALL = $(INSTALL_DATA)
htmlDATA_INSTALL = $(INSTALL_DATA)
psDATA_INSTALL = $(INSTALL_DATA)
-DATA = $(doc_DATA) $(html_DATA) $(ps_DATA)
+DATA =
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
@@ -708,8 +708,8 @@ info: info-am
info-am: $(INFO_DEPS)
-install-data-am: install-docDATA install-htmlDATA install-info-am \
- install-man install-psDATA
+install-data-am: install-docDATA install-info-am \
+ install-man
install-exec-am:
@@ -774,7 +774,7 @@ uninstall-am: uninstall-docDATA uninstal
uninstall-man: uninstall-man8
.PHONY: all all-am check check-am clean clean-generic dist-info \
- distclean distclean-generic distdir dvi dvi-am html html-am \
+ distclean distclean-generic distdir dvi dvi-am \
info info-am install install-am install-data install-data-am \
install-docDATA install-exec install-exec-am install-htmlDATA \
install-info install-info-am install-man install-man8 \

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-inputs_Makefile_in,v 1.1 2004/06/17 11:21:42 sturm Exp $
--- inputs/Makefile.in.orig 2004-05-11 15:16:09.000000000 -0400
+++ inputs/Makefile.in 2004-05-11 15:16:11.000000000 -0400
@@ -17,7 +17,7 @@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
-pkgdatadir = $(datadir)/@PACKAGE@
+pkgdatadir = $(datadir)/examples/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..

View File

@ -0,0 +1,14 @@
$OpenBSD: patch-pub_getopt_c,v 1.1 2004/06/17 11:21:42 sturm Exp $
--- pub/getopt.c.orig 2004-06-12 23:37:42.000000000 -0400
+++ pub/getopt.c 2004-06-12 23:38:17.000000000 -0400
@@ -60,6 +60,10 @@ Cambridge, MA 02139, USA. */
#include <stdlib.h>
#endif /* GNU C library. */
+#ifdef __OpenBSD__
+#include <unistd.h>
+#endif
+
/* This version of `getopt' appears to the caller like standard Unix `getopt'
but it behaves differently for the user, since it allows the user
to intersperse the options with the other arguments.

View File

@ -0,0 +1,17 @@
$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

@ -0,0 +1,132 @@
$OpenBSD: patch-src_cfagent_c,v 1.1 2004/06/17 11:21:42 sturm Exp $
--- src/cfagent.c.orig Sat Apr 17 16:10:58 2004
+++ src/cfagent.c Thu Jun 17 12:54:38 2004
@@ -214,7 +214,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();
SetSignals();
@@ -229,7 +229,7 @@ VDEFAULTROUTE[0] = '\0';
ALLCLASSBUFFER[0] = '\0';
VREPOSITORY = strdup("\0");
-strcpy(METHODNAME,"cf-nomethod");
+(void)strlcpy(METHODNAME,"cf-nomethod",sizeof(METHODNAME));
METHODREPLYTO[0] = '\0';
METHODRETURNVARS[0] = '\0';
METHODRETURNCLASSES[0] = '\0';
@@ -238,8 +238,8 @@ METHODRETURNCLASSES[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();
@@ -280,7 +280,7 @@ for (i = 1; i < argc; i++)
VIFELAPSED = VDEFAULTIFELAPSED;
TRAVLINKS = false;
- sprintf(ebuff,"%s/state/cf_procs",WORKDIR);
+ (void)snprintf(ebuff,sizeof(ebuff),"%s/state/cf_procs",WORKDIR);
if (stat(ebuff,&statbuf) == -1)
{
@@ -287,8 +287,8 @@ for (i = 1; i < argc; i++)
CreateEmptyFile(ebuff);
}
- strcpy(VLOGDIR,WORKDIR);
- strcpy(VLOCKDIR,VLOGDIR); /* Same since 2.0.a8 */
+ (void)strlcpy(VLOGDIR,WORKDIR,CF_BUFSIZE);
+ (void)strlcpy(VLOCKDIR,VLOGDIR,CF_BUFSIZE); /* Same since 2.0.a8 */
OpenSSL_add_all_algorithms();
ERR_load_crypto_strings();
@@ -317,8 +317,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)
{
@@ -605,8 +605,8 @@ if (strlen(ebuff) != 0)
}
else
{
- strcpy(VPREFIX,"cfengine:");
- strcat(VPREFIX,VUQNAME);
+ (void)strlcpy(VPREFIX,"cfengine:",40);
+ (void)strlcat(VPREFIX,VUQNAME,40);
}
@@ -744,7 +744,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))
{
@@ -888,7 +888,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] == '\\')
{
@@ -1066,7 +1066,7 @@ if ((tloc = time((time_t *)NULL)) == -1)
CFSTARTTIME = tloc;
-snprintf(vbuff,CF_BUFSIZE,"%s",ctime(&tloc));
+snprintf(vbuff,CF_MAXVARSIZE,"%s",ctime(&tloc));
Verbose("Reference time set to %s\n",ctime(&tloc));
@@ -1429,7 +1429,7 @@ while (*sp != '\0')
{
VIFELAPSED = VDEFAULTIFELAPSED;
VEXPIREAFTER = VDEFAULTEXPIREAFTER;
- strcpy(actiontxt,cbuff);
+ (void)strlcpy(actiontxt,cbuff,sizeof(actiontxt));
continue;
}
else
@@ -1828,8 +1828,8 @@ for (ip = VHEAP; ip != NULL; ip=ip->next
{
size++; /* Allow for : separator */
}
- strcat(ALLCLASSBUFFER,ip->name);
- strcat(ALLCLASSBUFFER,":");
+ (void)strlcat(ALLCLASSBUFFER,ip->name,sizeof(ALLCLASSBUFFER));
+ (void)strlcat(ALLCLASSBUFFER,":",sizeof(ALLCLASSBUFFER));
}
}
@@ -1848,8 +1848,8 @@ for (ip = VHEAP; ip != NULL; ip=ip->next
size++; /* Allow for : separator */
}
- strcat(ALLCLASSBUFFER,ip->name);
- strcat(ALLCLASSBUFFER,":");
+ (void)strlcat(ALLCLASSBUFFER,ip->name,sizeof(ALLCLASSBUFFER));
+ (void)strlcat(ALLCLASSBUFFER,":",sizeof(ALLCLASSBUFFER));
}
}

View File

@ -0,0 +1,276 @@
$OpenBSD: patch-src_cfenvd_c,v 1.1 2004/06/17 11:21:42 sturm Exp $
--- src/cfenvd.c.orig Mon Apr 19 11:41:05 2004
+++ src/cfenvd.c Thu Jun 17 12:54:38 2004
@@ -188,10 +188,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';
@@ -242,9 +242,9 @@ while ((c=getopt_long(argc,argv,"d:vhHFV
LOGGING = true; /* Do output to syslog */
-sprintf(VBUFF,"%s/test",WORKDIR);
+(void)snprintf(VBUFF,sizeof(VBUFF),"%s/test",WORKDIR);
MakeDirectoriesFor(VBUFF,'y');
-sprintf(VBUFF,"%s/state/test",WORKDIR);
+(void)snprintf(VBUFF,sizeof(VBUFF),"%s/state/test",WORKDIR);
MakeDirectoriesFor(VBUFF,'y');
strncpy(VLOCKDIR,WORKDIR,CF_BUFSIZE-1);
strncpy(VLOGDIR,WORKDIR,CF_BUFSIZE-1);
@@ -251,9 +251,9 @@ strncpy(VLOGDIR,WORKDIR,CF_BUFSIZE-1);
for (i = 0; i < ATTR; i++)
{
- sprintf(VBUFF,"%s/state/cf_incoming.%s",WORKDIR,ECGSOCKS[i][1]);
+ (void)snprintf(VBUFF,sizeof(VBUFF),"%s/state/cf_incoming.%s",WORKDIR,ECGSOCKS[i][1]);
CreateEmptyFile(VBUFF);
- sprintf(VBUFF,"%s/state/cf_outgoing.%s",WORKDIR,ECGSOCKS[i][1]);
+ (void)snprintf(VBUFF,sizeof(VBUFF),"%s/state/cf_outgoing.%s",WORKDIR,ECGSOCKS[i][1]);
CreateEmptyFile(VBUFF);
}
@@ -263,13 +263,13 @@ for (i = 0; i < CF_NETATTR; i++)
NETOUT_DIST[i] = NULL;
}
-sprintf(VBUFF,"%s/state/cf_users",WORKDIR);
+(void)snprintf(VBUFF,sizeof(VBUFF),"%s/state/cf_users",WORKDIR);
CreateEmptyFile(VBUFF);
-snprintf(AVDB,CF_BUFSIZE,"%s/state/%s",WORKDIR,CF_AVDB_FILE);
-snprintf(STATELOG,CF_BUFSIZE,"%s/state/%s",WORKDIR,CF_STATELOG_FILE);
-snprintf(ENV_NEW,CF_BUFSIZE,"%s/state/%s",WORKDIR,CF_ENVNEW_FILE);
-snprintf(ENV,CF_BUFSIZE,"%s/state/%s",WORKDIR,CF_ENV_FILE);
+snprintf(AVDB,sizeof(AVDB),"%s/state/%s",WORKDIR,CF_AVDB_FILE);
+snprintf(STATELOG,sizeof(AVDB),"%s/state/%s",WORKDIR,CF_STATELOG_FILE);
+snprintf(ENV_NEW,sizeof(AVDB),"%s/state/%s",WORKDIR,CF_ENVNEW_FILE);
+snprintf(ENV,sizeof(AVDB),"%s/state/%s",WORKDIR,CF_ENV_FILE);
if (!BATCH_MODE)
{
@@ -459,7 +459,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);
}
@@ -618,7 +618,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);
}
@@ -784,14 +784,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);
@@ -811,13 +811,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);
}
@@ -1135,7 +1135,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)
{
@@ -1466,7 +1466,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;
}
@@ -1477,7 +1477,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;
}
@@ -1527,7 +1527,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;
}
@@ -1538,7 +1538,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;
}
@@ -1765,19 +1765,19 @@ 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));
@@ -1784,8 +1784,8 @@ if (fabs(delta) < cf_noise_threshold) /*
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);
}
@@ -1795,19 +1795,19 @@ 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));
@@ -1814,14 +1814,14 @@ if (fabs(delta) < cf_noise_threshold) /*
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");
}
@@ -1831,8 +1831,8 @@ 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);
}
@@ -1839,8 +1839,8 @@ if (fabs(delta) < cf_noise_threshold) /*
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);
}
@@ -1855,13 +1855,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

@ -0,0 +1,282 @@
$OpenBSD: patch-src_cfenvgraph_c,v 1.1 2004/06/17 11:21:42 sturm Exp $
--- src/cfenvgraph.c.orig Mon Apr 19 12:00:16 2004
+++ src/cfenvgraph.c Thu Jun 17 12:54:38 2004
@@ -171,7 +171,7 @@ fgets(line,CF_BUFSIZE,pp);
fgets(line,CF_BUFSIZE,pp);
line[0] = '\0';
fgets(line,CF_BUFSIZE,pp);
-strcpy(VFQNAME,line);
+(void)strlcpy(VFQNAME,line,CF_MAXVARSIZE);
if (strlen(VFQNAME) == 0)
{
@@ -181,7 +181,7 @@ if (strlen(VFQNAME) == 0)
perror("uname ");
exit(0);
}
- strcpy(VFQNAME,sys.sysname);
+ (void)strlcpy(VFQNAME,sys.sysname,CF_MAXVARSIZE);
}
else
{
@@ -279,7 +279,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;
@@ -548,7 +548,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++)
{
@@ -560,7 +560,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);
@@ -582,7 +582,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)
{
@@ -590,7 +590,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)
{
@@ -603,31 +603,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");
@@ -636,7 +636,7 @@ 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");
@@ -643,7 +643,7 @@ if (SEPARATE)
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");
@@ -653,7 +653,7 @@ 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");
@@ -660,7 +660,7 @@ if (SEPARATE)
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");
@@ -675,7 +675,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");
@@ -765,7 +765,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;
@@ -1017,7 +1017,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",WORKDIR);
+ snprintf(FLNAME,sizeof(FLNAME),"%s/state/histograms",WORKDIR);
if ((fp = fopen(FLNAME,"r")) == NULL)
{
@@ -1074,31 +1074,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");
@@ -1107,7 +1107,7 @@ 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");
@@ -1114,7 +1114,7 @@ for (i = 0; i < 7; i++)
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");
@@ -1124,13 +1124,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)
{
@@ -1146,7 +1146,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");
@@ -1378,7 +1378,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;
@@ -1481,7 +1481,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;
@@ -1535,7 +1535,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++)
{
@@ -1607,7 +1607,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

@ -0,0 +1,128 @@
$OpenBSD: patch-src_cfexecd_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/cfexecd.c.orig Sat Apr 17 16:11:14 2004
+++ src/cfexecd.c Thu Jun 17 12:54:38 2004
@@ -143,7 +143,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:vhpFV1g",CFDOPTIONS,&optindex)) != EOF)
@@ -224,7 +224,7 @@ strncpy(VLOGDIR,WORKDIR,CF_BUFSIZE-1);
VCANONICALFILE = strdup(CanonifyName(VINPUTFILE));
GetNameInfo();
-strcpy(VUQNAME,VSYSNAME.nodename);
+(void)strlcpy(VUQNAME,VSYSNAME.nodename,CF_MAXVARSIZE);
}
@@ -408,7 +408,7 @@ if (strstr(line,"No SMTP"))
CfLog(cferror,"Need: smtpserver = ( ?? ) in control ","");
}
-strcpy(VMAILSERVER,line);
+(void)strlcpy(VMAILSERVER,line,sizeof(VMAILSERVER));
Debug("Got cfengine SMTP server as (%s)\n",VMAILSERVER);
@@ -422,19 +422,19 @@ if (strlen(line) == 0)
CfLog(cferror,"Need: sysadm = ( ??@?? ) in control ","");
}
-strcpy(MAILTO,line);
+(void)strlcpy(MAILTO,line,sizeof(MAILTO));
Debug("Got cfengine sysadm variable (%s)\n",MAILTO);
line[0] = '\0';
fgets(line,CF_BUFSIZE,pp);
Chop(line);
-strcpy(VFQNAME,line);
+(void)strlcpy(VFQNAME,line,CF_MAXVARSIZE);
Debug("Got fully qualified name (%s)\n",VFQNAME);
line[0] = '\0';
fgets(line,CF_BUFSIZE,pp);
Chop(line);
-strcpy(VIPADDRESS,line);
+(void)strlcpy(VIPADDRESS,line,18);
Debug("Got IP (%s)\n",VIPADDRESS);
if ((ungetc(fgetc(pp), pp)) != '[')
@@ -909,7 +909,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);
if (!Dialogue(sd,VBUFF))
{
@@ -916,7 +916,7 @@ sprintf(VBUFF,"HELO %s\r\n",VFQNAME);
goto mail_err;
}
-sprintf(VBUFF,"MAIL FROM: <cfengine@%s>\r\n",VFQNAME);
+(void)snprintf(VBUFF,sizeof(VBUFF),"MAIL FROM: <cfengine@%s>\r\n",VFQNAME);
if (!Dialogue(sd,VBUFF))
{
@@ -923,7 +923,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);
if (!Dialogue(sd,VBUFF))
{
@@ -937,18 +937,18 @@ 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);
}
else
{
- sprintf(VBUFF,"Subject: (%s/%s)\r\n",VFQNAME,VIPADDRESS);
+ (void)snprintf(VBUFF,sizeof(VBUFF),"Subject: (%s/%s)\r\n",VFQNAME,VIPADDRESS);
}
sent=send(sd,VBUFF,strlen(VBUFF),0);
-sprintf(VBUFF,"From: cfengine@%s\r\n",VFQNAME);
+(void)snprintf(VBUFF,sizeof(VBUFF),"From: cfengine@%s\r\n",VFQNAME);
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);
sent=send(sd,VBUFF,strlen(VBUFF),0);
while(!feof(fp))
@@ -958,13 +958,13 @@ 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;
}
@@ -985,7 +985,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(cferror,VBUFF,"");
}

View File

@ -0,0 +1,14 @@
$OpenBSD: patch-src_cfkey_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/cfkey.c.orig 2004-06-10 23:26:34.000000000 -0400
+++ src/cfkey.c 2004-06-10 22:30:18.000000000 -0400
@@ -147,8 +147,8 @@ void Initialize()
{
umask(077);
-strcpy(VLOCKDIR,WORKDIR);
-strcpy(VLOGDIR,WORKDIR);
+(void)strlcpy(VLOCKDIR,WORKDIR,CF_BUFSIZE);
+(void)strlcpy(VLOGDIR,WORKDIR,CF_BUFSIZE);
OpenSSL_add_all_algorithms();
ERR_load_crypto_strings();

View File

@ -0,0 +1,39 @@
$OpenBSD: patch-src_cflex_l_in,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/cflex.l.in.orig 2004-06-12 22:55:29.000000000 -0400
+++ src/cflex.l.in 2004-06-12 22:56:13.000000000 -0400
@@ -224,7 +224,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;
@@ -233,7 +233,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;
@@ -241,7 +241,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;
@@ -250,7 +250,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

@ -0,0 +1,94 @@
$OpenBSD: patch-src_cfrun_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/cfrun.c.orig 2004-04-17 10:11:04.000000000 -0400
+++ src/cfrun.c 2004-06-10 22:32:35.000000000 -0400
@@ -242,23 +242,23 @@ if (uname(&VSYSNAME) == -1)
if ((strlen(VDOMAIN) > 0) && !strchr(VSYSNAME.nodename,'.'))
{
- sprintf(VFQNAME,"%s.%s",VSYSNAME.nodename,VDOMAIN);
+ (void)snprintf(VFQNAME,CF_MAXVARSIZE,"%s.%s",VSYSNAME.nodename,VDOMAIN);
}
else
{
- sprintf(VFQNAME,"%s",VSYSNAME.nodename);
+ (void)snprintf(VFQNAME,CF_MAXVARSIZE,"%s",VSYSNAME.nodename);
}
*/
Debug("FQNAME = %s\n",VFQNAME);
-sprintf(VPREFIX,"cfrun:%s",VFQNAME);
+(void)snprintf(VPREFIX,40,"cfrun:%s",VFQNAME);
/* Read hosts file */
umask(077);
-strcpy(VLOCKDIR,WORKDIR);
-strcpy(VLOGDIR,WORKDIR);
+(void)strlcpy(VLOCKDIR,WORKDIR,CF_BUFSIZE);
+(void)strlcpy(VLOGDIR,WORKDIR,CF_BUFSIZE);
OpenSSL_add_all_algorithms();
ERR_load_crypto_strings();
@@ -292,7 +292,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;
@@ -562,10 +562,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
@@ -574,7 +574,7 @@ if (!strchr(VCFRUNHOSTS, '/'))
}
}
-strcat(filename,VCFRUNHOSTS);
+(void)strlcat(filename,VCFRUNHOSTS,sizeof(filename));
if ((fp = fopen(filename,"r")) == NULL) /* Open root file */
{
@@ -687,8 +687,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))
@@ -746,8 +746,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;
@@ -766,7 +766,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

@ -0,0 +1,177 @@
$OpenBSD: patch-src_cfservd_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/cfservd.c.orig 2004-04-17 10:11:16.000000000 -0400
+++ src/cfservd.c 2004-06-12 23:42:42.000000000 -0400
@@ -164,10 +164,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';
/*
@@ -269,7 +269,7 @@ strncpy(VLOCKDIR,WORKDIR,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");
@@ -981,7 +981,7 @@ if (CFDSTARTTIME < newstat.st_mtime)
DeleteItemList(TRUSTKEYLIST);
DeleteAuthList(VADMIT);
DeleteAuthList(VDENY);
- strcpy(VDOMAIN,"undefined.domain");
+ (void)strlcpy(VDOMAIN,"undefined.domain",sizeof(VDOMAIN));
VADMIT = VADMITTOP = NULL;
VDENY = VDENYTOP = NULL;
@@ -1355,7 +1355,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;
@@ -1420,7 +1420,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;
@@ -1528,7 +1528,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;
}
@@ -1569,8 +1569,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);
@@ -2377,7 +2377,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;
@@ -2480,12 +2480,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);
@@ -2687,13 +2687,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);
}
@@ -2711,7 +2711,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;
}
@@ -2743,7 +2743,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);
@@ -2758,7 +2758,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)
{
@@ -2977,7 +2977,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;
}
@@ -2988,7 +2988,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;
}
@@ -3061,7 +3061,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;
}
@@ -3072,7 +3072,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

@ -0,0 +1,28 @@
$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

@ -0,0 +1,26 @@
$OpenBSD: patch-src_crypto_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/crypto.c.orig 2004-04-17 10:11:17.000000000 -0400
+++ src/crypto.c 2004-06-10 15:47:30.000000000 -0400
@@ -49,11 +49,11 @@ snprintf(VBUFF,CF_BUFSIZE,"%s/randseed",
if (stat(VBUFF,&statbuf) == -1)
{
- snprintf(AVDB,CF_BUFSIZE,"%s/%s",WORKDIR,CF_AVDB_FILE);
+ snprintf(AVDB,sizeof(AVDB),"%s/%s",WORKDIR,CF_AVDB_FILE);
}
else
{
- strcpy(AVDB,VBUFF);
+ (void)strlcpy(AVDB,VBUFF,sizeof(AVDB));
}
Verbose("Looking for a source of entropy in %s\n",AVDB);
@@ -291,7 +291,7 @@ snprintf(buffer,CF_BUFSIZE,"%d%d%25s",(i
EVP_DigestUpdate(&context,buffer,CF_BUFSIZE);
-snprintf(pscomm,CF_BUFSIZE,"%s %s",VPSCOMM[VSYSTEMHARDCLASS],VPSOPTS[VSYSTEMHARDCLASS]);
+snprintf(pscomm,CF_MAXLINKSIZE,"%s %s",VPSCOMM[VSYSTEMHARDCLASS],VPSOPTS[VSYSTEMHARDCLASS]);
if ((pp = cfpopen(pscomm,"r")) == NULL)
{

View File

@ -0,0 +1,473 @@
$OpenBSD: patch-src_do_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/do.c.orig Sat Apr 17 16:10:55 2004
+++ src/do.c Thu Jun 17 12:54:38 2004
@@ -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))
{
@@ -230,13 +230,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;
@@ -246,13 +246,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;
@@ -261,18 +261,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:
@@ -344,12 +344,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);
}
@@ -633,7 +633,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 */
@@ -643,9 +643,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 */
@@ -713,9 +713,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)
{
@@ -1190,9 +1190,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);
}
@@ -1429,6 +1429,7 @@ void GetSetuidLog()
struct Item *ip;
FILE *fp;
char *sp;
+ size_t buflen;
if (!IsPrivileged()) /* Ignore this if not root */
{
@@ -1455,7 +1456,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");
@@ -1472,7 +1474,7 @@ else
Debug2("SETUID-LOG: %s\n",VBUFF);
- strcpy(sp,VBUFF);
+ (void)strlcpy(sp,VBUFF,buflen);
ip->name = sp;
ip->next = NULL;
filetop = ip;
@@ -1767,7 +1769,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))
@@ -1778,13 +1780,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\n",workname,path);
@@ -1912,15 +1914,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 */
@@ -1932,11 +1934,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))
@@ -2006,15 +2008,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 */
@@ -2168,8 +2170,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);
@@ -2193,8 +2195,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
@@ -2584,7 +2586,7 @@ for (ip = VTIMEZONE; ip != NULL; ip=ip->
#ifdef NT
tzset();
- strcpy(tz,timezone());
+ (void)strlcpy(tz,timezone(),sizeof(tz));
#else
#ifndef AOS
@@ -2591,7 +2593,7 @@ for (ip = VTIMEZONE; ip != NULL; ip=ip->
#ifndef SUN4
tzset();
- strcpy(tz,tzname[0]);
+ (void)strlcpy(tz,tzname[0],sizeof(tz));
#else
@@ -2599,7 +2601,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 */
@@ -2839,14 +2841,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)
{
@@ -2874,7 +2876,7 @@ 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);
}
@@ -2881,7 +2883,7 @@ if (S_ISDIR(statbuf.st_mode))
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);
}
@@ -2929,7 +2931,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))
@@ -2938,7 +2940,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)
{
@@ -2982,9 +2984,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))
{
@@ -3086,16 +3088,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;
@@ -3244,14 +3246,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) != '/')
@@ -3262,7 +3264,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);
@@ -3296,11 +3298,11 @@ else
EditItemsInResolvConf(from->next,list);
if (isdigit((int)*(work)))
{
- snprintf(buf,CF_BUFSIZE,"nameserver %s",work);
+ snprintf(buf,CF_MAXVARSIZE,"nameserver %s",work);
}
else
{
- strcpy(buf,work);
+ (void)strlcpy(buf,work,sizeof(buf));
}
DeleteItemMatching(list,buf); /* del+prep = move to head of list */
@@ -3373,7 +3375,7 @@ if (strlen(extract) == 0)
{
if (isdir)
{
- strcat(buffer,"/");
+ (void)strlcat(buffer,"/",CF_EXPANDSIZE);
}
(*function)(buffer,argptr);
return;
@@ -3381,7 +3383,7 @@ 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);
@@ -3388,13 +3390,13 @@ if (! IsWildCard(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)
{
@@ -3404,7 +3406,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))
{
@@ -3414,8 +3416,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

@ -0,0 +1,120 @@
$OpenBSD: patch-src_edittools_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/edittools.c.orig Thu Apr 22 21:34:19 2004
+++ src/edittools.c Thu Jun 17 12:54:38 2004
@@ -74,7 +74,7 @@ for (dirp = readdir(dirh); dirp != NULL;
continue;
}
- strcpy(pcwd,name); /* Assemble pathname */
+ (void)strlcpy(pcwd,name,sizeof(pcwd)); /* Assemble pathname */
AddSlash(pcwd);
if (BufferOverflow(pcwd,dirp->d_name))
@@ -82,7 +82,7 @@ for (dirp = readdir(dirh); dirp != NULL;
return true;
}
- strcat(pcwd,dirp->d_name);
+ (void)strlcat(pcwd,dirp->d_name,sizeof(pcwd));
if (!FileObjectFilter(pcwd,&statbuf,ptr->filters,editfiles))
{
@@ -190,9 +190,9 @@ for (ip = VMOUNTLIST; ip != NULL; ip=ip-
continue;
}
- strcpy(homedir,ip->name);
+ (void)strlcpy(homedir,ip->name,sizeof(homedir));
AddSlash(homedir);
- strcat(homedir,dirp->d_name);
+ (void)strlcat(homedir,dirp->d_name,sizeof(homedir));
if (! IsHomeDir(homedir))
{
@@ -213,12 +213,12 @@ for (ip = VMOUNTLIST; ip != NULL; ip=ip-
continue;
}
- strcpy(dest,homedir);
+ (void)strlcpy(dest,homedir,sizeof(dest));
AddSlash(dest);
- strcat(dest,dirp2->d_name);
+ (void)strlcat(dest,dirp2->d_name,sizeof(dest));
AddSlash(dest);
sp = ptr->fname + strlen("home/");
- strcat(dest,sp);
+ (void)strlcat(dest,sp,sizeof(dest));
if (stat(dest,&statbuf))
{
@@ -276,7 +276,7 @@ if (lstat(filename,&statbuf) != -1)
if (linkname[0] != '/')
{
- strcpy(realname,filename);
+ (void)strlcpy(realname,filename,sizeof(realname));
ChopLastNode(realname);
AddSlash(realname);
}
@@ -299,7 +299,7 @@ if (lstat(filename,&statbuf) != -1)
}
}
- strcat(realname,linkname);
+ (void)strlcat(realname,linkname,sizeof(realname));
if (!FileObjectFilter(realname,&statbuf2,ptr->filters,editfiles))
{
@@ -401,8 +401,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;
@@ -1303,6 +1303,7 @@ return true;
int ReplaceEditLineWith (char *string)
{ char *sp;
+ size_t splen;
if (strcmp(string,CURRENTLINEPTR->name) == 0)
{
@@ -1310,7 +1311,8 @@ 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;
@@ -1317,7 +1319,7 @@ if ((sp = malloc(strlen(string)+1)) == N
}
EditVerbose("Replacing line %d with %10s...\n",CURRENTLINENUMBER,string);
-strcpy(sp,string);
+(void)strlcpy(sp,string,splen);
free (CURRENTLINEPTR->name);
CURRENTLINEPTR->name = sp;
NUMBEROFEDITS++;
@@ -2023,10 +2025,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

@ -0,0 +1,84 @@
$OpenBSD: patch-src_eval_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/eval.c.orig 2004-04-17 10:11:08.000000000 -0400
+++ src/eval.c 2004-06-10 15:35:56.000000000 -0400
@@ -212,7 +212,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);
@@ -220,7 +220,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);
@@ -260,19 +260,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;
}
@@ -280,7 +280,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);
@@ -300,9 +300,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);
}
@@ -533,7 +533,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);
}
@@ -827,7 +827,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

@ -0,0 +1,48 @@
$OpenBSD: patch-src_filedir_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/filedir.c.orig 2004-06-10 10:50:03.000000000 -0400
+++ src/filedir.c 2004-06-10 11:21:14.000000000 -0400
@@ -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)
{
@@ -1168,7 +1168,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))
{
@@ -1189,7 +1189,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 */
@@ -1259,7 +1259,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

@ -0,0 +1,80 @@
$OpenBSD: patch-src_filenames_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/filenames.c.orig 2004-06-10 10:50:04.000000000 -0400
+++ src/filenames.c 2004-06-10 12:15:00.000000000 -0400
@@ -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;
@@ -365,9 +365,9 @@ if (strstr(pathbuf, _PATH_RSRCFORKSPEC)
struct TidyPattern tpat;
struct stat sbuf;
- 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,"");
@@ -633,7 +633,7 @@ for (sp = src+rootlen; *sp != '\0'; sp++
return false;
}
- strcat(dest,node);
+ (void)strlcat(dest,node,CF_BUFSIZE);
}
return true;
@@ -695,7 +695,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

@ -0,0 +1,51 @@
$OpenBSD: patch-src_filters_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/filters.c.orig 2004-06-10 10:50:04.000000000 -0400
+++ src/filters.c 2004-06-10 11:33:57.000000000 -0400
@@ -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--)
@@ -1025,15 +1025,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);
@@ -1145,7 +1145,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)
@@ -1177,7 +1177,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

@ -0,0 +1,323 @@
$OpenBSD: patch-src_functions_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/functions.c.orig Sat May 1 15:36:52 2004
+++ src/functions.c Thu Jun 17 12:54:39 2004
@@ -206,13 +206,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;
}
}
@@ -307,7 +307,7 @@ if (strchr(args,','))
if (lstat(args,&statbuf) == -1)
{
- strcpy(value,CF_NOCLASS);
+ (void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
return;
}
else
@@ -314,12 +314,12 @@ if (lstat(args,&statbuf) == -1)
{
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)
{
@@ -326,7 +326,7 @@ strcpy(value,CF_NOCLASS);
case fn_isdir:
if (S_ISDIR(statbuf.st_mode))
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
return;
}
break;
@@ -333,7 +333,7 @@ strcpy(value,CF_NOCLASS);
case fn_islink:
if (S_ISLNK(statbuf.st_mode))
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
return;
}
break;
@@ -340,13 +340,13 @@ strcpy(value,CF_NOCLASS);
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);
}
/*********************************************************************/
@@ -361,7 +361,7 @@ if (strchr(args,','))
return;
}
-strcpy(value,CF_NOCLASS);
+(void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
if (!FuzzyMatchParse(args))
{
@@ -370,7 +370,7 @@ if (!FuzzyMatchParse(args))
if (FuzzySetMatch(args,VIPADDRESS) == 0)
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
}
}
@@ -385,7 +385,7 @@ void HandleHostRange(char *args,char *va
if (!FuzzyHostParse(args))
{
- strcpy(value,CF_NOCLASS);
+ (void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
return;
}
/* VDEFAULTBINSERVER.name is relative domain name */
@@ -394,12 +394,12 @@ void HandleHostRange(char *args,char *va
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;
@@ -414,7 +414,7 @@ void HandleCompareStat(enum builtin fn,c
int count = 0;
FunctionArgs(args,argv,2);
-strcpy(value,CF_NOCLASS);
+(void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
if (stat(argv[0],&frombuf) == -1)
{
@@ -431,7 +431,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;
@@ -439,7 +439,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;
@@ -447,13 +447,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);
}
@@ -500,7 +500,7 @@ if (*args == '/')
if (ShellCommandReturnsZero(command))
{
- strcpy(value,CF_ANYCLASS);
+ (void)strlcpy(value,CF_ANYCLASS,CF_EXPANDSIZE);
return;
}
}
@@ -509,7 +509,7 @@ if (*args == '/')
yyerror("ExecResult(/command) must specify an absolute path");
}
- strcpy(value,CF_NOCLASS);
+ (void)strlcpy(value,CF_NOCLASS,CF_EXPANDSIZE);
}
@@ -527,11 +527,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);
}
/*********************************************************************/
@@ -547,7 +547,7 @@ value[0] = '\0';
if (PARSING)
{
- strcpy(value,"doinstall");
+ (void)strlcpy(value,"doinstall",CF_EXPANDSIZE);
return;
}
@@ -602,11 +602,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);
}
}
@@ -632,11 +632,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);
@@ -904,7 +904,7 @@ Verbose("This is a method with return va
yyerror("Redefinition of method return values");
}
-strcpy(value,"noinstall");
+(void)strlcpy(value,"noinstall",CF_EXPANDSIZE);
}
/*********************************************************************/
@@ -916,7 +916,7 @@ Verbose("This is a method with return cl
if (strlen(METHODRETURNCLASSES) == 0)
{
- strncpy(METHODRETURNCLASSES,args,CF_BUFSIZE-1);
+ strlcpy(METHODRETURNCLASSES,args,sizeof(METHODRETURNCLASSES));
}
else
{
@@ -923,7 +923,7 @@ Verbose("This is a method with return cl
yyerror("Redefinition of method return classes");
}
- strcpy(value,"noinstall");
+ (void)strlcpy(value,"noinstall",CF_EXPANDSIZE);
}
/*********************************************************************/
@@ -949,7 +949,7 @@ Debug("ShowState(%s)\n",args);
if (PARSING)
{
- strcpy(value,"doinstall");
+ (void)strlcpy(value,"doinstall",CF_EXPANDSIZE);
return;
}
@@ -1132,12 +1132,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);
}
if (dist)
@@ -1162,7 +1162,7 @@ FunctionArgs(args,argv,1);
if (PARSING)
{
- strcpy(value,"doinstall");
+ (void)strlcpy(value,"doinstall",CF_EXPANDSIZE);
return;
}
@@ -1173,7 +1173,7 @@ if (time >= 0)
CheckFriendConnections(time);
}
-strcpy(value,""); /* No reply */
+(void)strlcpy(value,"",CF_EXPANDSIZE); /* No reply */
}
/*********************************************************************/
@@ -1243,11 +1243,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);
}
}
@@ -1285,7 +1285,7 @@ if (strchr(args,','))
return;
}
-strcpy(arg1,UnQuote(args));
+(void)strlcpy(arg1,UnQuote(args),CF_BUFSIZE);
}
/*********************************************************************/

View File

@ -0,0 +1,77 @@
$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

@ -0,0 +1,66 @@
$OpenBSD: patch-src_ifconf_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/ifconf.c.orig 2004-06-10 10:50:04.000000000 -0400
+++ src/ifconf.c 2004-06-10 13:33:06.000000000 -0400
@@ -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

@ -0,0 +1,183 @@
$OpenBSD: patch-src_image_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/image.c.orig Fri Apr 30 17:20:19 2004
+++ src/image.c Thu Jun 17 12:54:39 2004
@@ -57,8 +57,8 @@ Banner("Looking for remote method collab
}
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 @@ Banner("Looking for remote method collab
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 = '>';
@@ -189,7 +189,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')
{
@@ -360,9 +360,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))
{
@@ -383,10 +383,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)
{
@@ -399,7 +399,7 @@ for (itp = VMOUNTLIST; itp != NULL; itp=
}
else
{
- strcat(dest,(ip->destination)+strlen("home/"));
+ (void)strlcat(dest,(ip->destination)+strlen("home/"),sizeof(dest));
}
}
@@ -501,9 +501,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)
@@ -535,7 +535,7 @@ if (S_ISDIR(sourcestatbuf.st_mode))
continue;
}
- strcpy(sourcefile, sourcedir);
+ (void)strlcpy(sourcefile, sourcedir, sizeof(sourcefile));
if (BufferOverflow(sourcefile,dirp->d_name))
{
@@ -542,8 +542,8 @@ if (S_ISDIR(sourcestatbuf.st_mode))
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))
{
@@ -550,7 +550,7 @@ if (S_ISDIR(sourcestatbuf.st_mode))
FatalError("Culprit: CheckImage");
}
- strcat(destfile, dirp->d_name);
+ (void)strlcat(destfile, dirp->d_name, sizeof(destfile));
if (cflstat(sourcefile,&sourcestatbuf,ip) == -1)
{
@@ -571,8 +571,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;
@@ -1005,7 +1005,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);
@@ -1381,7 +1381,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;
}
}
@@ -1569,13 +1569,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)
{
@@ -1614,7 +1614,7 @@ 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))
{
@@ -1621,15 +1621,15 @@ if (IMAGEBACKUP != 'n')
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

@ -0,0 +1,30 @@
$OpenBSD: patch-src_init_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/init.c.orig 2004-06-15 12:33:21.000000000 +0200
+++ src/init.c 2004-06-15 12:32:30.000000000 +0200
@@ -93,7 +93,7 @@ else
{
if (statbuf.st_mode & 022)
{
- snprintf(OUTPUT,CF_BUFSIZE*2,"UNTRUSTED: State directory %s was not private!\n",VLOCKDIR,statbuf.st_mode & 0777);
+ snprintf(OUTPUT,CF_BUFSIZE*2,"UNTRUSTED: State directory %s was not private! (%o)\n",VLOCKDIR,statbuf.st_mode & 0777);
CfLog(cferror,OUTPUT,"");
}
}
@@ -113,7 +113,7 @@ else
{
if (statbuf.st_mode & 022)
{
- snprintf(OUTPUT,CF_BUFSIZE*2,"UNTRUSTED: Module directory %s was not private!\n",VLOCKDIR,statbuf.st_mode & 0777);
+ snprintf(OUTPUT,CF_BUFSIZE*2,"UNTRUSTED: Module directory %s was not private! (%o)\n",VLOCKDIR,statbuf.st_mode & 0777);
CfLog(cferror,OUTPUT,"");
}
}
@@ -173,7 +173,7 @@ else
{
if (statbuf.st_mode & 077)
{
- snprintf(OUTPUT,CF_BUFSIZE*2,"UNTRUSTED: Private key directory %s/ppkeys was not private!\n",VLOCKDIR,statbuf.st_mode & 0777);
+ snprintf(OUTPUT,CF_BUFSIZE*2,"UNTRUSTED: Private key directory %s/ppkeys was not private! (%o)\n",VLOCKDIR,statbuf.st_mode & 0777);
FatalError(OUTPUT);
}
}

View File

@ -0,0 +1,541 @@
$OpenBSD: patch-src_install_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/install.c.orig 2004-05-01 15:53:44.000000000 +0200
+++ src/install.c 2004-06-15 10:36:49.000000000 +0200
@@ -106,7 +106,7 @@ else
FatalError("Redefinition of basic system variable");
}
- strcpy(VFACULTY,value);
+ (void)strlcpy(VFACULTY,value,sizeof(VFACULTY));
break;
case cfdomain:
@@ -117,7 +117,7 @@ else
if (strlen(value) > 0)
{
- strcpy(VDOMAIN,value);
+ (void)strlcpy(VDOMAIN,value,sizeof(VDOMAIN));
}
else
{
@@ -127,12 +127,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_BUFSIZE);
while(VSYSNAME.nodename[n++] != '.')
{
@@ -148,7 +148,7 @@ else
FatalError("The fully qualified name is longer than CF_MAXVARSIZE!!");
}
- strcpy(buffer,VFQNAME);
+ (void)strlcpy(buffer,VFQNAME,sizeof(buffer));
AddClassToHeap(CanonifyName(buffer));
}
@@ -161,7 +161,7 @@ else
break;
}
- strcpy(VSYSADM,value);
+ (void)strlcpy(VSYSADM,value,sizeof(VSYSADM));
break;
case cfnetmask:
@@ -175,7 +175,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;
@@ -337,7 +337,7 @@ else
break;
case cfnfstype:
- strcpy(VNFSTYPE,value);
+ (void)strlcpy(VNFSTYPE,value,sizeof(VNFSTYPE));
break;
case cfmethodname:
@@ -417,7 +417,7 @@ else
{
}
- sprintf(rename,"_%s",CLASSTEXT[VSYSTEMHARDCLASS]);
+ (void)snprintf(rename,sizeof(rename),"_%s",CLASSTEXT[VSYSTEMHARDCLASS]);
AddClassToHeap(rename);
break;
@@ -438,7 +438,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;
@@ -538,7 +538,7 @@ switch(GetCommAttribute(item))
case cfowner:
if (strlen(value) < CF_BUFSIZE)
{
- strcpy(VUIDNAME,value);
+ (void)strlcpy(VUIDNAME,value,CF_BUFSIZE);
}
else
{
@@ -549,7 +549,7 @@ switch(GetCommAttribute(item))
case cfgroup:
if (strlen(value) < CF_BUFSIZE)
{
- strcpy(VGIDNAME,value);
+ (void)strlcpy(VGIDNAME,value,CF_MAXVARSIZE);
}
else
{
@@ -631,13 +631,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;
@@ -810,7 +810,7 @@ Debug1("HandleOptionalMountItem(%s)\n",v
switch(GetCommAttribute(item))
{
case cfmountoptions:
- strcpy(MOUNTOPTS, value);
+ (void)strlcpy(MOUNTOPTS, value, CF_BUFSIZE);
break;
case cfreadonly:
@@ -997,7 +997,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");
@@ -1073,9 +1073,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;
@@ -1281,9 +1281,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;
@@ -1323,7 +1323,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;
@@ -1378,11 +1378,11 @@ if (value[0] == '\0')
break;
case cfretclasses:
- strncpy(METHODRETURNCLASSES,value,CF_BUFSIZE-1);
+ strlcpy(METHODRETURNCLASSES,value,sizeof(METHODRETURNCLASSES));
break;
case cfforcereplyto:
- strncpy(METHODFORCE,value,CF_BUFSIZE-1);
+ strlcpy(METHODFORCE,value,sizeof(METHODFORCE));
break;
case cfsendclasses:
@@ -1445,9 +1445,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;
@@ -1513,7 +1513,7 @@ if (!IsAbsoluteFileName(value))
yyerror("chdir is not an absolute directory name");
}
-strcpy(CHDIR,value);
+(void)strlcpy(CHDIR,value,CF_BUFSIZE);
}
/*******************************************************************/
@@ -1526,7 +1526,7 @@ if (!IsAbsoluteFileName(value))
yyerror("chdir is not an absolute directory name");
}
-strcpy(CHROOT,value);
+(void)strlcpy(CHROOT,value,sizeof(CHROOT));
}
/*******************************************************************/
@@ -1537,7 +1537,7 @@ void HandleFileItem(char *item)
if (strcmp(item,"home") == 0)
{
ACTIONPENDING=true;
- strcpy(CURRENTOBJECT,"home");
+ (void)strlcpy(CURRENTOBJECT,"home",CF_BUFSIZE);
return;
}
@@ -1567,19 +1567,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;
}
@@ -1622,12 +1622,12 @@ ExpandVarstring(item,ebuff,NULL);
else
{
memcpy(&inaddr,hp->h_addr, hp->h_length);
- strcpy(VDEFAULTROUTE,inet_ntoa(inaddr));
+ (void)strlcpy(VDEFAULTROUTE,inet_ntoa(inaddr),sizeof(VDEFAULTROUTE));
}
}
else
{
- strcpy(VDEFAULTROUTE,ebuff);
+ (void)strlcpy(VDEFAULTROUTE,ebuff,sizeof(VDEFAULTROUTE));
}
}
@@ -1905,7 +1905,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);
}
@@ -2621,9 +2621,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! */
@@ -2639,8 +2639,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);
}
@@ -2857,7 +2857,7 @@ if (data == NULL)
}
else
{
- Debug1("InstallEditFile(%s,%s,%s) with classes\n",file,edit,data,CLASSBUFF);
+ Debug1("InstallEditFile(%s,%s,%s) with classes %s\n",file,edit,data,CLASSBUFF);
}
if (!IsInstallable(CLASSBUFF))
@@ -3479,11 +3479,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)
@@ -3606,7 +3606,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] != ')')
{
@@ -4800,12 +4800,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;
}
@@ -4821,7 +4821,7 @@ if (strlen(buf1) > 1)
if (!FORCENETCOPY && ((strcmp(buf3,VFQNAME) == 0) || (strcmp(buf3,VUQNAME) == 0) || (strcmp(buf3,VSYSNAME.nodename) == 0)))
{
Debug("Swapping %s for localhost\n",server);
- strcpy(buf3,"localhost");
+ (void)strlcpy(buf3,"localhost",sizeof(buf3));
}
Build2DListFromVarstring(&tp,path,'/'); /* Must split on space in comm string */
@@ -4880,7 +4880,7 @@ for (spl = Get2DListEnt(tp); spl != NULL
if (strlen(destination) == 0)
{
- strcpy(buf2,spl);
+ (void)strlcpy(buf2,spl,sizeof(buf2));
}
else
{
@@ -5211,11 +5211,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
{
@@ -5334,7 +5334,7 @@ void HandleNetmask(char *value)
{
if (strlen(DESTINATION) == 0)
{
- strcpy(DESTINATION,value);
+ (void)strlcpy(DESTINATION,value,CF_BUFSIZE);
}
else
{
@@ -5349,7 +5349,7 @@ void HandleIPAddress(char *value)
{
if (strlen(LINKTO) == 0)
{
- strcpy(LINKTO,value);
+ (void)strlcpy(LINKTO,value,CF_BUFSIZE);
}
else
{
@@ -5370,19 +5370,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;
}
@@ -5395,6 +5395,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);
@@ -5426,8 +5427,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!");
@@ -5436,7 +5439,7 @@ while (*sp != '\0')
if (j == 1)
{
- strcpy(actiontxt,cbuff);
+ (void)strlcpy(actiontxt,cbuff,sizeof(actiontxt));
continue;
}
else if (!IsSpecialClass(cbuff))
@@ -5463,7 +5466,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
@@ -5561,7 +5564,7 @@ void HandleServer(char *value)
{
Debug("Server in copy set to : %s\n",value);
-strcpy(CFSERVER,value);
+(void)strlcpy(CFSERVER,value,CF_MAXVARSIZE);
}
/*******************************************************************/
@@ -5583,7 +5586,7 @@ if (strlen(value) > CF_BUFSIZE)
yyerror(OUTPUT);
}
*/
-strcpy(ALLCLASSBUFFER,value);
+(void)strlcpy(ALLCLASSBUFFER,value,sizeof(ALLCLASSBUFFER));
for (sp = value; *sp != '\0'; sp++)
{
@@ -5613,7 +5616,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++)
{
@@ -5643,7 +5646,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++)
{
@@ -6256,8 +6259,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
{
@@ -6290,6 +6293,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)
{
@@ -6319,10 +6323,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 == '?')
@@ -6348,7 +6356,7 @@ tp->rmdirs =tidydirs;
if (classes != NULL)
{
- strcpy(spe,classes);
+ (void)strlcpy(spe,classes,spelen);
tp->classes = spe;
}
else

View File

@ -0,0 +1,262 @@
$OpenBSD: patch-src_item-ext_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/item-ext.c.orig Sat Apr 17 16:11:02 2004
+++ src/item-ext.c Thu Jun 17 12:54:39 2004
@@ -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,7 +1175,8 @@ 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);
@@ -1175,9 +1183,9 @@ for (ip = CURRENTLINEPTR; ip != NULL; ip
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 */
@@ -1424,6 +1432,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);
@@ -1479,15 +1488,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;
@@ -1517,6 +1527,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);
@@ -1567,7 +1578,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;
@@ -1593,11 +1605,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++;
@@ -1782,7 +1794,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);
}
}
@@ -1793,6 +1805,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))
{
@@ -1801,9 +1814,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

@ -0,0 +1,65 @@
$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

@ -0,0 +1,166 @@
$OpenBSD: patch-src_item_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/item.c.orig Sat Apr 17 16:11:01 2004
+++ src/item.c Thu Jun 17 12:54:40 2004
@@ -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
@@ -303,6 +309,7 @@ void AppendItem (struct Item **liststart
{ struct Item *ip, *lp;
char *sp,*spe = NULL;
+ size_t splen, spelen = 0;
if (!PARSING && (ACTION == editfiles))
{
@@ -320,7 +327,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("");
@@ -339,13 +347,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);
ip->name = sp;
ip->next = NULL;
ip->counter = 0;
@@ -352,7 +364,7 @@ ip->counter = 0;
if (classes != NULL)
{
- strcpy(spe,classes);
+ (void)strlcpy(spe,classes,spelen);
ip->classes = spe;
}
else
@@ -370,6 +382,7 @@ void InstallItem (struct Item **liststar
{ struct Item *ip, *lp;
char *sp,*spe = NULL;
+ size_t splen, spelen = 0;
if (!PARSING && (ACTION == editfiles))
{
@@ -388,7 +401,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("");
@@ -407,13 +421,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)
{
@@ -438,7 +456,7 @@ ip->next = NULL;
if (classes != NULL)
{
- strcpy(spe,classes);
+ (void)strlcpy(spe,classes,spelen);
ip->classes = spe;
}
else
@@ -1061,7 +1079,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);
if ( cmp < 0 )
{
@@ -1116,7 +1134,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

@ -0,0 +1,330 @@
$OpenBSD: patch-src_link_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/link.c.orig Sat Apr 17 16:11:06 2004
+++ src/link.c Thu Jun 17 12:54:40 2004
@@ -61,7 +61,7 @@ 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))
@@ -68,9 +68,9 @@ for (dirp = readdir(dirh); dirp != NULL;
{
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))
@@ -77,7 +77,7 @@ for (dirp = readdir(dirh); dirp != NULL;
{
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,7 +1181,7 @@ while (pop > 0)
if (strlen(destination) == 0)
{
- strcpy(destination,"/");
+ (void)strlcpy(destination,"/",sizeof(destination));
}
else
{
@@ -1188,7 +1188,7 @@ else
AddSlash(destination);
}
-strcat(destination,sp);
+(void)strlcat(destination,sp,sizeof(destination));
Debug("Reconstructed absolute linkname = %s\n",destination);
return destination;
}

View File

@ -0,0 +1,48 @@
$OpenBSD: patch-src_locks_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/locks.c.orig 2004-06-10 10:50:04.000000000 -0400
+++ src/locks.c 2004-06-10 12:17:40.000000000 -0400
@@ -80,7 +80,7 @@ struct LockData
void PreLockState()
{
- strcpy(CFLOCK,"pre-lock-state");
+ (void)strlcpy(CFLOCK,"pre-lock-state",CF_BUFSIZE);
}
/********************************************************************/
@@ -88,7 +88,7 @@ void PreLockState()
void SaveExecLock()
{
- strcpy(SAVELOCK,CFLOCK);
+ (void)strlcpy(SAVELOCK,CFLOCK,CF_BUFSIZE);
}
@@ -97,7 +97,7 @@ void SaveExecLock()
void RestoreExecLock()
{
- strcpy(CFLOCK,SAVELOCK);
+ (void)strlcpy(CFLOCK,SAVELOCK,CF_BUFSIZE);
}
/********************************************************************/
@@ -341,7 +341,7 @@ if (PutLock(CFLAST) == -1)
LockLog(getpid(),"Lock removed normally ",CFLOCK,"");
-strcpy(CFLOCK,"no_active_lock");
+(void)strlcpy(CFLOCK,"no_active_lock",CF_BUFSIZE);
}
@@ -666,7 +666,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

@ -0,0 +1,37 @@
$OpenBSD: patch-src_macro_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/macro.c.orig 2004-04-17 10:11:08.000000000 -0400
+++ src/macro.c 2004-06-10 15:38:36.000000000 -0400
@@ -130,6 +130,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);
@@ -151,13 +152,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);
@@ -271,7 +273,7 @@ if (strstr(name,"."))
if (ptr == NULL)
{
- strcpy(vname,name);
+ (void)strlcpy(vname,name,sizeof(vname));
ptr = ObjectContext(scope);
}

View File

@ -0,0 +1,52 @@
$OpenBSD: patch-src_methods_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/methods.c.orig 2004-05-04 07:22:50.000000000 -0400
+++ src/methods.c 2004-06-10 16:11:06.000000000 -0400
@@ -238,24 +238,24 @@ options[0] = '\0';
if (INFORM)
{
- strcat(options,"-I ");
+ (void)strlcat(options,"-I ",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",WORKDIR,GetMethodFilename(ptr),options);
@@ -693,7 +693,7 @@ while (!feof(fp))
case cfmeth_sendclass:
Debug("Defining class: %s\n",arg);
- strncpy(METHODRETURNCLASSES,arg,CF_BUFSIZE-1);
+ strlcpy(METHODRETURNCLASSES,arg,sizeof(METHODRETURNCLASSES));
break;
case cfmeth_attacharg:
@@ -998,7 +998,7 @@ for (dirp = readdir(dirh); dirp != NULL;
SplitMethodName(dirp->d_name,client,server,name,digeststring,extra);
Verbose("This request came from %s - our reply should be sent there!\n",client);
- strcpy(METHODREPLYTO,client);
+ (void)strlcpy(METHODREPLYTO,client,sizeof(METHODREPLYTO));
if (strcmp(methodname,name) == 0)
{

View File

@ -0,0 +1,124 @@
$OpenBSD: patch-src_misc_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/misc.c.orig Thu Apr 29 23:35:59 2004
+++ src/misc.c Thu Jun 17 12:54:40 2004
@@ -556,10 +556,10 @@ 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;
}
@@ -566,7 +566,7 @@ switch(type)
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;
@@ -911,7 +911,7 @@ 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);
}
}
@@ -918,10 +918,10 @@ char strmajor[CF_MAXVARSIZE];
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);
}
@@ -1040,8 +1040,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);
}
/* red hat 9 is *not* red hat 9.0.
* and same thing with RHEL AS 3
@@ -1048,7 +1048,7 @@ char strminor[CF_MAXVARSIZE];
*/
else if (sscanf(release, "%d", &major) == 1)
{
- sprintf(strmajor, "%d", major);
+ (void)snprintf(strmajor, sizeof(strmajor), "%d", major);
minor = -2;
};
}
@@ -1056,21 +1056,21 @@ 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, "_");
+ (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);
}
}
@@ -1121,19 +1121,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);
}

View File

@ -0,0 +1,21 @@
$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

@ -0,0 +1,30 @@
$OpenBSD: patch-src_modules_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/modules.c.orig 2004-06-10 23:27:12.000000000 -0400
+++ src/modules.c 2004-06-10 23:10:02.000000000 -0400
@@ -69,7 +69,7 @@ else
}
AddSlash(ebuff);
-strcat(ebuff,actiontxt);
+(void)strlcat(ebuff,actiontxt,sizeof(ebuff));
if (stat(ebuff,&statbuf) == -1)
{
@@ -88,7 +88,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))
{
@@ -97,7 +97,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

@ -0,0 +1,31 @@
$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

@ -0,0 +1,117 @@
$OpenBSD: patch-src_nameinfo_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/nameinfo.c.orig Sat May 1 09:40:45 2004
+++ src/nameinfo.c Thu Jun 17 12:54:40 2004
@@ -53,6 +53,7 @@ void GetNameInfo()
time_t tloc;
struct hostent *hp;
struct sockaddr_in cin;
+ size_t buflen;
#ifdef AIX
char real_version[_SYS_NMLN];
#endif
@@ -123,12 +124,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++) /* Truncate fully qualified name */
@@ -184,7 +186,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));
@@ -253,8 +255,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));
@@ -271,7 +273,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++)
{
@@ -376,7 +378,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--)
@@ -387,8 +389,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));
@@ -498,9 +500,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 )
{
@@ -523,8 +525,8 @@ 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)));
@@ -531,14 +533,14 @@ if (gethostname(fqn, sizeof(fqn)) != -1)
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

@ -0,0 +1,17 @@
$OpenBSD: patch-src_package_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/package.c.orig 2004-06-10 23:27:18.000000000 -0400
+++ src/package.c 2004-06-10 23:21:39.000000000 -0400
@@ -339,11 +339,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

@ -0,0 +1,238 @@
$OpenBSD: patch-src_parse_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/parse.c.orig Thu Apr 29 18:30:18 2004
+++ src/parse.c Thu Jun 17 12:54:40 2004
@@ -245,7 +245,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)
{
@@ -271,7 +271,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 */
}
/*******************************************************************/
@@ -287,7 +287,7 @@ Debug1("HandleLVALUE(%s) in action %s\n"
if ((CONTROLVAR = ScanVariable(id)) != nonexistentvar)
{
- strcpy(CURRENTITEM,id);
+ (void)strlcpy(CURRENTITEM,id,CF_BUFSIZE);
return;
}
else
@@ -328,7 +328,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;
@@ -347,7 +347,7 @@ Debug1("HandleBraceObjectID(%s) in actio
switch (ACTION)
{
case acls:
- strcpy(CURRENTOBJECT,id);
+ (void)strlcpy(CURRENTOBJECT,id,CF_BUFSIZE);
InstallACL(id,CLASSBUFF);
break;
@@ -354,7 +354,7 @@ switch (ACTION)
case strategies:
if (strlen(STRATEGYNAME) == 0)
{
- strcpy(STRATEGYNAME,id);
+ (void)strlcpy(STRATEGYNAME,id,CF_BUFSIZE);
InstallStrategy(id,CLASSBUFF);
}
else
@@ -366,7 +366,7 @@ switch (ACTION)
case editfiles:
if (strlen(CURRENTOBJECT) == 0)
{
- strcpy(CURRENTOBJECT,id);
+ (void)strlcpy(CURRENTOBJECT,id,CF_BUFSIZE);
EDITGROUPLEVEL = 0;
FOREACHLEVEL = 0;
SEARCHREPLACELEVEL = 0;
@@ -380,7 +380,7 @@ switch (ACTION)
case filters:
if (strlen(FILTERNAME)==0)
{
- strcpy(FILTERNAME,id);
+ (void)strlcpy(FILTERNAME,id,CF_BUFSIZE);
InstallFilter(id);
}
else
@@ -406,7 +406,7 @@ switch (ACTION)
case filters:
case strategies:
- strcpy(CURRENTITEM,id);
+ (void)strlcpy(CURRENTITEM,id,CF_BUFSIZE);
break;
case editfiles:
@@ -420,7 +420,7 @@ switch (ACTION)
HandleEdit(CURRENTOBJECT,id,NULL);
}
- strcpy(CURRENTITEM,id);
+ (void)strlcpy(CURRENTITEM,id,CF_BUFSIZE);
break;
}
}
@@ -456,7 +456,7 @@ else
Debug1("Simple class = (%s)\n",id);
}
-strcpy(CLASSBUFF,id);
+(void)strlcpy(CLASSBUFF,id,CF_BUFSIZE);
}
/*******************************************************************/
@@ -473,13 +473,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;
@@ -493,7 +493,7 @@ switch (ACTION)
{
yyerror("Processes syntax error");
}
- strcpy(RESTART,qstring);
+ (void)strlcpy(RESTART,qstring,CF_BUFSIZE);
ACTIONPENDING = true;
InstallPending(ACTION);
@@ -517,7 +517,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)
@@ -612,7 +612,7 @@ if (ACTION == methods)
if (IsBuiltinFunction(fn))
{
local[0] = '\0';
- strcpy(local,EvaluateFunction(fn,local));
+ (void)strlcpy(local,EvaluateFunction(fn,local),sizeof(local));
switch (ACTION)
{
@@ -819,8 +819,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)
{
@@ -865,7 +865,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
{
@@ -1005,7 +1005,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);
@@ -1086,7 +1086,7 @@ void RecordMacroId(char *name)
{
Debug("RecordMacroId(%s)\n",name);
-strcpy(CURRENTITEM,name);
+(void)strlcpy(CURRENTITEM,name,CF_BUFSIZE);
if (strcmp(name,"this") == 0)
{
@@ -1116,7 +1116,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))
{
@@ -1131,13 +1131,13 @@ if ((sp=getenv(CF_INPUTSVAR)) != NULL)
{
if (!IsAbsoluteFileName(filename)) /* Don't prepend to absolute names */
{
- strcpy(result,WORKDIR);
+ (void)strlcpy(result,WORKDIR,CF_BUFSIZE);
AddSlash(result);
- strcat(result,"inputs/");
+ (void)strlcat(result,"inputs/",CF_BUFSIZE);
}
}
-strcat(result,filename);
+(void)strlcat(result,filename,CF_BUFSIZE);
return result;
}
@@ -1161,8 +1161,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;
@@ -1184,7 +1184,7 @@ void InitializeAction()
METHODREPLYTO[0] = '\0';
METHODFORCE[0] = '\0';
CHROOT[0] = '\0';
- strcpy(VIFNAME,"");
+ (void)strlcpy(VIFNAME,"",sizeof(VIFNAME));
PTRAVLINKS = (short) '?';
IMAGEBACKUP = 'y';
ENCRYPT = 'n';
@@ -1226,7 +1226,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

@ -0,0 +1,72 @@
$OpenBSD: patch-src_patches_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/patches.c.orig 2004-06-10 10:50:04.000000000 -0400
+++ src/patches.c 2004-06-10 11:32:49.000000000 -0400
@@ -134,7 +134,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)
{
@@ -142,10 +142,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 */
@@ -154,8 +154,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;
}
@@ -204,6 +204,7 @@ return NULL;
#ifndef HAVE_STRDUP
char *strdup(char *str)
+size_t buflen;
{ char *sp;
@@ -212,13 +213,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;
}
@@ -270,7 +272,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

@ -0,0 +1,21 @@
$OpenBSD: patch-src_popen_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/popen.c.orig 2004-06-15 10:48:40.000000000 +0200
+++ src/popen.c 2004-06-15 10:49:04.000000000 +0200
@@ -410,7 +410,7 @@ FILE *cfpopen_sh(char *command,char *typ
}
}
- execl("/bin/sh","sh","-c",command,NULL);
+ execl("/bin/sh","sh","-c",command,(void *)NULL);
_exit(1);
}
else
@@ -559,7 +559,7 @@ FILE *cfpopen_shsetuid(char *command,cha
}
}
- execl("/bin/sh","sh","-c",command,NULL);
+ execl("/bin/sh","sh","-c",command,(void *)NULL);
_exit(1);
}
else

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-src_process_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/process.c.orig 2004-06-10 23:27:24.000000000 -0400
+++ src/process.c 2004-06-10 23:22:19.000000000 -0400
@@ -400,7 +400,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

@ -0,0 +1,32 @@
$OpenBSD: patch-src_proto_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/proto.c.orig Sat Apr 17 16:11:10 2004
+++ src/proto.c Thu Jun 17 12:54:40 2004
@@ -131,8 +131,8 @@ if (strcmp(VDOMAIN,CF_START_DOMAIN) == 0
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
@@ -144,7 +144,7 @@ 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);
}
@@ -151,7 +151,7 @@ if ((strlen(VDOMAIN) > 0) && !IsIPV6Addr
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));
}
snprintf(sendbuff,CF_BUFSIZE-1,"CAUTH %s %s %s %d",localip,dnsname,uname,CFSIGNATURE);

View File

@ -0,0 +1,14 @@
$OpenBSD: patch-src_prototypes_h,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/prototypes.h.orig 2004-06-10 16:17:24.000000000 -0400
+++ src/prototypes.h 2004-06-10 16:17:35.000000000 -0400
@@ -198,8 +198,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

@ -0,0 +1,21 @@
$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

@ -0,0 +1,31 @@
$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

@ -0,0 +1,12 @@
$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

@ -0,0 +1,59 @@
$OpenBSD: patch-src_tidy_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/tidy.c.orig 2004-04-17 10:11:07.000000000 -0400
+++ src/tidy.c 2004-06-10 23:51:23.000000000 -0400
@@ -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)
{
@@ -399,7 +399,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))
@@ -407,7 +407,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) /* Check for links first */
{

View File

@ -0,0 +1,372 @@
$OpenBSD: patch-src_varstring_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/varstring.c.orig Tue Apr 20 07:49:29 2004
+++ src/varstring.c Thu Jun 17 12:54:41 2004
@@ -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++;
@@ -403,7 +403,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,VERSION);
+ (void)strlcat(buffer,VERSION,CF_EXPANDSIZE);
break;
case cffaculty:
@@ -417,7 +417,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,VFACULTY);
+ (void)strlcat(buffer,VFACULTY,CF_EXPANDSIZE);
break;
@@ -428,7 +428,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,VDEFAULTBINSERVER.name);
+ (void)strlcat(buffer,VDEFAULTBINSERVER.name,CF_EXPANDSIZE);
}
else
{
@@ -436,7 +436,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,VUQNAME);
+ (void)strlcat(buffer,VUQNAME,CF_EXPANDSIZE);
}
break;
@@ -445,7 +445,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,VFQNAME);
+ (void)strlcat(buffer,VFQNAME,CF_EXPANDSIZE);
break;
case cfnetmask:
@@ -453,7 +453,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,VNETMASK);
+ (void)strlcat(buffer,VNETMASK,CF_EXPANDSIZE);
break;
@@ -462,7 +462,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,VIPADDRESS);
+ (void)strlcat(buffer,VIPADDRESS,CF_EXPANDSIZE);
break;
case cfbinserver:
@@ -476,7 +476,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,"$(binserver)");
+ (void)strlcat(buffer,"$(binserver)",CF_EXPANDSIZE);
break;
case cfsysadm:
@@ -489,7 +489,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,VSYSADM);
+ (void)strlcat(buffer,VSYSADM,CF_EXPANDSIZE);
break;
case cfdomain:
@@ -502,7 +502,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:
@@ -510,7 +510,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,VNFSTYPE);
+ (void)strlcat(buffer,VNFSTYPE,CF_EXPANDSIZE);
break;
case cftimezone:
@@ -523,7 +523,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:
@@ -531,7 +531,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:
@@ -539,7 +539,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,VARCH);
+ (void)strlcat(buffer,VARCH,CF_EXPANDSIZE);
break;
case cfarch2:
@@ -547,7 +547,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,VARCH2);
+ (void)strlcat(buffer,VARCH2,CF_EXPANDSIZE);
break;
@@ -565,7 +565,7 @@ for (sp = string; /* No exit */ ; sp++)
}
else
{
- strcat(buffer,Space2Score(ctime(&tloc)));
+ (void)strlcat(buffer,Space2Score(ctime(&tloc)),CF_EXPANDSIZE);
Chop(buffer);
}
@@ -578,7 +578,7 @@ for (sp = string; /* No exit */ ; sp++)
}
else
{
- strcat(buffer,VYEAR);
+ (void)strlcat(buffer,VYEAR,CF_EXPANDSIZE);
}
break;
@@ -589,7 +589,7 @@ for (sp = string; /* No exit */ ; sp++)
}
else
{
- strcat(buffer,VMONTH);
+ (void)strlcat(buffer,VMONTH,CF_EXPANDSIZE);
}
break;
@@ -600,7 +600,7 @@ for (sp = string; /* No exit */ ; sp++)
}
else
{
- strcat(buffer,VDAY);
+ (void)strlcat(buffer,VDAY,CF_EXPANDSIZE);
}
break;
case cfhr:
@@ -610,7 +610,7 @@ for (sp = string; /* No exit */ ; sp++)
}
else
{
- strcat(buffer,VHR);
+ (void)strlcat(buffer,VHR,CF_EXPANDSIZE);
}
break;
@@ -621,7 +621,7 @@ for (sp = string; /* No exit */ ; sp++)
}
else
{
- strcat(buffer,VMINUTE);
+ (void)strlcat(buffer,VMINUTE,CF_EXPANDSIZE);
}
break;
@@ -629,7 +629,7 @@ 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))
@@ -636,7 +636,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,ALLCLASSBUFFER);
+ (void)strlcat(buffer,ALLCLASSBUFFER,CF_EXPANDSIZE);
break;
case cfspc:
@@ -644,7 +644,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer," ");
+ (void)strlcat(buffer," ",CF_EXPANDSIZE);
break;
case cftab:
@@ -652,7 +652,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,"\t");
+ (void)strlcat(buffer,"\t",CF_EXPANDSIZE);
break;
case cflf:
@@ -660,7 +660,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,"\012");
+ (void)strlcat(buffer,"\012",CF_EXPANDSIZE);
break;
case cfcr:
@@ -668,7 +668,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,"\015");
+ (void)strlcat(buffer,"\015",CF_EXPANDSIZE);
break;
case cfn:
@@ -676,7 +676,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,"\n");
+ (void)strlcat(buffer,"\n",CF_EXPANDSIZE);
break;
case cfdblquote:
@@ -684,7 +684,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,"\"");
+ (void)strlcat(buffer,"\"",CF_EXPANDSIZE);
break;
case cfquote:
if (ExpandOverflow(buffer," "))
@@ -691,7 +691,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,"\'");
+ (void)strlcat(buffer,"\'",CF_EXPANDSIZE);
break;
case cfdollar:
@@ -702,7 +702,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,"$");
+ (void)strlcat(buffer,"$",CF_EXPANDSIZE);
}
else
{
@@ -710,7 +710,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,"$(dollar)");
+ (void)strlcat(buffer,"$(dollar)",CF_EXPANDSIZE);
}
break;
@@ -743,7 +743,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expandvarstring");
}
- strcat(buffer,env);
+ (void)strlcat(buffer,env,CF_EXPANDSIZE);
break;
}
@@ -757,7 +757,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);
@@ -791,7 +791,7 @@ for (sp = string; /* No exit */ ; sp++)
sscanf(sp,"%[^$]",currentitem);
- strcat(buffer,currentitem);
+ (void)strlcat(buffer,currentitem,CF_EXPANDSIZE);
sp += strlen(currentitem);
if (*sp == '$')
@@ -805,7 +805,7 @@ for (sp = string; /* No exit */ ; sp++)
varstring = '}';
break;
default:
- strcat(buffer,"$");
+ (void)strlcat(buffer,"$",CF_EXPANDSIZE);
continue;
}
sp++;
@@ -819,7 +819,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))
@@ -829,7 +829,7 @@ for (sp = string; /* No exit */ ; sp++)
{
FatalError("Can't expand varstring");
}
- strcat(buffer,bserver);
+ (void)strlcat(buffer,bserver,CF_EXPANDSIZE);
break;
}
@@ -890,7 +890,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

@ -0,0 +1,12 @@
$OpenBSD: patch-src_wrapper_c,v 1.1 2004/06/17 11:21:43 sturm Exp $
--- src/wrapper.c.orig 2004-06-10 23:27:34.000000000 -0400
+++ src/wrapper.c 2004-06-10 23:10:23.000000000 -0400
@@ -305,7 +305,7 @@ ptr=(struct File *)vp;
ExpandVarstring(dir,directory,"");
AddSlash(directory);
-strcat(directory,".");
+(void)strlcat(directory,".",sizeof(directory));
MakeDirectoriesFor(directory,'n');

View File

@ -0,0 +1,22 @@
#!/bin/sh
# $OpenBSD: DEINSTALL,v 1.1 2004/06/17 11:21:43 sturm Exp $
PATH=/bin:/usr/bin:/sbin:/usr/sbin
PREFIX=${PKG_PREFIX:-/usr/local}
CONFIG_DIR=/var/cfengine
if [ "$PKG_DELETE_EXTRA" != Yes -a -d $CONFIG_DIR ]; then
echo
echo "+------------"
echo "| To completely deinstall the $1 package you need to perform"
echo "| this step as root:"
echo "|"
echo "| rm -rf $CONFIG_DIR"
echo "|"
echo "| Do not do this if you plan on re-installing $1"
echo "| at some future."
echo "+------------"
echo
fi
exit 0

View File

@ -0,0 +1,5 @@
Cfengine, or the configuration engine, is an autonomous agent and a middle to
high level policy language for building expert systems which administrate and
configure large computer networks. Cfengine uses the idea of classes and a
primitive intelligence to define and automate the configuration and
maintenance of system state, for small to huge configurations.

View File

@ -0,0 +1,64 @@
@comment $OpenBSD: PLIST,v 1.4 2004/06/17 11:21:43 sturm Exp $
@unexec install-info --delete --info-dir=%D/info %D/info/cfengine-Anomalies.info
@unexec install-info --delete --info-dir=%D/info %D/info/cfengine-Reference.info
@unexec install-info --delete --info-dir=%D/info %D/info/cfengine-Tutorial.info
info/cfengine-Anomalies.info
info/cfengine-Reference.info
info/cfengine-Reference.info-1
info/cfengine-Reference.info-2
info/cfengine-Reference.info-3
info/cfengine-Reference.info-4
info/cfengine-Reference.info-5
info/cfengine-Reference.info-6
info/cfengine-Reference.info-7
info/cfengine-Reference.info-8
info/cfengine-Tutorial.info
info/cfengine-Tutorial.info-1
info/cfengine-Tutorial.info-2
info/cfengine-Tutorial.info-3
info/cfengine-Tutorial.info-4
info/cfengine-Tutorial.info-5
info/cfengine-Tutorial.info-6
man/man8/cfagent.8
man/man8/cfengine.8
man/man8/cfenvd.8
man/man8/cfenvgraph.8
man/man8/cfexecd.8
man/man8/cfkey.8
man/man8/cfrun.8
man/man8/cfservd.8
sbin/cfagent
sbin/cfdoc
sbin/cfenvd
sbin/cfenvgraph
sbin/cfexecd
sbin/cfkey
sbin/cfrun
sbin/cfservd
sbin/vicf
share/cfengine/cfengine.el
share/examples/cfengine/cf.chflags.example
share/examples/cfengine/cf.freebsd.example
share/examples/cfengine/cf.ftp.example
share/examples/cfengine/cf.groups.example
share/examples/cfengine/cf.linux.example
share/examples/cfengine/cf.main.example
share/examples/cfengine/cf.motd.example
share/examples/cfengine/cf.preconf.example
share/examples/cfengine/cf.services.example
share/examples/cfengine/cf.site.example
share/examples/cfengine/cf.solaris.example
share/examples/cfengine/cf.sun4.example
share/examples/cfengine/cf.users.example
share/examples/cfengine/cfagent.conf-advanced.example
share/examples/cfengine/cfagent.conf.example
share/examples/cfengine/cfrc.example
share/examples/cfengine/cfrun.hosts.example
share/examples/cfengine/cfservd.conf.example
share/examples/cfengine/update.conf.example
@dirrm share/examples/cfengine
@dirrm share/cfengine
@exec install-info --info-dir=%D/info %D/info/cfengine-Anomalies.info
@exec install-info --info-dir=%D/info %D/info/cfengine-Reference.info
@exec install-info --info-dir=%D/info %D/info/cfengine-Tutorial.info
@extraunexec rm -fr /var/cfengine