Here's an updated patch with proper headers. :)

Also, for background on the solution, see:
http://blog.netherlabs.nl/articles/2009/01/18/the-ultimate-so_linger-page-or-why-is-my-tcp-not-reliable

-- 
Kees Cook                                            @debian.org
Description: it is possible for the client side of the socket to miss data
 when the server uses close() immediately after the last write(). To avoid
 this, shutdown down the write side of the socket and wait for the client
 to close the connection (0 byte read) before closing the server side.
Author: Kees Cook <k...@debian.org>

Index: cyrus-sasl2-2.1.26.dfsg1/saslauthd/ipc_unix.c
===================================================================
--- cyrus-sasl2-2.1.26.dfsg1.orig/saslauthd/ipc_unix.c	2012-01-27 15:31:36.000000000 -0800
+++ cyrus-sasl2-2.1.26.dfsg1/saslauthd/ipc_unix.c	2015-02-07 02:09:41.432110469 -0800
@@ -217,6 +217,7 @@
 
 	int		rc;
 	int		conn_fd;
+	unsigned char	dummy;
 
 
 	while(1) {
@@ -261,6 +262,8 @@
 		    }
 		    
 		    do_request(conn_fd);
+		    shutdown(conn_fd, SHUT_WR);
+		    while (read(conn_fd, &dummy, 1) > 0) { }
 		    close(conn_fd);
 
 		    if(flags & DETACH_TTY) {
@@ -275,6 +278,8 @@
 		 * Normal prefork mode.
 		 *************************************************************/
 		do_request(conn_fd);
+		shutdown(conn_fd, SHUT_WR);
+		while (read(conn_fd, &dummy, 1) > 0) { }
 		close(conn_fd);
 	}
 

Reply via email to