[Asterisk-code-review] dns core: Allow zero-length DNS responses. (asterisk[master])
Mark Michelson
asteriskteam at digium.com
Wed Jul 29 13:06:01 CDT 2015
Mark Michelson has uploaded a new change for review.
https://gerrit.asterisk.org/985
Change subject: dns_core: Allow zero-length DNS responses.
......................................................................
dns_core: Allow zero-length DNS responses.
A testsuite test recently failed due to a crash that occurred in the DNS
core. The problem was that the test could not resolve an address, did
not set a result on the DNS query, and then indicated the query was
completed. The DNS core does not handle the case of a query with no
result gracefully, and so there is a crash.
This changeset makes the DNS system resolver set a result with a
zero-length answer in the case that a DNS resolution failure occurs
early. The DNS core now also will accept such a response without
treating it as invalid input. A unit test was updated to no longer treat
setting a zero-length response as off-nominal.
Change-Id: Ie56641e22debdaa61459e1c9a042e23b78affbf6
---
M main/dns.c
M main/dns_core.c
M tests/test_dns.c
3 files changed, 3 insertions(+), 11 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/85/985/1
diff --git a/main/dns.c b/main/dns.c
index 409ed44..e1b7770 100644
--- a/main/dns.c
+++ b/main/dns.c
@@ -559,6 +559,7 @@
if (dns_response_len < 0) {
ast_log(LOG_ERROR, "DNS search failed for %s\n", dname);
+ response_handler(context, (unsigned char *)"", 0, ns_r_nxdomain);
return AST_DNS_SEARCH_FAILURE;
}
diff --git a/main/dns_core.c b/main/dns_core.c
index 0b471db..9119f60 100644
--- a/main/dns_core.c
+++ b/main/dns_core.c
@@ -399,7 +399,7 @@
return -1;
}
- if (!answer || answer_size == 0) {
+ if (!answer) {
ast_debug(2, "Query '%p': Could not set result information since no DNS answer was provided\n",
query);
return -1;
diff --git a/tests/test_dns.c b/tests/test_dns.c
index 4e2c4a4..a2132d5 100644
--- a/tests/test_dns.c
+++ b/tests/test_dns.c
@@ -366,8 +366,7 @@
"This test performs the following:\n"
"\t* Attempt to add a DNS result that is both bogus and secure\n"
"\t* Attempt to add a DNS result that has no canonical name\n"
- "\t* Attempt to add a DNS result that has no answer\n"
- "\t* Attempt to add a DNS result with a zero answer size";
+ "\t* Attempt to add a DNS result that has no answer\n";
return AST_TEST_NOT_RUN;
case TEST_EXECUTE:
break;
@@ -394,14 +393,6 @@
if (!ast_dns_resolver_set_result(&some_query, 0, 0, ns_r_noerror, NULL,
NULL, DNS_ANSWER_SIZE)) {
ast_test_status_update(test, "Successfully added result with no answer\n");
- result = ast_dns_query_get_result(&some_query);
- ast_dns_result_free(result);
- return AST_TEST_FAIL;
- }
-
- if (!ast_dns_resolver_set_result(&some_query, 0, 0, ns_r_noerror, NULL,
- DNS_ANSWER, 0)) {
- ast_test_status_update(test, "Successfully added result with answer size of zero\n");
result = ast_dns_query_get_result(&some_query);
ast_dns_result_free(result);
return AST_TEST_FAIL;
--
To view, visit https://gerrit.asterisk.org/985
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie56641e22debdaa61459e1c9a042e23b78affbf6
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>
More information about the asterisk-code-review
mailing list