]> PatchyGit - patchyircd.git/commitdiff
move the password rejection later down the line
authorEgor <egor@patchysicp.xyz>
Tue, 23 Jan 2024 02:19:13 +0000 (04:19 +0200)
committerEgor <egor@patchysicp.xyz>
Tue, 23 Jan 2024 02:19:13 +0000 (04:19 +0200)
src/irc.c

index 6d9ab13..1c0bc46 100644 (file)
--- a/src/irc.c
+++ b/src/irc.c
@@ -307,15 +307,12 @@ int processPacket(struct client_data *client, char *source, char *command, int a
                        return 0; // FIXME: error message
                if (argc < 1)
                        return err_needmoreparams(client, command), sendbuf(client), 0;
-               if (!(client->umode & UMODE_SECURE)) {
-                       memset(args[0], 0, strlen(args[0]));
-                       return err_passwdmismatch(client), sendbuf(client), 0;
-               }
                if (client->pass_reg) {
                        memset(client->pass_reg, 0, strlen(client->pass_reg));
                        free(client->pass_reg);
                }
                client->pass_reg = mystrdup(args[0]);
+               memset(args[0], 0, strlen(args[0]));
                if (!client->pass_reg) abort();
        } else if(strcmp(command, "OPER") == 0) {
                if (!is_registered(client))
@@ -1189,7 +1186,7 @@ void newUser(struct client_data *client) {
                memset(client->pass_reg, 0, strlen(client->pass_reg));
                free(client->pass_reg);
                client->pass_reg = NULL;
-               if (res == -1) {
+               if (!(client->umode & UMODE_SECURE) || res == -1) {
                        return err_passwdmismatch(client), sendbuf(client);
                } else {
                        client->umode |= UMODE_REGISTERED;