accept that in (normal) CRLF mode; this has been raised as a possible
attack scenario (under the name "smtp smuggling").
+JH/13 Add an fdatasync call for the received message data file in spool, before
+ loggging reception and sending the SMTP ack. Previously we only flushed
+ the stdio buffer so there was still the possibility of a disk error.
+
Exim version 4.97
#endif
#ifdef ENABLE_DISABLE_FSYNC
-# define EXIMfsync(f) (disable_fsync? 0 : fsync(f))
+# define EXIMfsync(f) (disable_fsync ? 0 : fsync(f))
#else
# define EXIMfsync(f) fsync(f)
#endif
receive_messagecount++;
-if (fflush(spool_data_file))
+if ( fflush(spool_data_file)
+#if _POSIX_C_SOURCE >= 199309L || _XOPEN_SOURCE >= 500
+# ifdef ENABLE_DISABLE_FSYNC
+ || !disable_fsync && fdatasync(data_fd)
+# else
+ || fdatasync(data_fd)
+# endif
+#endif
+ )
{
errmsg = string_sprintf("Spool write error: %s", strerror(errno));
log_write(0, LOG_MAIN, "%s\n", errmsg);