[PATCH] Fix for hang-on-exit bug in OpenSSH-3.0.2p1

John Bowman bowman at math.ualberta.ca
Mon Jan 28 06:45:15 EST 2002


Here is a simpler patch (based on Markus Friedl's suggestion posted to this
list) to OpenSSH-3.0.2p1 to fix the hang-on-exit bug (Protocol 2 only). To
date, no data loss has been reported with this patch: it does not break ssh
or scp.

This patch should make OpenSSH work on all operating systems exactly as it
does under FreeBSD.

This patch and others are maintained on the 
http://www.math.ualberta.ca/imaging/snfs/

-- John Bowman
University of Alberta

diff -ur openssh-3.0.2p1/clientloop.c openssh-3.0.2p1J2/clientloop.c
--- openssh-3.0.2p1/clientloop.c	Sun Nov 11 17:06:33 2001
+++ openssh-3.0.2p1J2/clientloop.c	Sat Jan 19 15:55:44 2002
@@ -445,9 +445,12 @@
 		len = read(connection_in, buf, sizeof(buf));
 		if (len == 0) {
 			/* Received EOF.  The remote host has closed the connection. */
+/* This message duplicates the one already in client_loop(). */
+#if 0 
 			snprintf(buf, sizeof buf, "Connection to %.300s closed by remote host.\r\n",
 				 host);
 			buffer_append(&stderr_buffer, buf, strlen(buf));
+#endif
 			quit_pending = 1;
 			return;
 		}
diff -ur openssh-3.0.2p1/session.c openssh-3.0.2p1J2/session.c
--- openssh-3.0.2p1/session.c	Sat Dec  1 16:37:08 2001
+++ openssh-3.0.2p1J2/session.c	Sat Jan 19 15:56:32 2002
@@ -1929,6 +1929,8 @@
 	 */
 	if (c->ostate != CHAN_OUTPUT_CLOSED)
 		chan_write_failed(c);
+	if (s->ttyfd != -1 && c->istate == CHAN_INPUT_OPEN)
+		chan_read_failed(c);
 	s->chanid = -1;
 }
 



More information about the openssh-unix-dev mailing list