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

Improve error detection code on blowfish crypt & increase password len. #40

Merged
merged 1 commit into from
Apr 18, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,17 +903,25 @@ void handle_new_connections(D_SOCKET *dsock, char *arg)
dsock->player = p_new;
break;
case STATE_NEW_PASSWORD:
if (strlen(arg) < 5 || strlen(arg) > 12)
if (strlen(arg) < 5 || strlen(arg) >= 256)
{
text_to_buffer(dsock, "Between 5 and 12 chars please!\n\rPlease enter a new password: ");
text_to_buffer(dsock, "Between 5 and 256 chars please!\n\rPlease enter a new password: ");
return;
}

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

if(0 == strncmp("*0", dsock->player->password, 2)) {
/*
* We check our encrypted password is not "*0" or "*1".
* This is one of the ways the blowcrypt API signals some
* internal error.
*
*/

if(0 == strncmp("*0", dsock->player->password, 2)
|| 0 == strncmp("*1", dsock->player->password, 2)) {
text_to_buffer(dsock, "Illegal password!\n\rPlease enter a new password: ");
return;
}
Expand Down