1
0
mirror of https://github.com/osmarks/ngircd.git synced 2024-12-12 09:50:29 +00:00

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().
This commit is contained in:
michi 2020-04-14 17:41:52 +02:00 committed by Alexander Barton
parent 13b8324c4a
commit 04de1423eb

View File

@ -1272,6 +1272,9 @@ Handle_Write( CONN_ID Idx )
if (errno == EAGAIN || errno == EINTR) if (errno == EAGAIN || errno == EINTR)
return true; 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)) if (!Conn_OPTION_ISSET(&My_Connections[Idx], CONN_ISCLOSING))
Log(LOG_ERR, Log(LOG_ERR,
"Write error on connection %d (socket %d): %s!", "Write error on connection %d (socket %d): %s!",
@ -1279,7 +1282,7 @@ Handle_Write( CONN_ID Idx )
else else
LogDebug("Recursive write error on connection %d (socket %d): %s!", LogDebug("Recursive write error on connection %d (socket %d): %s!",
Idx, My_Connections[Idx].sock, strerror(errno)); Idx, My_Connections[Idx].sock, strerror(errno));
Conn_Close(Idx, "Write error", NULL, false);
return false; return false;
} }