summaryrefslogtreecommitdiff
path: root/message.c
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2020-01-05 22:25:22 +0000
committerLuke Bratch <luke@bratch.co.uk>2020-01-05 22:25:22 +0000
commit82ab48d41bfef30ab51b407b48dfcda9ebc5f7e7 (patch)
tree28a87fe7d5c0af50aaf1abc4717c9e7cb93a24a5 /message.c
parentd0c2d49cc63cf14a094f3bb168ffdd18e2ea5ff3 (diff)
Fix some situations where the remote IP of a connecting/disconnecting client is wrong in the debug log and NOTICEs.
Diffstat (limited to 'message.c')
-rw-r--r--message.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/message.c b/message.c
index 7d50f0a..2c6eb16 100644
--- a/message.c
+++ b/message.c
@@ -846,12 +846,15 @@ int processclientmessage(SSL *server_ssl, char *str, struct client *clients, int
}
}
} else {
- debugprint(DEBUG_SOME, "Password rejected, disconnecting client %s with fd %d.\n", clients[arrindex(clients, sourcefd)].remoteip, sourcefd);
+ // Store the client's IP address for now, since we need to refer to it after disconnecting
+ // them (thus clearing the array entry that the IP is read from)
+ char remoteip[INET6_ADDRSTRLEN];
+ strncpy(remoteip, clients[arrindex(clients, sourcefd)].remoteip, INET6_ADDRSTRLEN);
+ debugprint(DEBUG_SOME, "Password rejected, disconnecting client %s with fd %d.\n", remoteip, sourcefd);
disconnectclient(sourcefd, clients, ircdstate, settings, clientcodes);
// Alert other clients about the failed authentication
char alertmsg[MAXDATASIZE];
- if (!snprintf(alertmsg, MAXDATASIZE, "NOTICE %s :blabouncer: new client %s has failed to authenticate.", ircdstate->ircnick,
- clients[arrindex(clients, sourcefd)].remoteip)) {
+ if (!snprintf(alertmsg, MAXDATASIZE, "NOTICE %s :blabouncer: new client %s failed to authenticate.", ircdstate->ircnick, remoteip)) {
fprintf(stderr, "Error while preparing authentication failure NOTICE!\n");
debugprint(DEBUG_CRIT, "Error while preparing authentication failure NOTICE!\n");
alertmsg[0] = '\0';