* \param answer The raw DNS answer
* \param answer_size The size of the raw DNS answer
*
+ * Zero-sized and NULL answers are permitted by this function. This may be
+ * necessary if the query fails at an early stage and no actual DNS response
+ * has been received from a DNS server.
+ *
* \retval 0 success
* \retval -1 failure
*/
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;
}
return -1;
}
- if (!answer || answer_size == 0) {
- ast_debug(2, "Query '%p': Could not set result information since no DNS answer was provided\n",
- query);
- return -1;
+ if (!answer) {
+ answer = "";
+ answer_size = 0;
+ ast_debug(2, "Query '%p': Assuming zero-sized answer on NULL input\n", query);
}
ast_dns_result_free(query->result);
info->description =
"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 canonical name";
return AST_TEST_NOT_RUN;
case TEST_EXECUTE:
break;
return AST_TEST_FAIL;
}
- 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;
- }
-
return AST_TEST_PASS;
}