dirmngr: Fix SRV record lookups when using the system resolver.
authorJustus Winter <justus@g10code.com>
Mon, 23 Nov 2015 14:46:33 +0000 (15:46 +0100)
committerJustus Winter <justus@g10code.com>
Mon, 23 Nov 2015 14:52:50 +0000 (15:52 +0100)
* dirmngr/dns-stuff.c (getsrv): Fix error handling.
--
This fixes hkp server pools not using SRV records.

Signed-off-by: Justus Winter <justus@g10code.com>
dirmngr/dns-stuff.c

index 2af4dec..694c04b 100644 (file)
@@ -1086,10 +1086,10 @@ getsrv (const char *name,struct srventry **list)
       return -1;
 
     r = res_query (name, C_IN, T_SRV, answer, sizeof answer);
-    if (r < sizeof (HEADER) || r > sizeof answer)
-      return -1;
     if (header->rcode != NOERROR || !(count=ntohs (header->ancount)))
       return 0; /* Error or no record found.  */
+    if (r < sizeof (HEADER) || r > sizeof answer)
+      return -1;
 
     emsg = &answer[r];
     pt = &answer[sizeof(HEADER)];