s3-winbind: Fix null pointer dereference in store_memory_creds().
authorAndreas Schneider <asn@samba.org>
Mon, 17 Dec 2012 16:18:14 +0000 (17:18 +0100)
committerGünther Deschner <gd@samba.org>
Fri, 21 Dec 2012 12:56:01 +0000 (13:56 +0100)
Found by Coverity.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
source3/winbindd/winbindd_cred_cache.c

index e8bbf9c..01ca3ff 100644 (file)
@@ -846,11 +846,11 @@ static NTSTATUS store_memory_creds(struct WINBINDD_MEMORY_CREDS *memcredp,
        DEBUG(10,("mlocked memory: %p\n", memcredp->nt_hash));
 #endif
 
-       /* Create and store the password hashes. */
-       E_md4hash(pass, memcredp->nt_hash);
-       E_deshash(pass, memcredp->lm_hash);
-
        if (pass) {
+               /* Create and store the password hashes. */
+               E_md4hash(pass, memcredp->nt_hash);
+               E_deshash(pass, memcredp->lm_hash);
+
                memcredp->pass = (char *)memcredp->lm_hash + LM_HASH_LEN;
                memcpy(memcredp->pass, pass,
                       memcredp->len - NT_HASH_LEN - LM_HASH_LEN);