Tidying: coverity issues
[exim.git] / src / src / deliver.c
index 956a33250e8fd58d8c3b2083ee1f315a71c79e66..dc616a1db8dd5b989618c132f24a294bd17e9daf 100644 (file)
@@ -446,6 +446,10 @@ while (one && two)
     two = end_two;
     }
 
+  /* if the names matched but ports do not, mismatch */
+  else if (one->port != two->port)
+    return FALSE;
+
   /* Hosts matched */
 
   one = one->next;
@@ -715,7 +719,7 @@ host_item * h = addr->host_used;
 s = string_append(s, sp, pp, 2, US" H=", h->name);
 
 if (LOGGING(dnssec) && h->dnssec == DS_YES)
-  s = string_cat(s, sp, pp, US" DS");
+  s = string_catn(s, sp, pp, US" DS", 3);
 
 s = string_append(s, sp, pp, 3, US" [", h->address, US"]");
 
@@ -1139,8 +1143,11 @@ else
 
 #ifndef DISABLE_PRDR
   if (addr->flags & af_prdr_used)
-    s = string_append(s, &size, &ptr, 1, US" PRDR");
+    s = string_catn(s, &size, &ptr, US" PRDR", 5);
 #endif
+
+  if (addr->flags & af_chunking_used)
+    s = string_catn(s, &size, &ptr, US" K", 2);
   }
 
 /* confirmation message (SMTP (host_used) and LMTP (driver_name)) */
@@ -1594,7 +1601,7 @@ else
   force the af_ignore_error flag. This will cause the address to be discarded
   later (with a log entry). */
 
-  if (sender_address[0] == 0 && message_age >= ignore_bounce_errors_after)
+  if (!*sender_address && message_age >= ignore_bounce_errors_after)
     setflag(addr, af_ignore_error);
 
   /* Freeze the message if requested, or if this is a bounce message (or other
@@ -3482,6 +3489,10 @@ while (!done)
     break;
 #endif
 
+    case 'K':
+    addr->flags |= af_chunking_used;
+    break;
+
     case 'D':
     if (!addr) goto ADDR_MISMATCH;
     memcpy(&(addr->dsn_aware), ptr, sizeof(addr->dsn_aware));
@@ -4414,6 +4425,7 @@ for (delivery_count = 0; addr_remote; delivery_count++)
       ok = FALSE;
       for (h = addr->host_list; h; h = h->next)
         if (Ustrcmp(h->name, continue_hostname) == 0)
+/*XXX should also check port here */
           { ok = TRUE; break; }
       }
 
@@ -4437,9 +4449,13 @@ for (delivery_count = 0; addr_remote; delivery_count++)
         addr_fallback = addr;
         }
 
-      else if (next)
+      else
        {
-       while (next->next) next = next->next;
+       for (next = addr; ; next = next->next)
+         {
+         DEBUG(D_deliver) debug_printf(" %s to def list\n", next->address);
+          if (!next->next) break;
+         }
        next->next = addr_defer;
        addr_defer = addr;
        }
@@ -4720,6 +4736,9 @@ for (delivery_count = 0; addr_remote; delivery_count++)
        rmt_dlv_checked_write(fd, 'P', '0', NULL, 0);
 #endif
 
+      if (addr->flags & af_chunking_used)
+       rmt_dlv_checked_write(fd, 'K', '0', NULL, 0);
+
       memcpy(big_buffer, &addr->dsn_aware, sizeof(addr->dsn_aware));
       rmt_dlv_checked_write(fd, 'D', '0', big_buffer, sizeof(addr->dsn_aware));
       DEBUG(D_deliver) debug_printf("DSN write: addr->dsn_aware = %d\n", addr->dsn_aware);
@@ -5559,10 +5578,8 @@ if (deliver_freeze)
   ignore timer is exceeded. The message will be discarded if this delivery
   fails. */
 
-  else if (sender_address[0] == 0 && message_age >= ignore_bounce_errors_after)
-    {
+  else if (!*sender_address && message_age >= ignore_bounce_errors_after)
     log_write(0, LOG_MAIN, "Unfrozen by errmsg timer");
-    }
 
   /* If this is a bounce message, or there's no auto thaw, or we haven't
   reached the auto thaw time yet, and this delivery is not forced by an admin
@@ -7100,7 +7117,7 @@ if (addr_senddsn)
     FILE *f = fdopen(fd, "wb");
     /* header only as required by RFC. only failure DSN needs to honor RET=FULL */
     uschar * bound;
-    transport_ctx tctx;
+    transport_ctx tctx = {0};
 
     DEBUG(D_deliver)
       debug_printf("sending error message to: %s\n", sender_address);
@@ -7180,7 +7197,6 @@ if (addr_senddsn)
 
     /* Write the original email out */
 
-    bzero(&tctx, sizeof(tctx));
     tctx.options = topt_add_return_path | topt_no_body;
     transport_write_message(fileno(f), &tctx, 0);
     fflush(f);
@@ -7638,16 +7654,14 @@ wording. */
       transport_filter_argv = NULL;   /* Just in case */
       return_path = sender_address;   /* In case not previously set */
        {                             /* Dummy transport for headers add */
-       transport_ctx * tctx =
-         store_get(sizeof(*tctx) + sizeof(transport_instance));
-       transport_instance * tb = (transport_instance *)(tctx+1);
+       transport_ctx tctx = {0};
+       transport_instance tb = {0};
 
-       bzero(tctx, sizeof(*tctx)+sizeof(*tb));
-       tctx->tblock = tb;
-       tctx->options = topt;
-       tb->add_headers = dsnnotifyhdr;
+       tctx.tblock = &tb;
+       tctx.options = topt;
+       tb.add_headers = dsnnotifyhdr;
 
-       transport_write_message(fileno(f), tctx, 0);
+       transport_write_message(fileno(f), &tctx, 0);
        }
       fflush(f);
 
@@ -7964,9 +7978,7 @@ else if (addr_defer != (address_item *)(+1))
         FILE *wmf = NULL;
         FILE *f = fdopen(fd, "wb");
        uschar * bound;
-       transport_ctx tctx;
-
-       bzero(&tctx, sizeof(tctx));
+       transport_ctx tctx = {0};
 
         if (warn_message_file)
           if (!(wmf = Ufopen(warn_message_file, "rb")))
@@ -8282,6 +8294,9 @@ if (!regex_STARTTLS) regex_STARTTLS =
   regex_must_compile(US"\\n250[\\s\\-]STARTTLS(\\s|\\n|$)", FALSE, TRUE);
 #endif
 
+if (!regex_CHUNKING) regex_CHUNKING =
+  regex_must_compile(US"\\n250[\\s\\-]CHUNKING(\\s|\\n|$)", FALSE, TRUE);
+
 #ifndef DISABLE_PRDR
 if (!regex_PRDR) regex_PRDR =
   regex_must_compile(US"\\n250[\\s\\-]PRDR(\\s|\\n|$)", FALSE, TRUE);