From 1f4375b77e0f6bd6d898bbfb6d525589ed11ada3 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Tue, 21 May 2019 23:04:46 +0100 Subject: Only try new nicks if the server tells us 432/ERR_ERRONEUSNICKNAME or 433/ERR_NICKNAMEINUSE if we weren't already registered with it. Avoids crash if the server changes our nick and our next automatic attempt was in use or invalid. --- blabouncer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'blabouncer.c') diff --git a/blabouncer.c b/blabouncer.c index 401b5fd..32ba454 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -1206,7 +1206,8 @@ int processircmessage(SSL *server_ssl, char *str, int source, struct client *cli } // Server 432 (ERR_ERRONEUSNICKNAME) or 433 (ERR_NICKNAMEINUSE) received? See which nick we're on and try another. - if (strncmp(tokens[1], "432", strlen(tokens[1])) == 0 || strncmp(tokens[1], "433", strlen(tokens[1])) == 0) { + // (But only if we're not already registered with the real IRC server.) + if ((strncmp(tokens[1], "432", strlen(tokens[1])) == 0 || strncmp(tokens[1], "433", strlen(tokens[1])) == 0) && !strlen(ircdstrings->greeting004)) { printf("Server 432 (ERR_ERRONEUSNICKNAME) or 433 (ERR_NICKNAMEINUSE) found and it is: %s with length %zd! Trying another nick...\n", tokens[1], strlen(tokens[1])); // Make sure nick3 hasn't already been tried -- cgit v1.2.3