Skip to content

Commit 3344c6d

Browse files
author
Rob Sanders
committed
Fix pass_matches to check return from crypt() call
1 parent f18d9b2 commit 3344c6d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

libcli.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,7 @@ void cli_regular_interval(struct cli_def *cli, int seconds) {
988988
#define DES_PREFIX "{crypt}" // To distinguish clear text from DES crypted
989989
#define MD5_PREFIX "$1$"
990990

991+
// returns 0 on fail/error, 1 if password checks out
991992
static int pass_matches(const char *pass, const char *attempt) {
992993
int des;
993994
if ((des = !strncasecmp(pass, DES_PREFIX, sizeof(DES_PREFIX) - 1))) pass += sizeof(DES_PREFIX) - 1;
@@ -996,7 +997,10 @@ static int pass_matches(const char *pass, const char *attempt) {
996997
// TODO(dparrish): Find a small crypt(3) function for use on windows
997998
if (des || !strncmp(pass, MD5_PREFIX, sizeof(MD5_PREFIX) - 1)) attempt = crypt(attempt, pass);
998999
#endif
999-
1000+
if (!attempt) {
1001+
// silent return here...
1002+
return 0;
1003+
}
10001004
return !strcmp(pass, attempt);
10011005
}
10021006

0 commit comments

Comments
 (0)