summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authormichi <michi+ngircd@dataswamp.org>2020-04-14 17:41:52 +0200
committerAlexander Barton <alex@barton.de>2020-04-20 00:20:46 +0200
commit04de1423eb26da60c192d343a7e7a6bcda2aca37 (patch)
treede8b39f00458c8915e4c21e10f18e9eb9d2c05d7 /src
parent13b8324c4a6f46e18e58883630808bc8c4ed9e80 (diff)
downloadngircd-04de1423eb26da60c192d343a7e7a6bcda2aca37.tar.gz
ngircd-04de1423eb26da60c192d343a7e7a6bcda2aca37.zip
Fix recursion bug on write error
Depending on the stack size, too many clients on the same channel
quitting at the same time would trigger a crash due to too many
recursive calls to Conn_Close().
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/conn.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index e14e6c08..92d9939a 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -1272,6 +1272,9 @@ Handle_Write( CONN_ID Idx )
 		if (errno == EAGAIN || errno == EINTR)
 			return true;
 
+		/* Log write errors but do not close the connection yet.
+		 * Calling Conn_Close() now could result in too many recursive calls.
+		 */
 		if (!Conn_OPTION_ISSET(&My_Connections[Idx], CONN_ISCLOSING))
 			Log(LOG_ERR,
 			    "Write error on connection %d (socket %d): %s!",
@@ -1279,7 +1282,7 @@ Handle_Write( CONN_ID Idx )
 		else
 			LogDebug("Recursive write error on connection %d (socket %d): %s!",
 				 Idx, My_Connections[Idx].sock, strerror(errno));
-		Conn_Close(Idx, "Write error", NULL, false);
+
 		return false;
 	}