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

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

197 lines
6.8 KiB
Plaintext

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