X-Git-Url: https://git.hcoop.net/hcoop/debian/courier-authlib.git/blobdiff_plain/8d138742ae268344f406cb75d79aa6bf853f9d87..8cefd203806dc3406799e37deeed619db0546535:/checkpassword.c diff --git a/checkpassword.c b/checkpassword.c index f403188..c6b9606 100644 --- a/checkpassword.c +++ b/checkpassword.c @@ -16,7 +16,6 @@ #include "auth.h" #include "courierauthdebug.h" -static const char rcsid[]="$Id: checkpassword.c,v 1.19 2008/12/18 12:08:25 mrsam Exp $"; #if HAVE_CRYPT #if NEED_CRYPT_PROTOTYPE @@ -27,6 +26,13 @@ extern char *crypt(const char *, const char *); extern int authcheckpasswordmd5(const char *, const char *); extern int authcheckpasswordsha1(const char *, const char *); +static int safe_strcmp(const char *a, const char *nullable_b) +{ + if (!nullable_b) + return -1; + return strcmp(a, nullable_b); +} + static int do_authcheckpassword(const char *password, const char *encrypted_password) { if (strncmp(encrypted_password, "$1$", 3) == 0 @@ -49,10 +55,10 @@ static int do_authcheckpassword(const char *password, const char *encrypted_pass return ( #if HAVE_CRYPT - strcmp(encrypted_password, - crypt(password, encrypted_password)) + safe_strcmp(encrypted_password, + crypt(password, encrypted_password)) #else - strcmp(encrypted_password, password) + safe_strcmp(encrypted_password, password) #endif ); }