[gnu.emacs.bug] movemail

stoller@CS.UTAH.EDU (Leigh B. Stoller) (10/29/88)

Gnu 18.44, but the same applies to 18.52. The diffs are from 18.44.

In the movemail.c function no checking is done on the close of the
outbox before the inbox is zapped. This is critical in an NFS
environment, when a write of the outbox could fail for any number
of reasons. In general, it is good practice to check anyway.

Leigh

*** /tmp/,RCSt1005423	Fri Oct 28 11:42:09 1988
--- /tmp/,RCSt2005423	Fri Oct 28 11:42:10 1988
***************
*** 168,173 ****
--- 168,185 ----
  	break;
      }
  
+   /* Check to make sure no errors before we zap the inbox.
+    */
+   if (close(outdesc) != 0) {
+     int saved_errno = errno;
+     (void) unlink (outname);
+ #ifndef MAIL_USE_FLOCK
+     (void) unlink (lockname);
+ #endif /* not MAIL_USE_FLOCK */ 
+     errno = saved_errno;
+     pfatal_with_name (outname);
+   }
+     
  #ifdef MAIL_USE_FLOCK
  #ifdef STRIDE
     /* Stride has flock(), but no ftruncate().  This mess will do. */
***************
*** 177,183 ****
  #endif /* STRIDE */
  #endif /* MAIL_USE_FLOCK */
    close (indesc);
-   close (outdesc);
  #ifndef MAIL_USE_FLOCK
    /* Delete the input file; if we can't, at least get rid of its contents.  */
    if (unlink (inname) < 0)
--- 189,194 ----