2006-03-02 22:03:39 +01:00
|
|
|
$NetBSD: patch-ae,v 1.2 2006/03/02 21:03:39 wiz Exp $
|
2005-04-13 18:36:07 +02:00
|
|
|
|
2006-03-02 22:03:39 +01:00
|
|
|
--- sockets.c.orig 2004-10-12 14:39:34.000000000 +0200
|
|
|
|
+++ sockets.c
|
|
|
|
@@ -540,7 +540,7 @@ int CloseSocket(int s)
|
2005-04-13 18:36:07 +02:00
|
|
|
/* */
|
|
|
|
/************************************************/
|
|
|
|
|
|
|
|
-int DnsIp(char *host,char *ip)
|
|
|
|
+int DnsIp(char *host,char *ip, size_t len)
|
|
|
|
{
|
|
|
|
struct hostent *hostptr;
|
|
|
|
struct in_addr *ptr;
|
2006-03-02 22:03:39 +01:00
|
|
|
@@ -552,7 +552,11 @@ if(hostptr->h_addrtype != AF_INET) retur
|
2005-04-13 18:36:07 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2006-03-02 22:03:39 +01:00
|
|
|
@@ -572,13 +576,14 @@ return(0);
|
2005-04-13 18:36:07 +02:00
|
|
|
/* */
|
|
|
|
/************************************************/
|
|
|
|
|
|
|
|
-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);
|
|
|
|
|
|
|
|
}
|
2006-03-02 22:03:39 +01:00
|
|
|
@@ -599,7 +604,7 @@ return(0);
|
2005-04-13 18:36:07 +02:00
|
|
|
/* */
|
|
|
|
/************************************************/
|
|
|
|
|
|
|
|
-int DnsName(char *ip,char *fqdn)
|
|
|
|
+int DnsName(char *ip,char *fqdn, size_t len)
|
|
|
|
{
|
|
|
|
|
|
|
|
struct hostent *hostptr;
|
2006-03-02 22:03:39 +01:00
|
|
|
@@ -609,7 +614,8 @@ addr.s_addr=inet_addr(ip);
|
2005-04-13 18:36:07 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2006-03-02 22:03:39 +01:00
|
|
|
@@ -631,20 +637,27 @@ return(0);
|
2005-04-13 18:36:07 +02:00
|
|
|
/* */
|
|
|
|
/************************************************/
|
|
|
|
|
|
|
|
-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';
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|