summaryrefslogtreecommitdiff
path: root/mail/gld/patches/patch-ae
blob: 2ccec646d2711d13db984baf28d6ca7caab42599 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
$NetBSD: patch-ae,v 1.2 2006/03/02 21:03:39 wiz Exp $

--- sockets.c.orig	2004-10-12 14:39:34.000000000 +0200
+++ sockets.c
@@ -540,7 +540,7 @@ int CloseSocket(int s)
 /*                                              */
 /************************************************/
 
-int DnsIp(char *host,char *ip)
+int DnsIp(char *host,char *ip, size_t len)
 {
 struct hostent *hostptr;
 struct in_addr *ptr;
@@ -552,7 +552,11 @@ if(hostptr->h_addrtype != AF_INET) retur
 
 ptr=(struct in_addr *) *hostptr->h_addr_list;
 
-if(ip!=NULL) strcpy(ip,(char *)inet_ntoa(*ptr));
+if(ip!=NULL)
+	{
+	strncpy(ip,(char *)inet_ntoa(*ptr), len - 1);
+	ip[len-1] = '\0';
+	}
 return(0);
 }
 
@@ -572,13 +576,14 @@ return(0);
 /*                                              */
 /************************************************/
 
-int DnsFQDN(char *host,char *fqdn)
+int DnsFQDN(char *host,char *fqdn, size_t len)
 {
 struct hostent *hostptr;
 
 if((hostptr=(struct hostent *)gethostbyname(host))==NULL) return(S_HOST_ERR);
 
-strcpy(fqdn,hostptr->h_name);
+strncpy(fqdn,hostptr->h_name, len-1);
+fqdn[len-1] = '\0';
 return(0);
 
 }
@@ -599,7 +604,7 @@ return(0);
 /*                                              */
 /************************************************/
 
-int DnsName(char *ip,char *fqdn)
+int DnsName(char *ip,char *fqdn, size_t len)
 {
 
 struct hostent *hostptr;
@@ -609,7 +614,8 @@ addr.s_addr=inet_addr(ip);
 
 if((hostptr=(struct hostent *)gethostbyaddr((char *)&addr,sizeof(struct in_addr),AF_INET))==NULL) return(S_HOST_ERR);
 
-strcpy(fqdn,hostptr->h_name);
+strncpy(fqdn,hostptr->h_name, len-1);
+fqdn[len-1] = '\0';
 
 return(0);
 }
@@ -631,20 +637,27 @@ return(0);
 /*                                              */
 /************************************************/
 
-void GetPeerIp(int sock,char *ipfrom,char *hostfrom)
+void GetPeerIp(int sock,char *ipfrom, size_t lip, char *hostfrom, size_t hip)
 {
 struct sockaddr_in from;
 size_t foo=sizeof(struct sockaddr_in);
 struct hostent *hostptr;
 
-strcpy(ipfrom,"???.???.???.???");
-strcpy(hostfrom,"?????");
+strncpy(ipfrom,"???.???.???.???", lip-1);
+ipfrom[lip-1] = '\0';
+strncpy(hostfrom,"?????", hip-1);
+hostfrom[hip-1] = '\0';
 
 if (getpeername(sock,(struct sockaddr *)&from, &foo) == 0)
      {
-     strcpy(ipfrom,(char *)inet_ntoa(from.sin_addr));
+     strncpy(ipfrom,(char *)inet_ntoa(from.sin_addr), lip-1);
+    ipfrom[lip-1] = '\0';
      hostptr=(struct hostent *)gethostbyaddr((char *)&from.sin_addr,sizeof(struct in_addr),AF_INET);
-     if(hostptr!=NULL) strcpy(hostfrom,hostptr->h_name);
+     if(hostptr!=NULL)
+		{
+		strncpy(hostfrom,hostptr->h_name, hip-1);
+		hostfrom[hip-1] = '\0';
+		}
      }
 }