[dovecot-cvs] dovecot/src/lib sendfile-util.c,1.11,1.12

cras at dovecot.org cras at dovecot.org
Sat Jan 15 20:15:55 EET 2005


Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv27168

Modified Files:
	sendfile-util.c 
Log Message:
Don't call sendfile() if count=0. With FreeBSD this fixes an assert crash.



Index: sendfile-util.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/sendfile-util.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- sendfile-util.c	13 Oct 2004 23:36:21 -0000	1.11
+++ sendfile-util.c	15 Jan 2005 18:15:52 -0000	1.12
@@ -22,6 +22,9 @@
 	off_t safe_offset;
 	ssize_t ret;
 
+	if (count == 0)
+		return 0;
+
 	/* make sure given offset fits into off_t */
 	if (sizeof(off_t) * CHAR_BIT == 32) {
 		/* 32bit off_t */
@@ -64,6 +67,12 @@
 
 	i_assert(count <= SSIZE_T_MAX);
 
+	if (count == 0) {
+		/* if count=0 is passed to sendfile(), it sends everything
+		   from in_fd until EOF. We don't want that. */
+		return 0;
+	}
+
 	memset(&hdtr, 0, sizeof(hdtr));
 	ret = sendfile(in_fd, out_fd, *offset, count, &hdtr, &sbytes, 0);
 
@@ -93,6 +102,9 @@
 
 	i_assert(count <= SSIZE_T_MAX);
 
+	if (count == 0)
+		return 0;
+
 	/* NOTE: if outfd is not a socket, some Solaris versions will
 	   kernel panic */
 



More information about the dovecot-cvs mailing list