From: Egor Date: Thu, 25 Jan 2024 02:55:37 +0000 (+0200) Subject: abort SASL on registration X-Git-Url: https://git.patchysicp.xyz/?a=commitdiff_plain;h=54258617a337dd3fbfd4b8720fb28315f7c2a196;p=patchyircd.git abort SASL on registration From the spec: If the client completes registration (with CAP END, NICK, USER and any other necessary messages) while the SASL authentication is still in progress, the server SHOULD abort it and send a 906 numeric, then register the client without authentication. --- diff --git a/src/irc.c b/src/irc.c index 2880d7f..ced610d 100644 --- a/src/irc.c +++ b/src/irc.c @@ -391,7 +391,6 @@ saslcleanup: free(client->saslbuf); client->saslbuf = 0; client->saslbufLen = 0; - newUser(client); return 0; } } @@ -1329,8 +1328,15 @@ unknown: } void newUser(struct client_data *client) { - if (client->regstate == REG_CAPLS || client->saslbuf || !client->nick_reg || !client->username) + if (client->regstate == REG_CAPLS || !client->nick_reg || !client->username) return; + if (client->saslbuf) { + copy_strf(&databuf, ":%s 906 * :SASL auhtentication aborted\r\n", hostname), sendbuf(client); + memset(client->saslbuf, 0, 1024); + free(client->saslbuf); + client->saslbuf = 0; + client->saslbufLen = 0; + } if (client->username[0] == '~' && client->pass_reg) { int res = password_check(client->username + 1, client->pass_reg, getdatafile("users.txt")); memset(client->pass_reg, 0, strlen(client->pass_reg));