From 4af8b1159c020faa1a1d2f273728f670630a21c6 Mon Sep 17 00:00:00 2001 From: Bleep Date: Tue, 14 Mar 2000 01:35:20 +0000 Subject: [PATCH] Author: Gte 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 | 2 +- ChangeLog | 6 +++++- ircd/s_auth.c | 13 +++++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.patches b/.patches index 4557293..a00f8d8 100644 --- a/.patches +++ b/.patches @@ -1 +1 @@ -ircu2.10.07+.07 +ircu2.10.07+.08 diff --git a/ChangeLog b/ChangeLog index 88cee38..2b895a4 100644 --- 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 diff --git a/ircd/s_auth.c b/ircd/s_auth.c index a2a7d11..f0ef362 100644 --- a/ircd/s_auth.c +++ b/ircd/s_auth.c @@ -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; } -- 2.20.1