ports/167380: updated netatalk 2.2.2 breaks file transfers due to incorrect use of sendfile

Daniel Becker razzfazz at gmail.com
Fri Apr 27 22:10:10 UTC 2012


>Number:         167380
>Category:       ports
>Synopsis:       updated netatalk 2.2.2 breaks file transfers due to incorrect use of sendfile
>Confidential:   no
>Severity:       critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Apr 27 22:10:10 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Daniel Becker
>Release:        9.0-RELEASE
>Organization:
>Environment:
FreeBSD razzems.Stanford.EDU 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan  3 07:46:30 UTC 2012     root at farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
After the recent update to version 2.2.2, all file transfers that use sendfile return corrupt data and/or terminate the connection.

This appears to be a known issue in 2.2.2 that is caused by improper use of FreeBSD's sendfile; it was fixed upstream on Feb 9:

<http://netatalk.git.sourceforge.net/git/gitweb.cgi?p=netatalk/netatalk;a=commit;h=d24a954821229e8835acb6d629ef1f09a4441e8b>

This will apparently be rolled into 2.2.3 upstream; however, since 2.2.2 in its current state for all intents and purposes does not work on FreeBSD, please consider integrating the linked patch into the FreeBSD port.
>How-To-Repeat:
Read any file larger than a few kilobytes from a Netatalk share.
>Fix:
Backport patch from upstream:

<http://netatalk.git.sourceforge.net/git/gitweb.cgi?p=netatalk/netatalk;a=commit;h=d24a954821229e8835acb6d629ef1f09a4441e8b>


Patch attached with submission follows:

>From d24a954821229e8835acb6d629ef1f09a4441e8b Mon Sep 17 00:00:00 2001
From: Frank Lahm <franklahm at googlemail.com>
Date: Thu, 9 Feb 2012 15:39:08 +0100
Subject: [PATCH] Fix broken sendfile on FreeBSD, from Denis Ahrens

---
 NEWS                           |    1 +
 libatalk/adouble/ad_sendfile.c |   11 ++++++++++-
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index 2ad321a..88d44f7 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Changes in 2.2.3
 * UPD: based on Unicode 6.1.0
 * UPD: experimental systemd service files: always run both afpd and cnid_metad
 * UPD: afpd: Ensure our umask is not altered by eg pam_umask
+* FIX: afpd: sendfile() on FreeBSD was broken, courtesy of Denis Ahrens
 
 Changes in 2.2.2
 ================
diff --git a/libatalk/adouble/ad_sendfile.c b/libatalk/adouble/ad_sendfile.c
index aabb61c..0e7b278 100644
--- a/libatalk/adouble/ad_sendfile.c
+++ b/libatalk/adouble/ad_sendfile.c
@@ -67,7 +67,16 @@ ssize_t sys_sendfile(int tofd, int fromfd, off_t *offset, size_t count)
 #include <sys/uio.h>
 ssize_t sys_sendfile(int tofd, int fromfd, off_t *offset, size_t count)
 {
-  return sendfile(fromfd, tofd, *offset, count, NULL, offset, 0);
+    off_t len;
+    int ret;
+
+    ret = sendfile(fromfd, tofd, *offset, count, NULL, &len, 0);
+
+    *offset += len;
+
+    if (ret != 0)
+        return -1;
+    return len;
 }
 
 #else
-- 
1.7.4.1



>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list