(inaddr2str): don't advance hostent->h_addr_list, use a copy instead
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5086 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska H<>gskolan
|
* Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska H<>gskolan
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -76,14 +76,16 @@ void
|
|||||||
inaddr2str(struct in_addr addr, char *s, size_t len)
|
inaddr2str(struct in_addr addr, char *s, size_t len)
|
||||||
{
|
{
|
||||||
struct hostent *h;
|
struct hostent *h;
|
||||||
char *p;
|
char **p;
|
||||||
|
|
||||||
h = roken_gethostbyaddr ((const char *)&addr, sizeof(addr), AF_INET);
|
h = roken_gethostbyaddr ((const char *)&addr, sizeof(addr), AF_INET);
|
||||||
if (h) {
|
if (h) {
|
||||||
h = roken_gethostbyname (h->h_name);
|
h = roken_gethostbyname (h->h_name);
|
||||||
if(h)
|
if(h)
|
||||||
while ((p = *(h->h_addr_list)++))
|
for(p = h->h_addr_list;
|
||||||
if (memcmp (p, &addr, sizeof(addr)) == 0) {
|
*p;
|
||||||
|
++p)
|
||||||
|
if (memcmp (*p, &addr, sizeof(addr)) == 0) {
|
||||||
strcpy_truncate (s, h->h_name, len);
|
strcpy_truncate (s, h->h_name, len);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user