Skip to content

Commit ce9a7ef

Browse files
author
Mislav Novakovic
committed
CHANGE add mutex lock when crypt() is used
Signed-off-by: Mislav Novakovic <[email protected]>
1 parent ebf4bd7 commit ce9a7ef

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/session_server_ssh.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
#include "session_server_ch.h"
2929
#include "libnetconf.h"
3030

31+
#if !defined(HAVE_CRYPT_R)
32+
pthread_mutex_t crypt_lock = PTHREAD_MUTEX_INITIALIZER;
33+
#endif
34+
3135
extern struct nc_server_opts server_opts;
3236

3337
static char *
@@ -770,7 +774,9 @@ auth_password_compare_pwd(const char *pass_hash, const char *pass_clear)
770774
cdata.initialized = 0;
771775
new_pass_hash = crypt_r(pass_clear, pass_hash, &cdata);
772776
#else
777+
pthread_mutex_lock(&crypt_lock);
773778
new_pass_hash = crypt(pass_clear, pass_hash);
779+
pthread_mutex_unlock(&crypt_lock);
774780
#endif
775781
return strcmp(new_pass_hash, pass_hash);
776782
}

0 commit comments

Comments
 (0)