Copyright year updates (things touched in 2015)
[exim.git] / src / src / routers / iplookup.c
index 72392fd4d6b5940609210e68641e85e148291c73..310e4d66d48f8585462c40bbb17668e0667478bd 100644 (file)
@@ -1,10 +1,8 @@
-/* $Cambridge: exim/src/src/routers/iplookup.c,v 1.2 2005/01/04 10:00:44 ph10 Exp $ */
-
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2005 */
+/* Copyright (c) University of Cambridge 1995 - 2015 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 
@@ -137,15 +135,16 @@ iplookup_router_entry(
   router_instance *rblock,        /* data for this instantiation */
   address_item *addr,             /* address we are working on */
   struct passwd *pw,              /* passwd entry after check_local_user */
-  BOOL verify,                    /* TRUE when verifying */
+  int verify,                     /* v_none/v_recipient/v_sender/v_expn */
   address_item **addr_local,      /* add it to this if it's local */
   address_item **addr_remote,     /* add it to this if it's remote */
   address_item **addr_new,        /* put new addresses on here */
   address_item **addr_succeed)    /* put old address here on success */
 {
 uschar *query = NULL;
-uschar reply[256];
-uschar *hostname, *reroute, *domain, *listptr;
+uschar *reply;
+uschar *hostname, *reroute, *domain;
+const uschar *listptr;
 uschar host_buffer[256];
 host_item *host = store_get(sizeof(host_item));
 address_item *new_addr;
@@ -163,6 +162,8 @@ pw = pw;
 DEBUG(D_route) debug_printf("%s router called for %s: domain = %s\n",
   rblock->name, addr->address, addr->domain);
 
+reply = store_get(256);
+
 /* Build the query string to send. If not explicitly given, a default of
 "user@domain user@domain" is used. */
 
@@ -202,11 +203,12 @@ while ((hostname = string_nextinlist(&listptr, &sep, host_buffer,
   host->mx = MX_NONE;
   host->next = NULL;
 
-  if (string_is_ip_address(host->name, NULL))
+  if (string_is_ip_address(host->name, NULL) != 0)
     host->address = host->name;
   else
     {
-    int rc = host_find_byname(host, NULL, NULL, TRUE);
+/*XXX might want dnssec request/require on an iplookup router? */
+    int rc = host_find_byname(host, NULL, HOST_FIND_QUALIFY_SINGLE, NULL, TRUE);
     if (rc == HOST_FIND_FAILED || rc == HOST_FIND_AGAIN) continue;
     }
 
@@ -240,6 +242,7 @@ while ((hostname = string_nextinlist(&listptr, &sep, host_buffer,
 
     if (ip_connect(query_socket, host_af, h->address,ob->port, ob->timeout) < 0)
       {
+      close(query_socket);
       DEBUG(D_route)
         debug_printf("connection to %s failed: %s\n", h->address,
           strerror(errno));
@@ -251,7 +254,7 @@ while ((hostname = string_nextinlist(&listptr, &sep, host_buffer,
     if (send(query_socket, query, query_len, 0) < 0)
       {
       DEBUG(D_route) debug_printf("send to %s failed\n", h->address);
-      close(query_socket);
+      (void)close(query_socket);
       continue;
       }
 
@@ -259,7 +262,7 @@ while ((hostname = string_nextinlist(&listptr, &sep, host_buffer,
     next IP address. */
 
     count = ip_recv(query_socket, reply, sizeof(reply) - 1, ob->timeout);
-    close(query_socket);
+    (void)close(query_socket);
     if (count <= 0)
       {
       DEBUG(D_route) debug_printf("%s from %s\n", (errno == ETIMEDOUT)?
@@ -375,8 +378,11 @@ new_addr = deliver_make_addr(reroute, TRUE);
 new_addr->parent = addr;
 
 copyflag(new_addr, addr, af_propagate);
-new_addr->p = addr->p;
+new_addr->prop = addr->prop;
 
+if (addr->child_count == SHRT_MAX)
+  log_write(0, LOG_MAIN|LOG_PANIC_DIE, "%s router generated more than %d "
+    "child addresses for <%s>", rblock->name, SHRT_MAX, addr->address);
 addr->child_count++;
 new_addr->next = *addr_new;
 *addr_new = new_addr;
@@ -384,11 +390,11 @@ new_addr->next = *addr_new;
 /* Set up the errors address, if any, and the additional and removeable headers
 for this new address. */
 
-rc = rf_get_errors_address(addr, rblock, verify, &(new_addr->p.errors_address));
+rc = rf_get_errors_address(addr, rblock, verify, &new_addr->prop.errors_address);
 if (rc != OK) return rc;
 
-rc = rf_get_munge_headers(addr, rblock, &(new_addr->p.extra_headers),
-  &(new_addr->p.remove_headers));
+rc = rf_get_munge_headers(addr, rblock, &new_addr->prop.extra_headers,
+  &new_addr->prop.remove_headers);
 if (rc != OK) return rc;
 
 return OK;