diff options
author | Yu Jiung <jiung.yu@samsung.com> | 2016-11-09 11:15:33 +0900 |
---|---|---|
committer | Yu Jiung <jiung.yu@samsung.com> | 2016-11-09 11:15:43 +0900 |
commit | b6627e2c19506bd30328969ea8aab73fa0945f36 (patch) | |
tree | 24b768763efadd60f318873601e58dd98fe9714c /ares_parse_ptr_reply.c | |
parent | b8e6c26b7b9608dffc84645f17fe4cf534af18dd (diff) | |
download | c-ares-b6627e2c19506bd30328969ea8aab73fa0945f36.tar.gz c-ares-b6627e2c19506bd30328969ea8aab73fa0945f36.tar.bz2 c-ares-b6627e2c19506bd30328969ea8aab73fa0945f36.zip |
Imported Upstream version 1.10.0
Change-Id: Ic7f3b0ad7dca62abe4cfa642a5eb5e190eb7a8c9
Diffstat (limited to 'ares_parse_ptr_reply.c')
-rw-r--r-- | ares_parse_ptr_reply.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/ares_parse_ptr_reply.c b/ares_parse_ptr_reply.c index 3b6dbc3..df21e40 100644 --- a/ares_parse_ptr_reply.c +++ b/ares_parse_ptr_reply.c @@ -16,9 +16,6 @@ #include "ares_setup.h" -#ifdef HAVE_SYS_SOCKET_H -# include <sys/socket.h> -#endif #ifdef HAVE_NETINET_IN_H # include <netinet/in.h> #endif @@ -38,10 +35,9 @@ # include <strings.h> #endif -#include <stdlib.h> -#include <string.h> #include "ares.h" #include "ares_dns.h" +#include "ares_nowarn.h" #include "ares_private.h" int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr, @@ -107,6 +103,12 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr, rr_class = DNS_RR_CLASS(aptr); rr_len = DNS_RR_LEN(aptr); aptr += RRFIXEDSZ; + if (aptr + rr_len > abuf + alen) + { + free(rr_name); + status = ARES_EBADRESP; + break; + } if (rr_class == C_IN && rr_type == T_PTR && strcasecmp(rr_name, ptrname) == 0) @@ -189,8 +191,8 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr, for (i=0 ; i<aliascnt ; i++) hostent->h_aliases[i] = aliases[i]; hostent->h_aliases[aliascnt] = NULL; - hostent->h_addrtype = family; - hostent->h_length = addrlen; + hostent->h_addrtype = aresx_sitoss(family); + hostent->h_length = aresx_sitoss(addrlen); memcpy(hostent->h_addr_list[0], addr, addrlen); hostent->h_addr_list[1] = NULL; *host = hostent; @@ -207,7 +209,7 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr, status = ARES_ENOMEM; } for (i=0 ; i<aliascnt ; i++) - if (aliases[i]) + if (aliases[i]) free(aliases[i]); free(aliases); if (hostname) |