summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2006-05-12 15:37:23 +0000
committerume <ume@FreeBSD.org>2006-05-12 15:37:23 +0000
commitab3eacdf3106cb0b4027a6d928d9555815af0b48 (patch)
tree164cb97bf2cd0fc04b8135b782152c0960ca3354 /lib
parent08978d5bee9bfc81ae25a6b3a8971577532cc9aa (diff)
downloadFreeBSD-src-ab3eacdf3106cb0b4027a6d928d9555815af0b48.zip
FreeBSD-src-ab3eacdf3106cb0b4027a6d928d9555815af0b48.tar.gz
Fix gethostbyaddr() prototype to conform to IEEE Std 1003.1:
http://www.opengroup.org/onlinepubs/009695399/functions/gethostbyaddr.html gethostbyaddr_r() is changed as well. It breaks ABI backward compatibility on 64 bit arch. So, we fix it on 32 bit arch only for now. Reported by: Rostislav Krasny <rosti.bsd@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/net/gethostbydns.c11
-rw-r--r--lib/libc/net/gethostbyht.c9
-rw-r--r--lib/libc/net/gethostbyname.34
-rw-r--r--lib/libc/net/gethostbynis.c14
-rw-r--r--lib/libc/net/gethostnamadr.c18
-rw-r--r--lib/libc/net/netdb_private.h2
6 files changed, 36 insertions, 22 deletions
diff --git a/lib/libc/net/gethostbydns.c b/lib/libc/net/gethostbydns.c
index 8558513..b19dc79 100644
--- a/lib/libc/net/gethostbydns.c
+++ b/lib/libc/net/gethostbydns.c
@@ -550,11 +550,13 @@ _dns_gethostbyname(void *rval, void *cb_data, va_list ap)
int
_dns_gethostbyaddr(void *rval, void *cb_data, va_list ap)
{
- const u_char *uaddr;
- int len, af;
+ const void *addr;
+ socklen_t len;
+ int af;
char *buffer;
size_t buflen;
int *errnop, *h_errnop;
+ const u_char *uaddr;
struct hostent *hptr, he;
struct hostent_data *hed;
int n;
@@ -570,14 +572,15 @@ _dns_gethostbyaddr(void *rval, void *cb_data, va_list ap)
int ret_h_error;
#endif /*SUNSECURITY*/
- uaddr = va_arg(ap, const u_char *);
- len = va_arg(ap, int);
+ addr = va_arg(ap, const void *);
+ len = va_arg(ap, socklen_t);
af = va_arg(ap, int);
hptr = va_arg(ap, struct hostent *);
buffer = va_arg(ap, char *);
buflen = va_arg(ap, size_t);
errnop = va_arg(ap, int *);
h_errnop = va_arg(ap, int *);
+ uaddr = (const u_char *)addr;
*((struct hostent **)rval) = NULL;
diff --git a/lib/libc/net/gethostbyht.c b/lib/libc/net/gethostbyht.c
index 0782518..cb5009d 100644
--- a/lib/libc/net/gethostbyht.c
+++ b/lib/libc/net/gethostbyht.c
@@ -282,8 +282,9 @@ found:
int
_ht_gethostbyaddr(void *rval, void *cb_data, va_list ap)
{
- const char *addr;
- int len, af;
+ const void *addr;
+ socklen_t len;
+ int af;
char *buffer;
size_t buflen;
int *errnop, *h_errnop;
@@ -292,8 +293,8 @@ _ht_gethostbyaddr(void *rval, void *cb_data, va_list ap)
res_state statp;
int error;
- addr = va_arg(ap, const char *);
- len = va_arg(ap, int);
+ addr = va_arg(ap, const void *);
+ len = va_arg(ap, socklen_t);
af = va_arg(ap, int);
hptr = va_arg(ap, struct hostent *);
buffer = va_arg(ap, char *);
diff --git a/lib/libc/net/gethostbyname.3 b/lib/libc/net/gethostbyname.3
index 6f9ee0d..7c83d02 100644
--- a/lib/libc/net/gethostbyname.3
+++ b/lib/libc/net/gethostbyname.3
@@ -55,7 +55,7 @@
.Ft struct hostent *
.Fn gethostbyname2 "const char *name" "int af"
.Ft struct hostent *
-.Fn gethostbyaddr "const char *addr" "int len" "int type"
+.Fn gethostbyaddr "const void *addr" "socklen_t len" "int type"
.Ft struct hostent *
.Fn gethostent void
.Ft void
@@ -246,7 +246,7 @@ struct hostent *hp;
if (!inet_aton(ipstr, &ip))
errx(1, "can't parse IP address %s", ipstr);
-if ((hp = gethostbyaddr((const char *)&ip,
+if ((hp = gethostbyaddr((const void *)&ip,
sizeof ip, AF_INET)) == NULL)
errx(1, "no name associated with %s", ipstr);
diff --git a/lib/libc/net/gethostbynis.c b/lib/libc/net/gethostbynis.c
index 5ce6097..7921ced 100644
--- a/lib/libc/net/gethostbynis.c
+++ b/lib/libc/net/gethostbynis.c
@@ -178,8 +178,8 @@ _gethostbynisname_r(const char *name, int af, struct hostent *he,
}
static int
-_gethostbynisaddr_r(const char *addr, int len, int af, struct hostent *he,
- struct hostent_data *hed)
+_gethostbynisaddr_r(const void *addr, socklen_t len, int af,
+ struct hostent *he, struct hostent_data *hed)
{
char *map;
char numaddr[46];
@@ -227,7 +227,7 @@ _gethostbynisname(const char *name, int af)
}
struct hostent *
-_gethostbynisaddr(const char *addr, int len, int af)
+_gethostbynisaddr(const void *addr, socklen_t len, int af)
{
#ifdef YP
struct hostent *he;
@@ -303,8 +303,8 @@ int
_nis_gethostbyaddr(void *rval, void *cb_data, va_list ap)
{
#ifdef YP
- const char *addr;
- int len;
+ const void *addr;
+ socklen_t len;
int af;
char *buffer;
size_t buflen;
@@ -313,8 +313,8 @@ _nis_gethostbyaddr(void *rval, void *cb_data, va_list ap)
struct hostent_data *hed;
res_state statp;
- addr = va_arg(ap, const char *);
- len = va_arg(ap, int);
+ addr = va_arg(ap, const void *);
+ len = va_arg(ap, socklen_t);
af = va_arg(ap, int);
hptr = va_arg(ap, struct hostent *);
buffer = va_arg(ap, char *);
diff --git a/lib/libc/net/gethostnamadr.c b/lib/libc/net/gethostnamadr.c
index 965af66..7ff3500 100644
--- a/lib/libc/net/gethostnamadr.c
+++ b/lib/libc/net/gethostnamadr.c
@@ -573,8 +573,14 @@ gethostbyname_internal(const char *name, int af, struct hostent *hp, char *buf,
}
int
-gethostbyaddr_r(const char *addr, int len, int af, struct hostent *hp,
- char *buf, size_t buflen, struct hostent **result, int *h_errnop)
+gethostbyaddr_r(const void *addr,
+#if __LONG_BIT == 64
+ int len,
+#else
+ socklen_t len,
+#endif
+ int af, struct hostent *hp, char *buf, size_t buflen,
+ struct hostent **result, int *h_errnop)
{
const u_char *uaddr = (const u_char *)addr;
const struct in6_addr *addr6;
@@ -606,7 +612,7 @@ gethostbyaddr_r(const char *addr, int len, int af, struct hostent *hp,
}
if (af == AF_INET6 && len == NS_IN6ADDRSZ) {
- addr6 = (const struct in6_addr *)(const void *)uaddr;
+ addr6 = (const struct in6_addr *)addr;
if (IN6_IS_ADDR_LINKLOCAL(addr6)) {
RES_SET_H_ERRNO(statp, HOST_NOT_FOUND);
*h_errnop = statp->res_h_errno;
@@ -678,7 +684,11 @@ gethostbyname2(const char *name, int af)
}
struct hostent *
-gethostbyaddr(const char *addr, int len, int af)
+#if __LONG_BIT == 64
+gethostbyaddr(const void *addr, int len, int af)
+#else
+gethostbyaddr(const void *addr, socklen_t len, int af)
+#endif
{
struct hostdata *hd;
struct hostent *rval;
diff --git a/lib/libc/net/netdb_private.h b/lib/libc/net/netdb_private.h
index e5535f6..b48dd7b 100644
--- a/lib/libc/net/netdb_private.h
+++ b/lib/libc/net/netdb_private.h
@@ -133,7 +133,7 @@ void _endhostdnsent(void);
void _endhosthtent(struct hostent_data *);
void _endnetdnsent(void);
void _endnethtent(struct netent_data *);
-struct hostent *_gethostbynisaddr(const char *, int, int);
+struct hostent *_gethostbynisaddr(const void *, socklen_t, int);
struct hostent *_gethostbynisname(const char *, int);
void _map_v4v6_address(const char *, char *);
void _map_v4v6_hostent(struct hostent *, char **, char *);
OpenPOWER on IntegriCloud