summaryrefslogtreecommitdiff
path: root/ares_parse_a_reply.c
diff options
context:
space:
mode:
Diffstat (limited to 'ares_parse_a_reply.c')
-rw-r--r--ares_parse_a_reply.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/ares_parse_a_reply.c b/ares_parse_a_reply.c
index a3ed69e..0422bd3 100644
--- a/ares_parse_a_reply.c
+++ b/ares_parse_a_reply.c
@@ -85,7 +85,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
return status;
if (aptr + len + QFIXEDSZ > abuf + alen)
{
- free(hostname);
+ ares_free(hostname);
return ARES_EBADRESP;
}
aptr += len + QFIXEDSZ;
@@ -94,17 +94,17 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
{
/* Allocate addresses and aliases; ancount gives an upper bound for
both. */
- addrs = malloc(ancount * sizeof(struct in_addr));
+ addrs = ares_malloc(ancount * sizeof(struct in_addr));
if (!addrs)
{
- free(hostname);
+ ares_free(hostname);
return ARES_ENOMEM;
}
- aliases = malloc((ancount + 1) * sizeof(char *));
+ aliases = ares_malloc((ancount + 1) * sizeof(char *));
if (!aliases)
{
- free(hostname);
- free(addrs);
+ ares_free(hostname);
+ ares_free(addrs);
return ARES_ENOMEM;
}
}
@@ -127,7 +127,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
aptr += len;
if (aptr + RRFIXEDSZ > abuf + alen)
{
- free(rr_name);
+ ares_free(rr_name);
status = ARES_EBADRESP;
break;
}
@@ -138,7 +138,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
aptr += RRFIXEDSZ;
if (aptr + rr_len > abuf + alen)
{
- free(rr_name);
+ ares_free(rr_name);
status = ARES_EBADRESP;
break;
}
@@ -150,22 +150,22 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
if (addrs)
{
if (aptr + sizeof(struct in_addr) > abuf + alen)
- {
- free(rr_name);
+ { /* LCOV_EXCL_START: already checked above */
+ ares_free(rr_name);
status = ARES_EBADRESP;
break;
- }
+ } /* LCOV_EXCL_STOP */
memcpy(&addrs[naddrs], aptr, sizeof(struct in_addr));
}
if (naddrs < max_addr_ttls)
{
struct ares_addrttl * const at = &addrttls[naddrs];
if (aptr + sizeof(struct in_addr) > abuf + alen)
- {
- free(rr_name);
+ { /* LCOV_EXCL_START: already checked above */
+ ares_free(rr_name);
status = ARES_EBADRESP;
break;
- }
+ } /* LCOV_EXCL_STOP */
memcpy(&at->ipaddr, aptr, sizeof(struct in_addr));
at->ttl = rr_ttl;
}
@@ -179,7 +179,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
if (aliases)
aliases[naliases] = rr_name;
else
- free(rr_name);
+ ares_free(rr_name);
naliases++;
/* Decode the RR data and replace the hostname with it. */
@@ -187,7 +187,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
&len);
if (status != ARES_SUCCESS)
break;
- free(hostname);
+ ares_free(hostname);
hostname = rr_data;
/* Take the min of the TTLs we see in the CNAME chain. */
@@ -195,14 +195,14 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
cname_ttl = rr_ttl;
}
else
- free(rr_name);
+ ares_free(rr_name);
aptr += rr_len;
if (aptr > abuf + alen)
- {
+ { /* LCOV_EXCL_START: already checked above */
status = ARES_EBADRESP;
break;
- }
+ } /* LCOV_EXCL_STOP */
}
if (status == ARES_SUCCESS && naddrs == 0 && naliases == 0)
@@ -228,10 +228,10 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
if (host)
{
/* Allocate memory to build the host entry. */
- hostent = malloc(sizeof(struct hostent));
+ hostent = ares_malloc(sizeof(struct hostent));
if (hostent)
{
- hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *));
+ hostent->h_addr_list = ares_malloc((naddrs + 1) * sizeof(char *));
if (hostent->h_addr_list)
{
/* Fill in the hostent and return successfully. */
@@ -243,11 +243,11 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
hostent->h_addr_list[i] = (char *) &addrs[i];
hostent->h_addr_list[naddrs] = NULL;
if (!naddrs && addrs)
- free(addrs);
+ ares_free(addrs);
*host = hostent;
return ARES_SUCCESS;
}
- free(hostent);
+ ares_free(hostent);
}
status = ARES_ENOMEM;
}
@@ -255,10 +255,10 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
if (aliases)
{
for (i = 0; i < naliases; i++)
- free(aliases[i]);
- free(aliases);
+ ares_free(aliases[i]);
+ ares_free(aliases);
}
- free(addrs);
- free(hostname);
+ ares_free(addrs);
+ ares_free(hostname);
return status;
}