Skip to content

Commit 08ca210

Browse files
committed
session_server_ssh: changes due to PR review
1 parent b05608b commit 08ca210

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/session_server_ssh.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -625,12 +625,10 @@ static int
625625
nc_server_ssh_compare_password(const char *stored_pw, const char *received_pw)
626626
{
627627
char *received_pw_hash = NULL;
628-
static struct crypt_data cdata;
628+
struct crypt_data *cdata;
629629

630630
NC_CHECK_ARG_RET(NULL, stored_pw, received_pw, 1);
631631

632-
memset(&cdata, 0, sizeof(struct crypt_data));
633-
634632
if (!stored_pw[0]) {
635633
if (!received_pw[0]) {
636634
WRN(NULL, "User authentication successful with an empty password!");
@@ -647,7 +645,13 @@ nc_server_ssh_compare_password(const char *stored_pw, const char *received_pw)
647645
return strcmp(stored_pw + 3, received_pw);
648646
}
649647

650-
received_pw_hash = crypt_r(received_pw, stored_pw, &cdata);
648+
cdata = (struct crypt_data *) calloc(sizeof(struct crypt_data), 1);
649+
if (cdata == NULL) {
650+
return 1;
651+
}
652+
653+
received_pw_hash = crypt_r(received_pw, stored_pw, cdata);
654+
free(cdata);
651655
if (!received_pw_hash) {
652656
ERR(NULL, "Hashing the password failed (%s).", strerror(errno));
653657
return 1;

0 commit comments

Comments
 (0)