118 lines
4.0 KiB
Plaintext
118 lines
4.0 KiB
Plaintext
|
$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));
|