Skip to content
This repository was archived by the owner on Feb 9, 2020. It is now read-only.

Commit 93a9e93

Browse files
rogersmxenith
authored andcommitted
Improve error detection code on blowfish crypt & increase password len. (#40)
1 parent d303ce4 commit 93a9e93

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/socket.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -903,17 +903,25 @@ void handle_new_connections(D_SOCKET *dsock, char *arg)
903903
dsock->player = p_new;
904904
break;
905905
case STATE_NEW_PASSWORD:
906-
if (strlen(arg) < 5 || strlen(arg) > 12)
906+
if (strlen(arg) < 5 || strlen(arg) >= 256)
907907
{
908-
text_to_buffer(dsock, "Between 5 and 12 chars please!\n\rPlease enter a new password: ");
908+
text_to_buffer(dsock, "Between 5 and 256 chars please!\n\rPlease enter a new password: ");
909909
return;
910910
}
911911

912912
free(dsock->player->password);
913913
snprintf(salt, sizeof(salt), "$2y$12$%s%s$", pepper, dsock->player->name);
914914
dsock->player->password = strdup(crypt(arg, salt));
915915

916-
if(0 == strncmp("*0", dsock->player->password, 2)) {
916+
/*
917+
* We check our encrypted password is not "*0" or "*1".
918+
* This is one of the ways the blowcrypt API signals some
919+
* internal error.
920+
*
921+
*/
922+
923+
if(0 == strncmp("*0", dsock->player->password, 2)
924+
|| 0 == strncmp("*1", dsock->player->password, 2)) {
917925
text_to_buffer(dsock, "Illegal password!\n\rPlease enter a new password: ");
918926
return;
919927
}

0 commit comments

Comments
 (0)