diff options
Diffstat (limited to 'ares')
| -rw-r--r-- | ares/CHANGES | 8 | ||||
| -rw-r--r-- | ares/RELEASE-NOTES | 5 | ||||
| -rw-r--r-- | ares/ares_expand_name.c | 11 | ||||
| -rw-r--r-- | ares/ares_parse_a_reply.c | 12 | ||||
| -rw-r--r-- | ares/ares_parse_aaaa_reply.c | 7 | ||||
| -rw-r--r-- | ares/ares_parse_ns_reply.c | 7 | ||||
| -rw-r--r-- | ares/ares_parse_ptr_reply.c | 10 | ||||
| -rw-r--r-- | ares/ares_private.h | 3 | 
8 files changed, 46 insertions, 17 deletions
| diff --git a/ares/CHANGES b/ares/CHANGES index 944bbf0c8..1c6b6070b 100644 --- a/ares/CHANGES +++ b/ares/CHANGES @@ -1,5 +1,13 @@    Changelog for the c-ares project +* January 11 2008 (Daniel Stenberg) +- Phil Blundell added the internal function ares__expand_name_for_response() +  that is now used by the ares_parse_*_reply() functions instead of the +  ares_expand_name() simply to easier return ARES_EBADRESP for the cases where +  the name expansion fails as in responses that really isn't expected. + +Version 1.6.0 (Dec 9, 2008) +  * December 9 2008 (Gisle Vanem)    Fixes for Win32 targets using the Watt-32 tcp/ip stack. diff --git a/ares/RELEASE-NOTES b/ares/RELEASE-NOTES index a96543777..3d3db9c57 100644 --- a/ares/RELEASE-NOTES +++ b/ares/RELEASE-NOTES @@ -6,10 +6,11 @@ Changed:  Fixed: - o  + o ares_parse_*_reply() functions now return ARES_EBADRESP instead of +   ARES_EBADNAME if the name in the response failed to decode  Thanks go to these friendly people for their efforts and contributions: -  + Phil Blundell  Have fun! diff --git a/ares/ares_expand_name.c b/ares/ares_expand_name.c index 8a9d82215..b0af474df 100644 --- a/ares/ares_expand_name.c +++ b/ares/ares_expand_name.c @@ -177,3 +177,14 @@ static int name_length(const unsigned char *encoded, const unsigned char *abuf,     */    return (n) ? n - 1 : n;  } + +/* Like ares_expand_name but returns EBADRESP in case of invalid input. */ +int ares__expand_name_for_response(const unsigned char *encoded, +                                   const unsigned char *abuf, int alen, +                                   char **s, long *enclen) +{ +  int status = ares_expand_name(encoded, abuf, alen, s, enclen); +  if (status == ARES_EBADNAME) +    status = ARES_EBADRESP; +  return status; +} diff --git a/ares/ares_parse_a_reply.c b/ares/ares_parse_a_reply.c index 6380f5bac..b8d98d43c 100644 --- a/ares/ares_parse_a_reply.c +++ b/ares/ares_parse_a_reply.c @@ -83,7 +83,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,    /* Expand the name from the question, and skip past the question. */    aptr = abuf + HFIXEDSZ; -  status = ares_expand_name(aptr, abuf, alen, &hostname, &len); +  status = ares__expand_name_for_response(aptr, abuf, alen, &hostname, &len);    if (status != ARES_SUCCESS)      return status;    if (aptr + len + QFIXEDSZ > abuf + alen) @@ -95,7 +95,8 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,    if (host)      { -      /* Allocate addresses and aliases; ancount gives an upper bound for both. */ +      /* Allocate addresses and aliases; ancount gives an upper bound for +         both. */        addrs = malloc(ancount * sizeof(struct in_addr));        if (!addrs)          { @@ -115,7 +116,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,        addrs = NULL;        aliases = NULL;      } -   +    naddrs = 0;    naliases = 0; @@ -123,7 +124,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,    for (i = 0; i < (int)ancount; i++)      {        /* Decode the RR up to the data field. */ -      status = ares_expand_name(aptr, abuf, alen, &rr_name, &len); +      status = ares__expand_name_for_response(aptr, abuf, alen, &rr_name, &len);        if (status != ARES_SUCCESS)          break;        aptr += len; @@ -176,7 +177,8 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,            naliases++;            /* Decode the RR data and replace the hostname with it. */ -          status = ares_expand_name(aptr, abuf, alen, &rr_data, &len); +          status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data, +                                                  &len);            if (status != ARES_SUCCESS)              break;            free(hostname); diff --git a/ares/ares_parse_aaaa_reply.c b/ares/ares_parse_aaaa_reply.c index 6a43f933c..60f8f851b 100644 --- a/ares/ares_parse_aaaa_reply.c +++ b/ares/ares_parse_aaaa_reply.c @@ -84,7 +84,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,    /* Expand the name from the question, and skip past the question. */    aptr = abuf + HFIXEDSZ; -  status = ares_expand_name(aptr, abuf, alen, &hostname, &len); +  status = ares__expand_name_for_response(aptr, abuf, alen, &hostname, &len);    if (status != ARES_SUCCESS)      return status;    if (aptr + len + QFIXEDSZ > abuf + alen) @@ -123,7 +123,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,    for (i = 0; i < (int)ancount; i++)      {        /* Decode the RR up to the data field. */ -      status = ares_expand_name(aptr, abuf, alen, &rr_name, &len); +      status = ares__expand_name_for_response(aptr, abuf, alen, &rr_name, &len);        if (status != ARES_SUCCESS)          break;        aptr += len; @@ -176,7 +176,8 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,            naliases++;            /* Decode the RR data and replace the hostname with it. */ -          status = ares_expand_name(aptr, abuf, alen, &rr_data, &len); +          status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data, +                                                  &len);            if (status != ARES_SUCCESS)              break;            free(hostname); diff --git a/ares/ares_parse_ns_reply.c b/ares/ares_parse_ns_reply.c index 9eed3ebe4..abcf88377 100644 --- a/ares/ares_parse_ns_reply.c +++ b/ares/ares_parse_ns_reply.c @@ -73,7 +73,7 @@ int ares_parse_ns_reply( const unsigned char* abuf, int alen,    /* Expand the name from the question, and skip past the question. */    aptr = abuf + HFIXEDSZ; -  status = ares_expand_name( aptr, abuf, alen, &hostname, &len ); +  status = ares__expand_name_for_response( aptr, abuf, alen, &hostname, &len);    if ( status != ARES_SUCCESS )      return status;    if ( aptr + len + QFIXEDSZ > abuf + alen ) @@ -96,7 +96,7 @@ int ares_parse_ns_reply( const unsigned char* abuf, int alen,    for ( i = 0; i < ( int ) ancount; i++ )    {      /* Decode the RR up to the data field. */ -    status = ares_expand_name( aptr, abuf, alen, &rr_name, &len ); +    status = ares__expand_name_for_response( aptr, abuf, alen, &rr_name, &len );      if ( status != ARES_SUCCESS )        break;      aptr += len; @@ -113,7 +113,8 @@ int ares_parse_ns_reply( const unsigned char* abuf, int alen,      if ( rr_class == C_IN && rr_type == T_NS )      {        /* Decode the RR data and add it to the nameservers list */ -      status = ares_expand_name( aptr, abuf, alen, &rr_data, &len ); +      status = ares__expand_name_for_response( aptr, abuf, alen, &rr_data, +                                               &len);        if ( status != ARES_SUCCESS )        {          break; diff --git a/ares/ares_parse_ptr_reply.c b/ares/ares_parse_ptr_reply.c index 54fb560b0..b72f99521 100644 --- a/ares/ares_parse_ptr_reply.c +++ b/ares/ares_parse_ptr_reply.c @@ -73,7 +73,7 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,    /* Expand the name from the question, and skip past the question. */    aptr = abuf + HFIXEDSZ; -  status = ares_expand_name(aptr, abuf, alen, &ptrname, &len); +  status = ares__expand_name_for_response(aptr, abuf, alen, &ptrname, &len);    if (status != ARES_SUCCESS)      return status;    if (aptr + len + QFIXEDSZ > abuf + alen) @@ -94,7 +94,7 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,    for (i = 0; i < (int)ancount; i++)      {        /* Decode the RR up to the data field. */ -      status = ares_expand_name(aptr, abuf, alen, &rr_name, &len); +      status = ares__expand_name_for_response(aptr, abuf, alen, &rr_name, &len);        if (status != ARES_SUCCESS)          break;        aptr += len; @@ -112,7 +112,8 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,            && strcasecmp(rr_name, ptrname) == 0)          {            /* Decode the RR data and set hostname to it. */ -          status = ares_expand_name(aptr, abuf, alen, &rr_data, &len); +          status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data, +                                                  &len);            if (status != ARES_SUCCESS)              break;            if (hostname) @@ -141,7 +142,8 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,        if (rr_class == C_IN && rr_type == T_CNAME)          {            /* Decode the RR data and replace ptrname with it. */ -          status = ares_expand_name(aptr, abuf, alen, &rr_data, &len); +          status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data, +                                                  &len);            if (status != ARES_SUCCESS)              break;            free(ptrname); diff --git a/ares/ares_private.h b/ares/ares_private.h index 137e155de..f8afd4de1 100644 --- a/ares/ares_private.h +++ b/ares/ares_private.h @@ -319,6 +319,9 @@ int ares__read_line(FILE *fp, char **buf, int *bufsize);  void ares__free_query(struct query *query);  unsigned short ares__generate_new_id(rc4_key* key);  struct timeval ares__tvnow(void); +int ares__expand_name_for_response(const unsigned char *encoded, +                                   const unsigned char *abuf, int alen, +                                   char **s, long *enclen);  #if 0 /* Not used */  long ares__tvdiff(struct timeval t1, struct timeval t2);  #endif | 
