Commit 8b494282 authored by Yang Tse's avatar Yang Tse
Browse files

- Larry Lansing fixed ares_parse_srv_reply to properly parse replies

  which might contain non-SRV answers, skipping over potential non-SRV
  ones such as CNAMEs.
parent 19f79e5a
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
  Changelog for the c-ares project
  Changelog for the c-ares project


* November 26, 2009 (Yang Tse)
- Larry Lansing fixed ares_parse_srv_reply to properly parse replies
  which might contain non-SRV answers, skipping over potential non-SRV
  ones such as CNAMEs.

* November 23, 2009 (Yang Tse)
* November 23, 2009 (Yang Tse)
- Changed naming convention for c-ares libraries built with MSVC, details
- Changed naming convention for c-ares libraries built with MSVC, details
  and build instructions provided in README.msvc file.
  and build instructions provided in README.msvc file.
+1 −1
Original line number Original line Diff line number Diff line
@@ -31,6 +31,6 @@ Fixed:
Thanks go to these friendly people for their efforts and contributions:
Thanks go to these friendly people for their efforts and contributions:


 Phil Blundell, Japheth Cleaver, Yang Tse, Gregor Jasny, Joshua Kwan,
 Phil Blundell, Japheth Cleaver, Yang Tse, Gregor Jasny, Joshua Kwan,
 Timo Teras, Jakub Hrozek, John Engelhart
 Timo Teras, Jakub Hrozek, John Engelhart, Larry Lansing


Have fun!
Have fun!
+12 −11
Original line number Original line Diff line number Diff line
@@ -56,7 +56,7 @@ ares_parse_srv_reply (const unsigned char *abuf, int alen,
                      struct ares_srv_reply **srv_out)
                      struct ares_srv_reply **srv_out)
{
{
  unsigned int qdcount, ancount, i;
  unsigned int qdcount, ancount, i;
  const unsigned char *aptr;
  const unsigned char *aptr, *vptr;
  int status, rr_type, rr_class, rr_len;
  int status, rr_type, rr_class, rr_len;
  long len;
  long len;
  char *hostname = NULL, *rr_name = NULL;
  char *hostname = NULL, *rr_name = NULL;
@@ -139,24 +139,25 @@ ares_parse_srv_reply (const unsigned char *abuf, int alen,
            }
            }
          srv_last = srv_curr;
          srv_last = srv_curr;


          srv_curr->priority = ntohs (*((unsigned short *)aptr));
          vptr = aptr;
          aptr += sizeof(unsigned short);
          srv_curr->priority = ntohs (*((unsigned short *)vptr));
          srv_curr->weight = ntohs (*((unsigned short *)aptr));
          vptr += sizeof(unsigned short);
          aptr += sizeof(unsigned short);
          srv_curr->weight = ntohs (*((unsigned short *)vptr));
          srv_curr->port = ntohs (*((unsigned short *)aptr));
          vptr += sizeof(unsigned short);
          aptr += sizeof(unsigned short);
          srv_curr->port = ntohs (*((unsigned short *)vptr));
          vptr += sizeof(unsigned short);


          status = ares_expand_name (aptr, abuf, alen, &srv_curr->host, &len);
          status = ares_expand_name (vptr, abuf, alen, &srv_curr->host, &len);
          if (status != ARES_SUCCESS)
          if (status != ARES_SUCCESS)
            break;
            break;

          /* Move on to the next record */
          aptr += len;
        }
        }


      /* Don't lose memory in the next iteration */
      /* Don't lose memory in the next iteration */
      free (rr_name);
      free (rr_name);
      rr_name = NULL;
      rr_name = NULL;

      /* Move on to the next record */
      aptr += rr_len;
    }
    }


  if (hostname)
  if (hostname)
+3 −3
Original line number Original line Diff line number Diff line
@@ -172,14 +172,14 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
            }
            }
          /* Make sure we NULL-terminate */
          /* Make sure we NULL-terminate */
          *((char *) txt_curr->txt + txt_curr->length) = '\0';
          *((char *) txt_curr->txt + txt_curr->length) = '\0';

          /* Move on to the next record */
          aptr += rr_len;
        }
        }


      /* Don't lose memory in the next iteration */
      /* Don't lose memory in the next iteration */
      free (rr_name);
      free (rr_name);
      rr_name = NULL;
      rr_name = NULL;

      /* Move on to the next record */
      aptr += rr_len;
    }
    }


  if (hostname)
  if (hostname)