diff options
-rw-r--r-- | libc/inet/resolv.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c index 0c9b52415..148fd4a4a 100644 --- a/libc/inet/resolv.c +++ b/libc/inet/resolv.c @@ -1846,6 +1846,7 @@ int gethostbyname_r(const char * name, { struct in_addr *in; struct in_addr **addr_list; + char **alias; unsigned char *packet; struct resolv_answer a; int i; @@ -1899,17 +1900,27 @@ int gethostbyname_r(const char * name, addr_list[0] = in; addr_list[1] = 0; - + + if (buflen < sizeof(char *)*(ALIAS_DIM)) + return ERANGE; + alias=(char **)buf; + buf+=sizeof(char **)*(ALIAS_DIM); + buflen-=sizeof(char **)*(ALIAS_DIM); + if (buflen<256) return ERANGE; strncpy(buf, name, buflen); + alias[0] = buf; + alias[1] = NULL; + /* First check if this is already an address */ if (inet_aton(name, in)) { result_buf->h_name = buf; result_buf->h_addrtype = AF_INET; result_buf->h_length = sizeof(*in); result_buf->h_addr_list = (char **) addr_list; + result_buf->h_aliases = alias; *result=result_buf; *h_errnop = NETDB_SUCCESS; return NETDB_SUCCESS; @@ -1954,6 +1965,10 @@ int gethostbyname_r(const char * name, result_buf->h_addrtype = AF_INET; result_buf->h_length = sizeof(*in); result_buf->h_addr_list = (char **) addr_list; +#ifdef __UCLIBC_MJN3_ONLY__ +#warning TODO -- generate the full list +#endif + result_buf->h_aliases = alias; /* TODO: generate the full list */ free(packet); break; } else { |