summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2006-05-21 11:27:28 +0000
committerume <ume@FreeBSD.org>2006-05-21 11:27:28 +0000
commitdce008dac9e1172bb4b955ae91cf29b2e8429dd2 (patch)
tree233d98c434bf29bc5dcbe3cc56c393049660ce60
parentc49929798600cc98625b30e672dfe77235791a07 (diff)
downloadFreeBSD-src-dce008dac9e1172bb4b955ae91cf29b2e8429dd2.zip
FreeBSD-src-dce008dac9e1172bb4b955ae91cf29b2e8429dd2.tar.gz
Fix gethostbyaddr() prototype to conform to IEEE Std 1003.1 on 64 bit
arch. X-MFC after: never
-rw-r--r--include/netdb.h7
-rw-r--r--lib/libc/net/gethostnamadr.c47
2 files changed, 22 insertions, 32 deletions
diff --git a/include/netdb.h b/include/netdb.h
index 33a5051..cd7fc74 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -63,7 +63,6 @@
#include <sys/cdefs.h>
#include <sys/_types.h>
-#include <machine/_limits.h>
#ifndef _SIZE_T_DECLARED
typedef __size_t size_t;
@@ -222,15 +221,9 @@ void endnetgrent(void);
void endprotoent(void);
void endservent(void);
void freehostent(struct hostent *);
-#if __LONG_BIT == 64
-struct hostent *gethostbyaddr(const void *, int, int);
-int gethostbyaddr_r(const void *, int, int, struct hostent *,
- char *, size_t, struct hostent **, int *);
-#else
struct hostent *gethostbyaddr(const void *, socklen_t, int);
int gethostbyaddr_r(const void *, socklen_t, int, struct hostent *,
char *, size_t, struct hostent **, int *);
-#endif
struct hostent *gethostbyname(const char *);
int gethostbyname_r(const char *, struct hostent *, char *, size_t,
struct hostent **, int *);
diff --git a/lib/libc/net/gethostnamadr.c b/lib/libc/net/gethostnamadr.c
index 7ff3500..ffad6f2 100644
--- a/lib/libc/net/gethostnamadr.c
+++ b/lib/libc/net/gethostnamadr.c
@@ -169,7 +169,9 @@ host_id_func(char *buffer, size_t *buffer_size, va_list ap, void *cache_mdata)
const int op_id = 1;
char *str;
- int len, type;
+ void *addr;
+ socklen_t len;
+ int type;
size_t desired_size, size;
enum nss_lookup_type lookup_type;
@@ -214,12 +216,13 @@ host_id_func(char *buffer, size_t *buffer_size, va_list ap, void *cache_mdata)
res = NS_SUCCESS;
break;
case nss_lt_id:
- str = va_arg(ap, char *);
- len = va_arg(ap, int);
+ addr = va_arg(ap, void *);
+ len = va_arg(ap, socklen_t);
type = va_arg(ap, int);
desired_size = sizeof(res_options) + sizeof(int) +
- sizeof(enum nss_lookup_type) + sizeof(int) * 2 + len;
+ sizeof(enum nss_lookup_type) + sizeof(int) +
+ sizeof(socklen_t) + len;
if (desired_size > *buffer_size) {
res = NS_RETURN;
@@ -239,10 +242,10 @@ host_id_func(char *buffer, size_t *buffer_size, va_list ap, void *cache_mdata)
memcpy(p, &type, sizeof(int));
p += sizeof(int);
- memcpy(p, &len, sizeof(int));
- p += sizeof(int);
+ memcpy(p, &len, sizeof(socklen_t));
+ p += sizeof(socklen_t);
- memcpy(p, str, len);
+ memcpy(p, addr, len);
res = NS_SUCCESS;
break;
@@ -261,7 +264,9 @@ host_marshal_func(char *buffer, size_t *buffer_size, void *retval, va_list ap,
void *cache_mdata)
{
char *str;
- int len, type;
+ void *addr;
+ socklen_t len;
+ int type;
struct hostent *ht;
struct hostent new_ht;
@@ -274,8 +279,8 @@ host_marshal_func(char *buffer, size_t *buffer_size, void *retval, va_list ap,
type = va_arg(ap, int);
break;
case nss_lt_id:
- str = va_arg(ap, char *);
- len = va_arg(ap, int);
+ addr = va_arg(ap, void *);
+ len = va_arg(ap, socklen_t);
type = va_arg(ap, int);
break;
default:
@@ -365,7 +370,9 @@ host_unmarshal_func(char *buffer, size_t buffer_size, void *retval, va_list ap,
void *cache_mdata)
{
char *str;
- int len, type;
+ void *addr;
+ socklen_t len;
+ int type;
struct hostent *ht;
char *p;
@@ -379,8 +386,8 @@ host_unmarshal_func(char *buffer, size_t buffer_size, void *retval, va_list ap,
type = va_arg(ap, int);
break;
case nss_lt_id:
- str = va_arg(ap, char *);
- len = va_arg(ap, int);
+ addr = va_arg(ap, void *);
+ len = va_arg(ap, socklen_t);
type = va_arg(ap, int);
break;
default:
@@ -573,14 +580,8 @@ gethostbyname_internal(const char *name, int af, struct hostent *hp, char *buf,
}
int
-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)
+gethostbyaddr_r(const void *addr, socklen_t len, 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;
@@ -684,11 +685,7 @@ gethostbyname2(const char *name, int af)
}
struct hostent *
-#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;
OpenPOWER on IntegriCloud