Avoid crashes when handling ET_EOF for IAuth stderr before stdout.
authorMichael Poole <mdpoole@troilus.org>
Tue, 6 Aug 2013 03:01:51 +0000 (23:01 -0400)
committerMichael Poole <mdpoole@troilus.org>
Tue, 6 Aug 2013 03:01:51 +0000 (23:01 -0400)
Because iauth_stderr_callback() ignores ET_DESTROY, we should destroy
IAuth stderr first.  Then, when iauth_sock_callback() handles ET_DESTROY
for the stdout socket, it can respawn the socket without generating a
second ET_DESTROY for stderr.

ircd/s_auth.c

index 924bd50ab13dcc36df46936301348155a327312d..95e7d5ca1741f7c17f267c68aeeb53933e3b0b27 100644 (file)
@@ -1373,19 +1373,19 @@ static void iauth_disconnect(struct IAuth *iauth)
   if (iauth == NULL)
     return;
 
-  /* Close main socket. */
-  if (s_fd(i_socket(iauth)) != -1) {
-    close(s_fd(i_socket(iauth)));
-    socket_del(i_socket(iauth));
-    s_fd(i_socket(iauth)) = -1;
-  }
-
   /* Close error socket. */
   if (s_fd(i_stderr(iauth)) != -1) {
     close(s_fd(i_stderr(iauth)));
     socket_del(i_stderr(iauth));
     s_fd(i_stderr(iauth)) = -1;
   }
+
+  /* Close main socket. */
+  if (s_fd(i_socket(iauth)) != -1) {
+    close(s_fd(i_socket(iauth)));
+    socket_del(i_socket(iauth));
+    s_fd(i_socket(iauth)) = -1;
+  }
 }
 
 /** Close all %IAuth connections marked as closing. */