Gitweb:
https://git.exim.org/exim.git/commitdiff/1bf08084e235d22625eb78f457d668064a1ce28b
Commit: 1bf08084e235d22625eb78f457d668064a1ce28b
Parent: a3da0b8f1ed51351bb3a6eaed2146fae4eebd35b
Author: Jeremy Harris <jgh146exb@???>
AuthorDate: Sat Nov 30 17:39:25 2019 +0000
Committer: Jeremy Harris <jgh146exb@???>
CommitDate: Sat Nov 30 17:39:25 2019 +0000
FreeBSD: fix sendfile shim
Broken-by: 7d758a6a68
---
doc/doc-txt/ChangeLog | 4 ++++
src/OS/os.c-FreeBSD | 12 +++++++-----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index 6419894..8a0b75e 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -213,6 +213,10 @@ JH/45 local_scan API: documented the current smtp_printf() call. This changed
adjustment for any calls to smtp_printf() to match the new function
signature; a FALSE value for the new argument is always safe.
+JH/46 FreeBSD: fix use of the sendfile() syscall. The shim was not updating
+ the file-offset (which the Linux syscall does, and exim expects); this
+ resulted in an indefinite loop.
+
Exim version 4.92
-----------------
diff --git a/src/OS/os.c-FreeBSD b/src/OS/os.c-FreeBSD
index 1261b85..4cc46c7 100644
--- a/src/OS/os.c-FreeBSD
+++ b/src/OS/os.c-FreeBSD
@@ -2,7 +2,7 @@
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) Jeremy Harris 1995 - 2018 */
+/* Copyright (c) Jeremy Harris 1995 - 2019 */
/* See the file NOTICE for conditions of use and distribution. */
/* FreeBSD-specific code. This is concatenated onto the generic
@@ -14,11 +14,13 @@ src/os.c file. */
*************/
ssize_t
-os_sendfile(int out, int in, off_t * off, size_t cnt)
+os_sendfile(int out, int in, off_t * offp, size_t cnt)
{
-off_t written;
-return sendfile(in, out, *off, cnt, NULL, &written, 0) < 0
- ? (ssize_t) -1 : (ssize_t) written;
+off_t loff = *offp, written;
+
+if (sendfile(in, out, loff, cnt, NULL, &written, 0) < 0) return (ssize_t)-1;
+*offp = loff + written;
+return (ssize_t)written;
}
/* End of os.c-Linux */