From 358690b5f17fefecbe42cfbd3e65746f3ce3205f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 9 Nov 2012 08:55:40 +0100 Subject: [PATCH 1/2] source3/libaddns: remove pointless check for resp->num_additionals != 1 We never use resp->additionals, so there's no reason to check. This fixes dns updates against BIND9 (used in a Samba4 domain). Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett (cherry picked from commit b59c5db5f74f56c0536635a41ae51c389109ceb5) --- source3/libaddns/dnsgss.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source3/libaddns/dnsgss.c b/source3/libaddns/dnsgss.c index c903741..fe7c6ca 100644 --- a/source3/libaddns/dnsgss.c +++ b/source3/libaddns/dnsgss.c @@ -175,8 +175,7 @@ static DNS_ERROR dns_negotiate_gss_ctx_int( TALLOC_CTX *mem_ctx, * TODO: Compare id and keyname */ - if ((resp->num_additionals != 1) || - (resp->num_answers == 0) || + if ((resp->num_answers == 0) || (resp->answers[0]->type != QTYPE_TKEY)) { err = ERROR_DNS_INVALID_MESSAGE; goto error; -- 1.7.9.5 From 97114e1a5415d73d86f87e89c03cc1957d82506c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 9 Nov 2012 08:59:36 +0100 Subject: [PATCH 2/2] source3/libaddns: don't depend on the order in resp->answers[] Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett (cherry picked from commit eecc1d294256210ee8c2f6ab79d21b835258a6d4) --- source3/libaddns/dnsgss.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/source3/libaddns/dnsgss.c b/source3/libaddns/dnsgss.c index fe7c6ca..a8b2ea1 100644 --- a/source3/libaddns/dnsgss.c +++ b/source3/libaddns/dnsgss.c @@ -164,6 +164,8 @@ static DNS_ERROR dns_negotiate_gss_ctx_int( TALLOC_CTX *mem_ctx, struct dns_request *resp; struct dns_buffer *buf; struct dns_tkey_record *tkey; + struct dns_rrec *tkey_answer = NULL; + uint16_t i; err = dns_receive(mem_ctx, conn, &buf); if (!ERR_DNS_IS_OK(err)) goto error; @@ -174,9 +176,16 @@ static DNS_ERROR dns_negotiate_gss_ctx_int( TALLOC_CTX *mem_ctx, /* * TODO: Compare id and keyname */ - - if ((resp->num_answers == 0) || - (resp->answers[0]->type != QTYPE_TKEY)) { + + for (i=0; i < resp->num_answers; i++) { + if (resp->answers[i]->type != QTYPE_TKEY) { + continue; + } + + tkey_answer = resp->answers[i]; + } + + if (tkey_answer == NULL) { err = ERROR_DNS_INVALID_MESSAGE; goto error; } -- 1.7.9.5