summaryrefslogtreecommitdiffstats
path: root/cpukit/libnetworking/libc/gethostnamadr.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/libnetworking/libc/gethostnamadr.c')
-rw-r--r--cpukit/libnetworking/libc/gethostnamadr.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/cpukit/libnetworking/libc/gethostnamadr.c b/cpukit/libnetworking/libc/gethostnamadr.c
index ccf2f96164..cf0a12d68f 100644
--- a/cpukit/libnetworking/libc/gethostnamadr.c
+++ b/cpukit/libnetworking/libc/gethostnamadr.c
@@ -371,7 +371,7 @@ nodata:
int gethostbyname_r(const char* name,
struct hostent* result,
char *buf,
- int buflen,
+ size_t buflen,
struct hostent **RESULT,
int *h_errnop)
{
@@ -414,8 +414,13 @@ int gethostbyname_r(const char* name,
{
struct hostent* r;
+ struct hostent* he_buf = (struct hostent *)buf;
+ char *work_buf = buf + sizeof(struct hostent);
+ size_t remain_len = buflen - sizeof(struct hostent);
+ int he_errno;
+
sethostent(0);
- while ((r=gethostent_r(buf,buflen))) {
+ while (gethostent_r(he_buf, work_buf, remain_len, &r, &he_errno) == 0) {
int i;
if (r->h_addrtype==AF_INET && !strcasecmp(r->h_name,name)) { /* found it! */
found: