From f01e7188c8c5253449ff6774b195b9d1152eeeb7 Mon Sep 17 00:00:00 2001 From: Jim Hague Date: Wed, 4 Mar 2020 09:45:52 +0000 Subject: [PATCH 1/2] CMake libunbound fixups. 1. ub_ctx_set_stub is in unbound.h, not unbound-events.h. 2. Only bother looking for unbound event API if enabled. 3. If building stub only, ensure all libunbound items are off. This is necessary in case we first configure without stub only, and then change to stub only. Fixes #463 --- CMakeLists.txt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d22d3ca..10d10b99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -489,9 +489,19 @@ if (NOT ENABLE_STUB_ONLY) set(CMAKE_REQUIRED_INCLUDES ${LIBUNBOUND_INCLUDE_DIR}) set(CMAKE_REQUIRED_LIBRARIES ${LIBUNBOUND_LIBRARIES}) - check_include_file(unbound-event.h HAVE_UNBOUND_EVENT_H) - check_symbol_exists(ub_ctx_create_ub_event "unbound-event.h" HAVE_UNBOUND_EVENT_API) - check_symbol_exists(ub_ctx_set_stub "unbound-event.h" HAVE_UB_CTX_SET_STUB) + + check_symbol_exists(ub_ctx_set_stub "unbound.h" HAVE_UB_CTX_SET_STUB) + + if (ENABLE_UNBOUND_EVENT_API) + check_include_file(unbound-event.h HAVE_UNBOUND_EVENT_H) + check_symbol_exists(ub_ctx_create_ub_event "unbound-event.h" HAVE_UNBOUND_EVENT_API) + endif () +else () + # Ensure we're not using libunbound items. + set(HAVE_LIBUNBOUND 0) + set(HAVE_UNBOUND_EVENT_H 0) + set(HAVE_UNBOUND_EVENT_API 0) + set(HAVE_UB_CTX_SET_STUB 0) endif () # Event loop extension From ef455471f4f1db778e7bcc58818fc780a280c16d Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Wed, 4 Mar 2020 10:57:11 +0000 Subject: [PATCH 2/2] Work around dnsmasq issue --- src/test/check_getdns_common.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/test/check_getdns_common.c b/src/test/check_getdns_common.c index 9816f8ff..723f7f81 100644 --- a/src/test/check_getdns_common.c +++ b/src/test/check_getdns_common.c @@ -57,6 +57,8 @@ int event_loop_type = 0; void extract_response(struct getdns_dict *response, struct extracted_response *ex_response) { int have_answer_type = 0; + int get_reply = 0; + uint32_t rcode; ck_assert_msg(response != NULL, "Response should not be NULL"); /* fprintf(stderr, "%s\n", getdns_pretty_print_dict(response)); */ @@ -103,10 +105,18 @@ void extract_response(struct getdns_dict *response, struct extracted_response *e ex_response->question = NULL; return; } + /* Work around dnsmasq issue in which NXDOMAIN AAAA responses + * are returned as NODATA. In such cases use the other A response + * which does have rcode NXDOMAIN. + */ + if (ex_response->status == GETDNS_RESPSTATUS_NO_NAME + && !getdns_dict_get_int(response, "/replies_tree/1/header/rcode", &rcode) + && rcode == GETDNS_RCODE_NXDOMAIN) + get_reply = 1; - ASSERT_RC(getdns_list_get_dict(ex_response->replies_tree, 0, &ex_response->replies_tree_sub_dict), - GETDNS_RETURN_GOOD, "Failed to extract \"replies_tree[0]\""); - ck_assert_msg(ex_response->replies_tree_sub_dict != NULL, "replies_tree[0] dict should not be NULL"); + ASSERT_RC(getdns_list_get_dict(ex_response->replies_tree, get_reply, &ex_response->replies_tree_sub_dict), + GETDNS_RETURN_GOOD, "Failed to extract \"replies_tree[#]\""); + ck_assert_msg(ex_response->replies_tree_sub_dict != NULL, "replies_tree[#] dict should not be NULL"); ASSERT_RC(getdns_dict_get_list(ex_response->replies_tree_sub_dict, "additional", &ex_response->additional), GETDNS_RETURN_GOOD, "Failed to extract \"additional\"");