Corrected several mis-calls of is_ip_address() that treated the result
[exim.git] / src / src / verify.c
index 0c1d6b0ebe3b0b56c987ce93f82db02e41affa3f..591c6c03df74e1011dcae89d980886ea7aa2b3ac 100644 (file)
@@ -1,10 +1,10 @@
-/* $Cambridge: exim/src/src/verify.c,v 1.7 2004/11/22 11:30:04 ph10 Exp $ */
+/* $Cambridge: exim/src/src/verify.c,v 1.10 2005/01/11 15:51:02 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2004 */
+/* Copyright (c) University of Cambridge 1995 - 2005 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 /* Functions concerned with verifying things. The original code for callout
@@ -1049,7 +1049,8 @@ while (addr_new != NULL)
             for (host = host_list; host != NULL; host = nexthost)
               {
               nexthost = host->next;
-              if (tf.gethostbyname || string_is_ip_address(host->name, NULL))
+              if (tf.gethostbyname || 
+                  string_is_ip_address(host->name, NULL) > 0)
                 (void)host_find_byname(host, NULL, &canonical_name, TRUE);
               else
                 {
@@ -1830,7 +1831,7 @@ if (*ss == '@')
 /* If the pattern is an IP address, optionally followed by a bitmask count, do
 a (possibly masked) comparision with the current IP address. */
 
-if (string_is_ip_address(ss, &maskoffset))
+if (string_is_ip_address(ss, &maskoffset) > 0)
   return (host_is_in_net(cb->host_address, ss, maskoffset)? OK : FAIL);
 
 /* If the item is of the form net[n]-lookup;<file|query> then it is a lookup on
@@ -2593,13 +2594,14 @@ while ((domain = string_nextinlist(&list, &sep, buffer, sizeof(buffer))) != NULL
   else
     {
     int keysep = 0;
+    BOOL defer = FALSE; 
     uschar *keydomain; 
     uschar keybuffer[256];
   
     while ((keydomain = string_nextinlist(&key, &keysep, keybuffer, 
             sizeof(keybuffer))) != NULL)
       {       
-      if (string_is_ip_address(keydomain, NULL))
+      if (string_is_ip_address(keydomain, NULL) > 0)
         {
         uschar keyrevadd[128];
         invert_address(keyrevadd, keydomain);
@@ -2625,11 +2627,17 @@ while ((domain = string_nextinlist(&list, &sep, buffer, sizeof(buffer))) != NULL
         dnslist_domain = string_copy(domain);
         HDEBUG(D_dnsbl) debug_printf("=> that means %s is listed at %s\n", 
           keydomain, domain);
+        return OK;   
         }
          
-      if (rc != FAIL) return rc;   /* OK or DEFER */
+      /* If the lookup deferred, remember this fact. We keep trying the rest
+      of the list to see if we get a useful result, and if we don't, we return
+      DEFER at the end. */
 
+      if (rc == DEFER) defer = TRUE;
       }    /* continue with next keystring domain/address */
+
+    if (defer) return DEFER;
     }  
   }        /* continue with next dnsdb outer domain */