[exim-cvs] FreeBSD: fix sendfile shim

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Exim Git Commits Mailing List
Datum:  
To: exim-cvs
Betreff: [exim-cvs] FreeBSD: fix sendfile shim
Gitweb: https://git.exim.org/exim.git/commitdiff/ab6b4fdbded98ca6d185409e3c419ab1bfb26422
Commit:     ab6b4fdbded98ca6d185409e3c419ab1bfb26422
Parent:     adf703b6582dcb89a2592b3519fd2e5ed30682f3
Author:     Jeremy Harris <jgh146exb@???>
AuthorDate: Sat Dec 7 22:07:02 2019 +0000
Committer:  Jeremy Harris <jgh146exb@???>
CommitDate: Sat Dec 7 22:07:02 2019 +0000


    FreeBSD: fix sendfile shim
---
 doc/doc-txt/ChangeLog |  4 ++++
 src/OS/Makefile-Base  | 28 ++++------------------------
 src/OS/os.c-FreeBSD   | 12 +++++++-----
 3 files changed, 15 insertions(+), 29 deletions(-)


diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index a8cd823..9f18a20 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -218,6 +218,10 @@ JH/43 Bug 2465: Fix taint-handling in dsearch lookup.  Previously a nontainted
       buffer was used for the filename, resulting in a trap when tainted
       arguments (eg. $domain) were used.


+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/Makefile-Base b/src/OS/Makefile-Base
index 9ecde1d..36af830 100644
--- a/src/OS/Makefile-Base
+++ b/src/OS/Makefile-Base
@@ -79,23 +79,8 @@ Makefile: ../OS/Makefile-Base ../OS/Makefile-Default \

# Build (link) the os.h file

-#os.h:    $(SCRIPTS)/Configure-os.h \
-#    $(O)/os.h-AIX        $(O)/os.h-BSDI    $(O)/os.h-cygwin \
-#    $(O)/os.h-Darwin    $(O)/os.h-DGUX    $(O)/os.h-DragonFly \
-#    $(O)/os.h-FreeBSD    $(O)/os.h-GNU    $(O)/os.h-GNUkFreeBSD \
-#    $(O)/os.h-GNUkNetBSD    $(O)/os.h-HI-OSF \
-#    $(O)/os.h-HI-UX        $(O)/os.h-HP-UX    $(O)/os.h-HP-UX-9 \
-#    $(O)/os.h-IRIX        $(O)/os.h-IRIX6    $(O)/os.h-IRIX632 \
-#    $(O)/os.h-IRIX65    $(O)/os.h-Linux    $(O)/os.h-mips \
-#    $(O)/os.h-NetBSD    $(O)/os.h-NetBSD-a.out \
-#    $(O)/os.h-OpenBSD    $(O)/os.h-OpenUNIX    $(O)/os.h-OSF1 \
-#    $(O)/os.h-QNX        $(O)/os.h-SCO        $(O)/os.h-SCO_SV \
-#    $(O)/os.h-SunOS4    $(O)/os.h-SunOS5    $(O)/os.h-SunOS5-hal \
-#    $(O)/os.h-ULTRIX    $(O)/os.h-UNIX_SV \
-#    $(O)/os.h-Unixware7    $(O)/os.h-USG
-#    $(SHELL) $(SCRIPTS)/Configure-os.h
-
 os.h:    $(SCRIPTS)/Configure-os.h \
+    $(O)/os.h-Darwin    \
     $(O)/os.h-FreeBSD    \
     $(O)/os.h-GNU        \
     $(O)/os.h-Linux        \
@@ -105,17 +90,12 @@ os.h:    $(SCRIPTS)/Configure-os.h \


# Build the os.c file

-#os.c:   ../src/os.c \
-#    $(SCRIPTS)/Configure-os.c \
-#    $(O)/os.c-cygwin    $(O)/os.c-GNU    $(O)/os.c-HI-OSF \
-#    $(O)/os.c-IRIX        $(O)/os.c-IRIX6    $(O)/os.c-IRIX632 \
-#    $(O)/os.c-IRIX65    $(O)/os.c-Linux    $(O)/os.c-OSF1
-#    $(SHELL) $(SCRIPTS)/Configure-os.c
-
 os.c:   ../src/os.c \
     $(SCRIPTS)/Configure-os.c \
+    $(O)/os.c-FreeBSD    \
     $(O)/os.c-GNU        \
-    $(O)/os.c-Linux
+    $(O)/os.c-Linux        \
+    $(O)/os.c-SunOS5
     $(SHELL) $(SCRIPTS)/Configure-os.c


 # Build the config.h file.
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 */