Check syscall return values.
[exim.git] / src / src / receive.c
index 8ac381addd7670f3d97abdf652cc80f500d01189..1943a74c75d02e8aef718bc2e24c7896c5162012 100644 (file)
@@ -936,7 +936,6 @@ add_acl_headers(uschar *acl_name)
 {
 header_line *h, *next;
 header_line *last_received = NULL;
-int sep = ':';
 
 if (acl_removed_headers != NULL)
   {
@@ -944,7 +943,6 @@ if (acl_removed_headers != NULL)
 
   for (h = header_list; h != NULL; h = h->next)
     {
-    int i;
     uschar *list;
     BOOL include_header;
 
@@ -1403,7 +1401,7 @@ BOOL resents_exist = FALSE;
 uschar *resent_prefix = US"";
 uschar *blackholed_by = NULL;
 uschar *blackhole_log_msg = US"";
-int  cutthrough_done;
+int  cutthrough_done = 0;
 
 flock_t lock_data;
 error_block *bad_addresses = NULL;
@@ -2795,7 +2793,10 @@ if (data_fd < 0)
 /* Make sure the file's group is the Exim gid, and double-check the mode
 because the group setting doesn't always get set automatically. */
 
-(void)fchown(data_fd, exim_uid, exim_gid);
+if (fchown(data_fd, exim_uid, exim_gid))
+  log_write(0, LOG_MAIN|LOG_PANIC_DIE,
+    "Failed setting ownership on spool file %s: %s",
+    spool_name, strerror(errno));
 (void)fchmod(data_fd, SPOOL_MODE);
 
 /* We now have data file open. Build a stream for it and lock it. We lock only
@@ -2825,7 +2826,7 @@ if (next != NULL)
   {
   uschar *s = next->text;
   int len = next->slen;
-  (void)fwrite(s, 1, len, data_file);
+  len = fwrite(s, 1, len, data_file);  len = len; /* compiler quietening */
   body_linecount++;                 /* Assumes only 1 line */
   }
 
@@ -3604,7 +3605,11 @@ if (sender_host_authenticated != NULL)
   {
   s = string_append(s, &size, &sptr, 2, US" A=", sender_host_authenticated);
   if (authenticated_id != NULL)
+    {
     s = string_append(s, &size, &sptr, 2, US":", authenticated_id);
+    if (log_extra_selector & LX_smtp_mailauth  &&  authenticated_sender != NULL)
+      s = string_append(s, &size, &sptr, 2, US":", authenticated_sender);
+    }
   }
 
 sprintf(CS big_buffer, "%d", msg_size);
@@ -3614,10 +3619,11 @@ s = string_append(s, &size, &sptr, 2, US" S=", big_buffer);
    0 ... no BODY= used
    7 ... 7BIT
    8 ... 8BITMIME */
-if (log_extra_selector & LX_8bitmime) {
+if (log_extra_selector & LX_8bitmime)
+  {
   sprintf(CS big_buffer, "%d", body_8bitmime);
   s = string_append(s, &size, &sptr, 2, US" M8S=", big_buffer);
-}
+  }
 
 /* If an addr-spec in a message-id contains a quoted string, it can contain
 any characters except " \ and CR and so in particular it can contain NL!
@@ -3799,6 +3805,7 @@ for this message. */
 
    XXX We do not handle queue-only, freezing, or blackholes.
 */
+cutthrough_done = 0;
 if(cutthrough_fd >= 0)
   {
   uschar * msg= cutthrough_finaldot(); /* Ask the target system to accept the messsage */
@@ -3820,8 +3827,6 @@ if(cutthrough_fd >= 0)
       break;
     }
   }
-else
-  cutthrough_done = 0;
 
 if(smtp_reply == NULL)
   {