Fix build on OpenBSD. Bug 1761
[exim.git] / src / src / dns.c
index dbe331ea53e341a905bbd7ed610d0ff81fa348e6..e6e4fb6b3e7708b4bc4b1f3fe39293e28e644923 100644 (file)
@@ -40,7 +40,6 @@ fakens_search(const uschar *domain, int type, uschar *answerptr, int size)
 {
 int len = Ustrlen(domain);
 int asize = size;                  /* Locally modified */
-uschar *endname;
 uschar name[256];
 uschar utilname[256];
 uschar *aptr = answerptr;          /* Locally modified */
@@ -51,7 +50,6 @@ struct stat statbuf;
 if (domain[len - 1] == '.') len--;
 Ustrncpy(name, domain, len);
 name[len] = 0;
-endname = name + len;
 
 /* Look for the fakens utility, and if it exists, call it. */
 
@@ -86,7 +84,7 @@ if (stat(CS utilname, &statbuf) >= 0)
     asize -= rc;      /* may need to be passed on to res_search(). */
     }
 
-  /* If we ran out of output buffer before exhasting the return,
+  /* If we ran out of output buffer before exhausting the return,
   carry on reading and counting it. */
 
   if (asize == 0)
@@ -390,7 +388,8 @@ from the following bytes. */
 
 dnss->aptr += namelen;
 GETSHORT(dnss->srr.type, dnss->aptr); /* Record type */
-dnss->aptr += 6;                      /* Don't want class or TTL */
+dnss->aptr += 2;                      /* Don't want class */
+GETLONG(dnss->srr.ttl, dnss->aptr);   /* TTL */
 GETSHORT(dnss->srr.size, dnss->aptr); /* Size of data portion */
 dnss->srr.data = dnss->aptr;          /* The record's data follows */
 dnss->aptr += dnss->srr.size;         /* Advance to next RR */
@@ -424,7 +423,7 @@ if (!h->nscount || !h->aa) return NULL;
 for (rr = dns_next_rr((dns_answer*) dnsa, &dnss, RESET_AUTHORITY);
      rr;
      rr = dns_next_rr((dns_answer*) dnsa, &dnss, RESET_NEXT))
-  if (rr->type == h->ancount ? T_NS : T_SOA) return rr->name;
+  if (rr->type == (h->ancount ? T_NS : T_SOA)) return rr->name;
 return NULL;
 }
 
@@ -469,7 +468,7 @@ if (  !h->aa
    || !*trusted
    || !(auth_name = dns_extract_auth_name(dnsa))
    || OK != match_isinlist(auth_name, &trusted, 0, NULL, NULL,
-                           MCL_DOMAIN, TRUE, NULL) 
+                           MCL_DOMAIN, TRUE, NULL)
    )
   return FALSE;
 
@@ -484,8 +483,10 @@ return TRUE;
 static void
 dns_set_insecure(dns_answer * dnsa)
 {
+#ifndef DISABLE_DNSSEC
 HEADER * h = (HEADER *)dnsa->answer;
 h->ad = 0;
+#endif
 }
 
 /************************************************
@@ -497,7 +498,11 @@ h->ad = 0;
 BOOL
 dns_is_aa(const dns_answer *dnsa)
 {
+#ifdef DISABLE_DNSSEC
+return FALSE;
+#else
 return ((HEADER*)dnsa->answer)->aa;
+#endif
 }
 
 
@@ -559,7 +564,7 @@ dns_return(const uschar * name, int type, int rc)
 res_state resp = os_get_dns_resolver_res();
 tree_node *node = store_get_perm(sizeof(tree_node) + 290);
 sprintf(CS node->name, "%.255s-%s-%lx", name, dns_text_type(type),
-  resp->options);
+  (unsigned long) resp->options);
 node->data.val = rc;
 (void)tree_insertnode(&tree_dns_fails, node);
 return rc;
@@ -608,7 +613,7 @@ have many addresses in the same domain. We rely on the resolver and name server
 caching for successful lookups. */
 
 sprintf(CS node_name, "%.255s-%s-%lx", name, dns_text_type(type),
-  resp->options);
+  (unsigned long) resp->options);
 previous = tree_search(tree_dns_fails, node_name);
 if (previous != NULL)
   {
@@ -621,7 +626,7 @@ if (previous != NULL)
   return previous->data.val;
   }
 
-#ifdef EXPERIMENTAL_INTERNATIONAL
+#ifdef SUPPORT_I18N
 /* Convert all names to a-label form before doing lookup */
   {
   uschar * alabel;
@@ -852,7 +857,7 @@ for (i = 0; i < 10; i++)
     if (  rr_name
        && Ustrcmp(rr_name, *fully_qualified_name) != 0
        && rr_name[0] != '*'
-#ifdef EXPERIMENTAL_INTERNATIONAL
+#ifdef SUPPORT_I18N
        && (  !string_is_utf8(*fully_qualified_name)
          || Ustrcmp(rr_name,
               string_domain_utf8_to_alabel(*fully_qualified_name, NULL)) != 0
@@ -1113,8 +1118,7 @@ return DNS_FAIL;
 *          Get address(es) from DNS record       *
 *************************************************/
 
-/* The record type is either T_A for an IPv4 address or T_AAAA (or T_A6 when
-supported) for an IPv6 address.
+/* The record type is either T_A for an IPv4 address or T_AAAA for an IPv6 address.
 
 Argument:
   dnsa       the DNS answer block
@@ -1146,8 +1150,11 @@ else
   {
   if (rr->data + 16 <= dnsa_lim)
     {
+    struct in6_addr in6;
+    int i;
+    for (i = 0; i < 16; i++) in6.s6_addr[i] = rr->data[i];
     yield = store_get(sizeof(dns_address) + 50);
-    inet_ntop(AF_INET6, US rr->data, CS yield->address, 50);
+    inet_ntop(AF_INET6, &in6, CS yield->address, 50);
     yield->next = NULL;
     }
   }