From e372e9118de10a6f87bbc77e3664de2f7b3bfe79 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Wed, 11 Sep 2019 14:36:12 +0200 Subject: [PATCH] Move cptr->count to cptr->local->identbufcnt since this only used by the ident reading code nowadays, which obviously only happens for locally connected users. --- include/struct.h | 6 +----- src/bsd.c | 12 ++++++------ src/modules/stats.c | 4 ++-- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/include/struct.h b/include/struct.h index b2c77d27f..0d85ca690 100644 --- a/include/struct.h +++ b/include/struct.h @@ -933,7 +933,6 @@ struct Client { char info[REALLEN + 1]; /**< Additional client information text. For persons this is gecos/realname */ char id[IDLEN + 1]; /**< Unique ID: SID or UID */ Client *srvptr; /**< Server on where this client is connected to (can be &me) */ - int count; /**< Amount of data in buffer */ char *ip; /**< IP address of user or server (never NULL) */ ModData moddata[MODDATA_MAX_CLIENT]; /**< Client attached module data, used by the ModData system */ }; @@ -985,12 +984,9 @@ struct LocalClient { u_short sasl_cookie; char *sni_servername; /**< Servername as sent by client during SNI (otherwise NULL) */ int cap_protocol; /**< CAP protocol in use. At least 300 for any CAP capable client. 302 for 3.2, etc.. */ + int identbufcnt; /**< Counter for 'ident' reading code */ }; - -#define CLIENT_LOCAL_SIZE sizeof(Client) -#define CLIENT_REMOTE_SIZE offsetof(Client,count) - struct MessageTag { MessageTag *prev, *next; char *name; diff --git a/src/bsd.c b/src/bsd.c index b6f3707c1..95616e6fc 100644 --- a/src/bsd.c +++ b/src/bsd.c @@ -1648,15 +1648,15 @@ static void read_authports(int fd, int revents, void *userdata) * Oh. this is needed because an authd reply may come back in more * than 1 read! -avalon */ - if ((len = READ_SOCK(cptr->local->authfd, cptr->local->buffer + cptr->count, - sizeof(cptr->local->buffer) - 1 - cptr->count)) >= 0) + if ((len = READ_SOCK(cptr->local->authfd, cptr->local->buffer + cptr->local->identbufcnt, + sizeof(cptr->local->buffer) - 1 - cptr->local->identbufcnt)) >= 0) { - cptr->count += len; - cptr->local->buffer[cptr->count] = '\0'; + cptr->local->identbufcnt += len; + cptr->local->buffer[cptr->local->identbufcnt] = '\0'; } cptr->local->lasttime = TStime(); - if ((len > 0) && (cptr->count != (sizeof(cptr->local->buffer) - 1)) && + if ((len > 0) && (cptr->local->identbufcnt != (sizeof(cptr->local->buffer) - 1)) && (sscanf(cptr->local->buffer, "%hd , %hd : USERID : %*[^:]: %10s", &remp, &locp, ruser) == 3)) { @@ -1684,7 +1684,7 @@ static void read_authports(int fd, int revents, void *userdata) fd_close(cptr->local->authfd); --OpenFiles; cptr->local->authfd = -1; - cptr->count = 0; + cptr->local->identbufcnt = 0; ClearAuth(cptr); if (!DoingDNS(cptr)) finish_auth(cptr); diff --git a/src/modules/stats.c b/src/modules/stats.c index 3221d6355..1e6214ade 100644 --- a/src/modules/stats.c +++ b/src/modules/stats.c @@ -788,8 +788,8 @@ int stats_mem(Client *sptr, char *para) } } } - lcm = lc * CLIENT_LOCAL_SIZE; - rcm = rc * CLIENT_REMOTE_SIZE; + lcm = lc * sizeof(Client)+sizeof(LocalClient); + rcm = rc * sizeof(Client); for (chptr = channel; chptr; chptr = chptr->nextch) {