summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-05-21 23:04:46 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-05-21 23:04:46 +0100
commit1f4375b77e0f6bd6d898bbfb6d525589ed11ada3 (patch)
tree272e6f5d3a5dbdc7fa949bb9f82966e2d992940a
parent5280e648d96fbcb20948f7470afdca8b38f80a44 (diff)
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.
-rw-r--r--TODO4
-rw-r--r--blabouncer.c3
2 files changed, 2 insertions, 5 deletions
diff --git a/TODO b/TODO
index b5b645a..245ddf1 100644
--- a/TODO
+++ b/TODO
@@ -15,10 +15,6 @@ Allow connecting to a passworded server.
Might need to #include <limits.h> in blabouncer.c to make some operating systems and/or compilers happy.
-Can't update greeting if server changed our nick (e.g. nick protection), then we tried to change it back, but it was now in use (e.g. by services enforcer), so our 433 handling tries to change it again.
-Maybe only do 433 handling if we're not registered yet?
-(Might be fixed by adding missing free() to fix memory leak in this commit - need to re-test.)
-
Support autojoining passworded channels.
Test CTCP.
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