diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2023-12-25 07:07:05 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2023-12-25 07:07:05 +0100 |
commit | 5fb77c3337679d5661a3e14747481355fbc82bfd (patch) | |
tree | ad29badd5b13f1dccc12fe06c87e1859740d50ac /FICS/comproc.c | |
parent | 74b8ab228e7fc36f2a648b4e6b206c45d289aa85 (diff) |
Fix the salt
Diffstat (limited to 'FICS/comproc.c')
-rw-r--r-- | FICS/comproc.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/FICS/comproc.c b/FICS/comproc.c index 3533c15..32f8662 100644 --- a/FICS/comproc.c +++ b/FICS/comproc.c @@ -39,6 +39,7 @@ #include "comproc.h" #include "config.h" #include "eco.h" +#include "fics_getsalt.h" #include "ficsmain.h" #include "formula.h" #include "gamedb.h" @@ -538,7 +539,7 @@ com_password(int p, param_list param) { char *oldpassword = param[0].val.word; char *newpassword = param[1].val.word; - char salt[6]; + char salt[FICS_SALT_SIZE]; if (!parray[p].registered) { pprintf(p, "Setting a password is only for registered players." @@ -547,12 +548,8 @@ com_password(int p, param_list param) } if (parray[p].passwd) { - salt[0] = '$'; - salt[1] = '1'; - salt[2] = '$'; - salt[3] = parray[p].passwd[0]; - salt[4] = parray[p].passwd[1]; - salt[5] = '\0'; + strncpy(salt, &(parray[p].passwd[0]), sizeof salt - 1); + salt[sizeof salt - 1] = '\0'; if (strcmp(crypt(oldpassword, salt), parray[p].passwd)) { pprintf(p, "Incorrect password, password not changed!" @@ -564,12 +561,7 @@ com_password(int p, param_list param) parray[p].passwd = NULL; } - salt[0] = '$'; - salt[1] = '1'; - salt[2] = '$'; - salt[3] = ('a' + rand() % 26); - salt[4] = ('a' + rand() % 26); - salt[5] = '\0'; + strcpy(salt, fics_getsalt()); parray[p].passwd = xstrdup(crypt(newpassword, salt)); pprintf(p, "Password changed to \"%s\".\n", newpassword); |