Merge tag 'exim-4_82_1'
[exim.git] / src / src / routers / rf_lookup_hostlist.c
index a5beb49f4f7c2cafed52a4d05b6799c5f635039e..0eae31e6160f0f21d76ce4cd0cdd612e3c2fc1a1 100644 (file)
@@ -1,10 +1,8 @@
-/* $Cambridge: exim/src/src/routers/rf_lookup_hostlist.c,v 1.9 2007/03/13 15:32:48 ph10 Exp $ */
-
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2007 */
+/* Copyright (c) University of Cambridge 1995 - 2009 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 
@@ -64,13 +62,13 @@ list of MX hosts. If the first host is the local host, act according to the
 "self" option in the configuration. */
 
 prev = NULL;
-for (h = addr->host_list; h != NULL; prev = h, h = next_h)
+for (h = addr->host_list; h != NULL; h = next_h)
   {
   uschar *canonical_name;
   int rc, len, port;
 
   next_h = h->next;
-  if (h->address != NULL) continue;
+  if (h->address != NULL) { prev = h; continue; }
 
   DEBUG(D_route|D_host_lookup)
     debug_printf("finding IP address for %s\n", h->name);
@@ -96,6 +94,8 @@ for (h = addr->host_list; h != NULL; prev = h, h = next_h)
         NULL,                           /* SRV service not relevant */
         NULL,                           /* failing srv domains not relevant */
         NULL,                           /* no special mx failing domains */
+       NULL,                           /* no dnssec request XXX ? */
+       NULL,                           /* no dnssec require XXX ? */
         NULL,                           /* fully_qualified_name */
         NULL);                          /* indicate local host removed */
     }
@@ -119,7 +119,9 @@ for (h = addr->host_list; h != NULL; prev = h, h = next_h)
     BOOL removed;
     DEBUG(D_route|D_host_lookup) debug_printf("doing DNS lookup\n");
     rc = host_find_bydns(h, ignore_target_hosts, HOST_FIND_BY_A, NULL, NULL,
-      NULL, &canonical_name, &removed);
+      NULL,
+      NULL, NULL,      /*XXX dnssec? */
+      &canonical_name, &removed);
     if (rc == HOST_FOUND)
       {
       if (removed) setflag(addr, af_local_host_removed);
@@ -160,8 +162,7 @@ for (h = addr->host_list; h != NULL; prev = h, h = next_h)
     if (hff_code == hff_ignore)
       {
       if (prev == NULL) addr->host_list = next_h; else prev->next = next_h;
-      h = prev;   /* Because the loop sets prev to h */
-      continue;   /* With the next host */
+      continue;   /* With the next host, leave prev unchanged */
       }
 
     if (hff_code == hff_pass) return PASS;
@@ -213,6 +214,12 @@ for (h = addr->host_list; h != NULL; prev = h, h = next_h)
       }
     self_send = TRUE;
     }
+
+  /* Ensure that prev is the host before next_h; this will not be h if a lookup
+  found multiple addresses or multiple MX records. */
+
+  prev = h;
+  while (prev->next != next_h) prev = prev->next;
   }
 
 return OK;