Author: Gte <gte@atomicrevs.demon.co.uk>
authorBleep <twhelvey1@home.com>
Tue, 14 Mar 2000 01:35:20 +0000 (01:35 +0000)
committerBleep <twhelvey1@home.com>
Tue, 14 Mar 2000 01:35:20 +0000 (01:35 +0000)
Log message:
Bugfix: uninitialized variable causing getsockname to fail and trigger
other bugs.

In s_auth.c:103, insert:
  len = sizeof(sock);

just before:
  if (getsockname(cptr->fd, (struct sockaddr *)&sock, &len) == -1
      || (sock.sin_port = 0)    /* Reset sin_port and let OS choose
      || bind(cptr->authfd, (struct sockaddr *)&sock, len) == -1)

This initialises len correctly, and everything then works :)

--
On a sidenote, I noticed the result of this failure is that the clients
socket is closed, surely closing the authfd would be better than just
cutting off the client? :P
The authfd then never gets closed, and also the ircd hits 100% cpu,
presumably because this client is still in a list somewhere, but with a
closed Fd, maybe, not looked :)

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@22 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

.patches
ChangeLog
ircd/s_auth.c

index 4557293d74a52f4ddb05216071bbb16ba74f762e..a00f8d8f980e36a00afb69ebd7289f90c0d3bef6 100644 (file)
--- a/.patches
+++ b/.patches
@@ -1 +1 @@
-ircu2.10.07+.07
+ircu2.10.07+.08
index 88cee38582630c0d3d125ffeb770c0c6e64697b8..2b895a45473807731e20efd2832abc3e2bd797f1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,16 @@
 #
 # ChangeLog for Undernet ircu Servers
 #
-# $Id: ChangeLog,v 1.10 2000-03-07 00:56:36 bleep Exp $
+# $Id: ChangeLog,v 1.11 2000-03-14 01:35:20 bleep Exp $
 #
 # Please insert new entries on the top of the list, a one or two line comment
 # is sufficient. Please include your name on the entries we know who to blame.
 # Please keep lines < 80 chars.
 #-------------------------------------------------------------------------------
+* s_auth.c (start_auth): Bugfix - uninitialized len variable caused binding to
+  client local address to fail, initialize to sizeof(struct sockaddr_in).
+  Clean up leaking file descriptors, set authfd to -1 when closed for error.
+  Bug stomping and fix by Gte. --Bleep
 * Add Run's pline patch. --Run
 * channel.c (send_channel_modes): send modes for second line for channels with
   a lot of ops. --Gte
index a2a7d111b84cbb399390e14a79d93c325290b5d5..f0ef3623dede4973b0a320942427eed07236ca93 100644 (file)
@@ -66,7 +66,8 @@ RCSTAG_CC("$Id$");
 void start_auth(aClient *cptr)
 {
   struct sockaddr_in sock;
-  int err, len;
+  int err;
+  int len = sizeof(struct sockaddr_in);
 
   Debug((DEBUG_NOTICE, "start_auth(%p) fd %d status %d",
       cptr, cptr->fd, cptr->status));
@@ -96,6 +97,7 @@ void start_auth(aClient *cptr)
   {
     sendto_ops("Can't allocate fd for auth on %s", get_client_name(cptr, TRUE));
     close(cptr->authfd);
+    cptr->authfd = -1;
     return;
   }
 
@@ -106,7 +108,14 @@ void start_auth(aClient *cptr)
       || bind(cptr->authfd, (struct sockaddr *)&sock, len) == -1)
   {
     report_error("binding auth stream socket %s: %s", cptr);
-    close(cptr->fd);
+    close(cptr->authfd);
+    cptr->authfd = -1;
+    /*
+     * fsck can't return exit_client here ... let read_message
+     * do it when we get done here. At any rate this error is
+     * fatal for the client, mark it dead.
+     */
+    cptr->flags |= FLAGS_DEADSOCKET;
     return;
   }