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
-ircu2.10.07+.07
+ircu2.10.07+.08
#
# 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
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));
{
sendto_ops("Can't allocate fd for auth on %s", get_client_name(cptr, TRUE));
close(cptr->authfd);
+ cptr->authfd = -1;
return;
}
|| 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;
}