Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a function to parse a srv reply with ttl #393

Closed
wants to merge 51 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
7a26cb6
add a function to parse a srv reply with ttl
kylebevans Jan 25, 2021
4c9f2b6
remove print statements
kylebevans Jan 25, 2021
ab66778
make ares_parse_srv_reply a wrapper for cares_parse_srv_reply
kylebevans Jan 30, 2021
73d8bf5
return const char* from cares_srv_reply_get_host
kylebevans Jan 30, 2021
eb34dbe
use ares_strdup in ares_parse_srv_reply to copy host string
kylebevans Jan 31, 2021
a86be7e
add new structs and parse functions to support TTL for these RRs:
kylebevans Mar 10, 2021
ce230f7
check hostent->h_addr_list[0] before free
kylebevans Mar 10, 2021
7078113
Merge branch 'master' into kylebevans-ttl
kylebevans Mar 10, 2021
3d06d06
fix loop off by one for freeing h_aliases
kylebevans Mar 10, 2021
a6c585c
modify ptr parsing to use the last hostname as h_name
kylebevans Mar 11, 2021
b55ccb9
use ptr_curr instead of ptr_out to get h_name
kylebevans Mar 11, 2021
08de712
fix memory leaks
kylebevans Mar 13, 2021
7eae6d8
remove debug prints and fix unrelated Container test leak
kylebevans Mar 13, 2021
a82fed6
Merge branch 'main' into kylebevans-ttl
kylebevans Nov 7, 2021
3179732
406 - Validate hostnames in DNS responses
kylebevans Nov 7, 2021
1e03b81
fix a missed a conflict in ares.h
kylebevans Nov 7, 2021
d36bec7
add is_hostname parameter back in one spot
kylebevans Nov 7, 2021
2814894
change struct cares_ to just cares_ for declarations
kylebevans Nov 7, 2021
7fcb191
change ttl in ares_uri_reply to be unsigned int
kylebevans Nov 7, 2021
487d072
change ARES_DATATYPE_C prefix to CARES_DATATYPE_ prefix
kylebevans Nov 7, 2021
97143cc
return const from cares_get_next functions
kylebevans Nov 12, 2021
699a9cd
create cares_memdup function as sugar for malloc/memcpy pattern
kylebevans Nov 12, 2021
3286a5d
save progress
kylebevans Dec 29, 2021
aed6a71
save progress
kylebevans Dec 29, 2021
baf30b8
save progress
kylebevans Dec 30, 2021
6983bc3
add free routine for container
kylebevans Dec 30, 2021
39c8e55
add malloc routine for container
kylebevans Dec 31, 2021
385a3fe
change cares_parse_srv_reply to use container
kylebevans Dec 31, 2021
697b9fd
change ares_parse_srv_reply to use container
kylebevans Dec 31, 2021
de092f3
fix errors and warnings
kylebevans Dec 31, 2021
9583762
fix errors and warnings
kylebevans Dec 31, 2021
e22efd5
add debugging
kylebevans Jan 1, 2022
f349105
fix crashes and add debugging
kylebevans Jan 2, 2022
867e3f7
fix crashes
kylebevans Jan 2, 2022
0f5ba50
remove print statements
kylebevans Jan 2, 2022
9268be0
Add build/test instructions for asan
kylebevans Jan 2, 2022
13aec44
update build/test instructions for asan
kylebevans Jan 2, 2022
86daca3
update build/test instructions for asan
kylebevans Jan 2, 2022
9f7b8b9
update build/test instructions for asan
kylebevans Jan 2, 2022
487cb0c
attempt to fix leak
kylebevans Jan 2, 2022
84d87cb
attempt to fix leak
kylebevans Jan 2, 2022
f131cf2
add missing break statement
kylebevans Jan 2, 2022
8bca0fa
free srv_host on error
kylebevans Jan 2, 2022
979f715
add debugging
kylebevans Jan 2, 2022
183a999
fix leak if no srv rr type
kylebevans Jan 3, 2022
e247b6e
add fuzzing loop instrution
kylebevans Jan 3, 2022
e1bb47d
fix typo for cares_free_container.h
kylebevans Jan 3, 2022
73248f7
remove debugging print statements
kylebevans Jan 3, 2022
337db1d
Update instructions for lsan
kylebevans Jan 4, 2022
be37e6a
Update instructions for lsan
kylebevans Jan 4, 2022
e82ff03
change srv to csrv
kylebevans Jan 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove debugging print statements
  • Loading branch information
kylebevans committed Jan 3, 2022
commit 73248f72daba1ec6880e6627740c28506515c21b
3 changes: 0 additions & 3 deletions src/lib/ares_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "ares.h"
#include "ares_data.h"
#include "ares_private.h"
#include "stdio.h"

/*
** ares_free_data() - c-ares external API function.
Expand Down Expand Up @@ -80,7 +79,6 @@ void ares_free_data(void *dataptr)
next_data = ptr->data.srv_reply.next;
if (ptr->data.srv_reply.host)
{
printf("free host srv\n");
ares_free(ptr->data.srv_reply.host);
}
break;
Expand All @@ -89,7 +87,6 @@ void ares_free_data(void *dataptr)

if (ptr->data.srv_reply.host)
{
printf("free host csrv\n");
ares_free(ptr->data.csrv_reply.host);
}
break;
Expand Down
4 changes: 0 additions & 4 deletions src/lib/ares_parse_srv_reply.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "ares_dns.h"
#include "ares_data.h"
#include "ares_private.h"
#include "stdio.h"

int
ares_parse_srv_reply (const unsigned char *abuf, int alen,
Expand All @@ -56,7 +55,6 @@ ares_parse_srv_reply (const unsigned char *abuf, int alen,
*srv_out = NULL;

status = cares_parse_srv_reply(abuf, alen, &csrv_out);
printf("status after cares_parse_srv_reply: %d\n", status);

/* clean up on error */
if (status != ARES_SUCCESS)
Expand Down Expand Up @@ -105,14 +103,12 @@ ares_parse_srv_reply (const unsigned char *abuf, int alen,

if (csrv_out)
{
printf("free container in ares_parse\n");
cares_free_container(csrv_out);
}

/* clean up on error */
if (status != ARES_SUCCESS)
{
printf("free srv_head in ares_parse\n");
if (srv_head)
ares_free_data (srv_head);
return status;
Expand Down
2 changes: 0 additions & 2 deletions src/lib/cares_free_container.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@ void cares_free_container(void *containerptr)
case CARES_CONTAINER_SRV_REPLY_CONTAINER:
if (ptr->container.srv_container.replies[i])
{
printf("before ares_free_data in free container; count: %u\n", count);
ares_free_data(ptr->container.srv_container.replies[i]);
}

if (i == count - 1)
{
printf("before free replies in free container\n");
ares_free(ptr->container.srv_container.replies);
}
break;
Expand Down
13 changes: 0 additions & 13 deletions src/lib/cares_parse_srv_reply.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ cares_parse_srv_reply (const unsigned char *abuf, int alen,
/* Give up if abuf doesn't have room for a header. */
if (alen < HFIXEDSZ)
{
printf("alen return\n");
return ARES_EBADRESP;
}

Expand All @@ -66,12 +65,10 @@ cares_parse_srv_reply (const unsigned char *abuf, int alen,
ancount = DNS_HEADER_ANCOUNT (abuf);
if (qdcount != 1)
{
printf("qdcount return\n");
return ARES_EBADRESP;
}
if (ancount == 0)
{
printf("ancount return\n");
return ARES_ENODATA;
}

Expand All @@ -84,14 +81,12 @@ cares_parse_srv_reply (const unsigned char *abuf, int alen,
{
ares_free(hostname);
}
printf("expand_name return\n");
return status;
}

if (aptr + len + QFIXEDSZ > abuf + alen)
{
ares_free (hostname);
printf("aptr + len + QFIXED return\n");
return ARES_EBADRESP;
}
aptr += len + QFIXEDSZ;
Expand All @@ -100,7 +95,6 @@ cares_parse_srv_reply (const unsigned char *abuf, int alen,
if (srv_replies == NULL)
{
ares_free (hostname);
printf("srv_replies null return\n");
return ARES_ENOMEM;
}

Expand All @@ -109,8 +103,6 @@ cares_parse_srv_reply (const unsigned char *abuf, int alen,
srv_replies[i] = NULL;
}

printf("ancount: %u\n", ancount);

/* Examine each answer resource record (RR) in turn. */
for (i = 0; i < ancount; i++)
{
Expand Down Expand Up @@ -140,7 +132,6 @@ cares_parse_srv_reply (const unsigned char *abuf, int alen,
/* Check if we are really looking at a SRV record */
if (rr_class == C_IN && rr_type == T_SRV)
{
printf("rr is srv\n");
/* parse the SRV record itself */
if (rr_len < 6)
{
Expand Down Expand Up @@ -168,7 +159,6 @@ cares_parse_srv_reply (const unsigned char *abuf, int alen,
status = ares_expand_name (vptr, abuf, alen, &srv_host, &len);
if (status != ARES_SUCCESS)
break;
printf("expand name succeeded; srv_host: %p\n", (void *)srv_host);
cares_srv_reply_set_host(srv_curr, srv_host);
srv_replies[count] = srv_curr;
count++;
Expand Down Expand Up @@ -202,7 +192,6 @@ cares_parse_srv_reply (const unsigned char *abuf, int alen,
/* clean up on error */
if (status != ARES_SUCCESS)
{
printf("status not success in cares_parse_srv\n");
if (srv_replies)
{
for(i = 0; i < count; ++i) {
Expand All @@ -218,13 +207,11 @@ cares_parse_srv_reply (const unsigned char *abuf, int alen,
{
ares_free(srv_host);
}
printf("should have been freed return\n");
return status;
}

/* everything looks fine, return the data */
(*srv_out)->replies = srv_replies;
cares_srv_reply_container_set_count(*srv_out, count);
printf("should have been success return\n");
return ARES_SUCCESS;
}