update to pre-4.87 master
[exim.git] / src / src / spool_mbox.c
index 635fb8df1c4085150f7d5b51f0d55920154b3e60..8d04f8e17ea5f77030255c320a4c88de7c1ee1ab 100644 (file)
@@ -2,7 +2,7 @@
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) Tom Kistner <tom@duncanthrax.net> 2003-???? */
+/* Copyright (c) Tom Kistner <tom@duncanthrax.net> 2003 - 2015 */
 /* License: GPL */
 
 /* Code for setting up a MBOX style spool file inside a /scan/<msgid>
@@ -26,7 +26,9 @@ uschar spooled_message_id[17];
 /* returns a pointer to the FILE, and puts the size in bytes into mbox_file_size
  * normally, source_file_override is NULL */
 
-FILE *spool_mbox(unsigned long *mbox_file_size, uschar *source_file_override) {
+FILE *
+spool_mbox(unsigned long *mbox_file_size, const uschar *source_file_override)
+{
   uschar message_subdir[2];
   uschar buffer[16384];
   uschar *temp_string;
@@ -56,7 +58,7 @@ FILE *spool_mbox(unsigned long *mbox_file_size, uschar *source_file_override) {
     mbox_file = modefopen(mbox_path, "wb", SPOOL_MODE);
     if (mbox_file == NULL) {
       log_write(0, LOG_MAIN|LOG_PANIC, "%s", string_open_failed(errno,
-        "scan file %s", mbox_file));
+        "scan file %s", mbox_path));
       goto OUT;
     };
 
@@ -96,7 +98,11 @@ FILE *spool_mbox(unsigned long *mbox_file_size, uschar *source_file_override) {
     };
 
     /* End headers */
-    (void)fwrite("\n", 1, 1, mbox_file);
+    if (fwrite("\n", 1, 1, mbox_file) != 1) {
+      log_write(0, LOG_MAIN|LOG_PANIC, "Error/short write while writing \
+        message headers to %s", mbox_path);
+      goto OUT;
+    }
 
     /* copy body file */
     if (source_file_override == NULL) {
@@ -155,7 +161,7 @@ FILE *spool_mbox(unsigned long *mbox_file_size, uschar *source_file_override) {
   if (Ustat(mbox_path, &statbuf) != 0 ||
       (yield = Ufopen(mbox_path,"rb")) == NULL) {
     log_write(0, LOG_MAIN|LOG_PANIC, "%s", string_open_failed(errno,
-      "scan file %s", mbox_file));
+      "scan file %s", mbox_path));
     goto OUT;
   };