Check syscall return values.
[exim.git] / src / src / spool_out.c
index 5df2a414e98f7c196b723c6c3c5b2619a5e3ef12..ce25a564efd4d18c4c21fdc6e168bd21a771a0de 100644 (file)
@@ -93,10 +93,12 @@ double-check the mode because the group setting doesn't always get set
 automatically. */
 
 if (fd >= 0)
-  {
-  (void)fchown(fd, exim_uid, exim_gid);
-  (void)fchmod(fd, SPOOL_MODE);
-  }
+  if (fchown(fd, exim_uid, exim_gid) || fchmod(fd, SPOOL_MODE))
+    {
+    DEBUG(D_any) debug_printf("failed setting perms on %s\n", temp_name);
+    (void) close(fd); fd = -1;
+    Uunlink(temp_name);
+    }
 
 return fd;
 }