lib/addns: don't depend on the order in resp->answers[]
authorStefan Metzmacher <metze@samba.org>
Fri, 9 Nov 2012 07:59:36 +0000 (08:59 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 13 Nov 2012 11:14:13 +0000 (22:14 +1100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/addns/dnsgss.c

index c22173468d50f83a7b2b4285b859a300bb132bfb..52f1298e01e24e28fe9a2394afc32efd6fa95b4b 100644 (file)
@@ -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;
                        }