Gerald Combs fixed a bug in ares_parse_ptr_reply() which would cause a
buffer to shrink instead of expand if a reply contained 8 or more records.
This commit is contained in:
@@ -3,6 +3,9 @@
|
|||||||
* Nov 26 2008 (Yang Tse)
|
* Nov 26 2008 (Yang Tse)
|
||||||
- Brad Spencer provided changes to allow buildconf to work on OS X.
|
- Brad Spencer provided changes to allow buildconf to work on OS X.
|
||||||
|
|
||||||
|
- Gerald Combs fixed a bug in ares_parse_ptr_reply() which would cause a
|
||||||
|
buffer to shrink instead of expand if a reply contained 8 or more records.
|
||||||
|
|
||||||
* Nov 25 2008 (Yang Tse)
|
* Nov 25 2008 (Yang Tse)
|
||||||
- In preparation for the upcomming IPv6 nameservers patch, the internal
|
- In preparation for the upcomming IPv6 nameservers patch, the internal
|
||||||
ares_addr union is now changed into an internal struct which also holds
|
ares_addr union is now changed into an internal struct which also holds
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
|
|||||||
char *ptrname, *hostname, *rr_name, *rr_data;
|
char *ptrname, *hostname, *rr_name, *rr_data;
|
||||||
struct hostent *hostent;
|
struct hostent *hostent;
|
||||||
int aliascnt = 0;
|
int aliascnt = 0;
|
||||||
|
int alias_alloc = 8;
|
||||||
char ** aliases;
|
char ** aliases;
|
||||||
|
|
||||||
/* Set *host to NULL for all failure cases. */
|
/* Set *host to NULL for all failure cases. */
|
||||||
@@ -84,7 +85,7 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
|
|||||||
|
|
||||||
/* Examine each answer resource record (RR) in turn. */
|
/* Examine each answer resource record (RR) in turn. */
|
||||||
hostname = NULL;
|
hostname = NULL;
|
||||||
aliases = malloc(8 * sizeof(char *));
|
aliases = malloc(alias_alloc * sizeof(char *));
|
||||||
if (!aliases)
|
if (!aliases)
|
||||||
{
|
{
|
||||||
free(ptrname);
|
free(ptrname);
|
||||||
@@ -125,9 +126,10 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
|
|||||||
}
|
}
|
||||||
strncpy(aliases[aliascnt], rr_data, strlen(rr_data)+1);
|
strncpy(aliases[aliascnt], rr_data, strlen(rr_data)+1);
|
||||||
aliascnt++;
|
aliascnt++;
|
||||||
if ((aliascnt%8)==0) {
|
if (aliascnt >= alias_alloc) {
|
||||||
char **ptr;
|
char **ptr;
|
||||||
ptr = realloc(aliases, (aliascnt/16+1) * sizeof(char *));
|
alias_alloc *= 2;
|
||||||
|
ptr = realloc(aliases, alias_alloc * sizeof(char *));
|
||||||
if(!ptr) {
|
if(!ptr) {
|
||||||
status = ARES_ENOMEM;
|
status = ARES_ENOMEM;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user