X-Git-Url: https://git.hcoop.net/hcoop/debian/courier-authlib.git/blobdiff_plain/d50284c4aa46bdb558ab92276d4e3ebd856fe9a6..463a5c942956f42fce366796356201639cb0d92b:/checkpassword.c diff --git a/checkpassword.c b/checkpassword.c index c6b9606..9f7896a 100644 --- a/checkpassword.c +++ b/checkpassword.c @@ -35,6 +35,7 @@ static int safe_strcmp(const char *a, const char *nullable_b) static int do_authcheckpassword(const char *password, const char *encrypted_password) { + char *cpass; if (strncmp(encrypted_password, "$1$", 3) == 0 || strncasecmp(encrypted_password, "{MD5}", 5) == 0 || strncasecmp(encrypted_password, "{MD5RAW}", 8) == 0 @@ -53,14 +54,17 @@ static int do_authcheckpassword(const char *password, const char *encrypted_pass encrypted_password += 7; #endif - return ( #if HAVE_CRYPT - safe_strcmp(encrypted_password, - crypt(password, encrypted_password)) + + cpass = crypt(password, encrypted_password); + if (cpass == NULL) { + return 1; + } else { + return safe_strcmp(encrypted_password, cpass); + } #else - safe_strcmp(encrypted_password, password) + return safe_strcmp(encrypted_password, password) #endif - ); } int authcheckpassword(const char *password, const char *encrypted_password)