summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Cabrero <scabrero@samba.org>2019-10-08 13:30:18 +0200
committerSamuel Cabrero <scabrero@sn-devel-184>2019-11-08 12:31:29 +0000
commitf9eaf4dc713bab48703a053c9446b6becabe18dc (patch)
tree9d07c49d4e6665ec25db653c44dcede28c685d83
parent8dbb8643499c495474f28071750cbfc2da5b60f0 (diff)
downloadsamba-f9eaf4dc713bab48703a053c9446b6becabe18dc.tar.gz
dns: Always return SOA record for records we should know
Regression introduced by commit 4b54e14b7cf456e327b176b365e8471e0899210b, where the number of returned records is not set by talloc_array_length when the record is not found. Found by DELL EMC at SDC SMB3 plugfest trying to perform a secure DNS update. Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Samuel Cabrero <scabrero@samba.org> Autobuild-Date(master): Fri Nov 8 12:31:30 UTC 2019 on sn-devel-184
-rw-r--r--source4/dns_server/dns_query.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/source4/dns_server/dns_query.c b/source4/dns_server/dns_query.c
index b75fabe7e82..762bcca6fb6 100644
--- a/source4/dns_server/dns_query.c
+++ b/source4/dns_server/dns_query.c
@@ -645,20 +645,12 @@ static void handle_authoritative_done(struct tevent_req *subreq)
static WERROR handle_authoritative_recv(struct tevent_req *req)
{
- struct handle_authoritative_state *state = tevent_req_data(
- req, struct handle_authoritative_state);
WERROR werr;
if (tevent_req_is_werror(req, &werr)) {
return werr;
}
- werr = add_zone_authority_record(state->dns, state, state->question,
- state->nsrecs);
- if (!W_ERROR_IS_OK(werr)) {
- return werr;
- }
-
return WERR_OK;
}
@@ -1091,6 +1083,7 @@ static void dns_server_process_query_got_auth(struct tevent_req *subreq)
struct dns_server_process_query_state *state = tevent_req_data(
req, struct dns_server_process_query_state);
WERROR werr;
+ WERROR werr2;
werr = handle_authoritative_recv(subreq);
TALLOC_FREE(subreq);
@@ -1103,6 +1096,20 @@ static void dns_server_process_query_got_auth(struct tevent_req *subreq)
/* If you have run out of forwarders, simply finish */
if (state->forwarders == NULL) {
+ werr2 = add_zone_authority_record(state->dns,
+ state,
+ state->question,
+ &state->nsrecs);
+ if (tevent_req_werror(req, werr2)) {
+ DBG_WARNING("Failed to add SOA record: %s\n",
+ win_errstr(werr2));
+ return;
+ }
+
+ state->ancount = talloc_array_length(state->answers);
+ state->nscount = talloc_array_length(state->nsrecs);
+ state->arcount = talloc_array_length(state->additional);
+
tevent_req_werror(req, werr);
return;
}
@@ -1125,6 +1132,16 @@ static void dns_server_process_query_got_auth(struct tevent_req *subreq)
return;
}
+ werr2 = add_zone_authority_record(state->dns,
+ state,
+ state->question,
+ &state->nsrecs);
+ if (tevent_req_werror(req, werr2)) {
+ DBG_WARNING("Failed to add SOA record: %s\n",
+ win_errstr(werr2));
+ return;
+ }
+
state->ancount = talloc_array_length(state->answers);
state->nscount = talloc_array_length(state->nsrecs);
state->arcount = talloc_array_length(state->additional);