s4:password hash LDB module - check that password hashes are != NULL before copying...
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Mon, 10 May 2010 18:02:21 +0000 (20:02 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Mon, 10 May 2010 18:02:21 +0000 (20:02 +0200)
source4/dsdb/samdb/ldb_modules/password_hash.c

index 2fcb6aed6db1500be9bdc04d671036635fca8258..7717b03621a8f8fe809c68b7f9cccff36b18dc1b 100644 (file)
@@ -1778,9 +1778,11 @@ static int setup_io(struct ph_context *ac,
                        return LDB_ERR_CONSTRAINT_VIOLATION;
                }
 
-               io->n.nt_hash = talloc(io->ac, struct samr_Password);
-               memcpy(io->n.nt_hash->hash, quoted_utf16->data,
-                      MIN(quoted_utf16->length, sizeof(io->n.nt_hash->hash)));
+               if (quoted_utf16 != NULL) {
+                       io->n.nt_hash = talloc(io->ac, struct samr_Password);
+                       memcpy(io->n.nt_hash->hash, quoted_utf16->data,
+                              MIN(quoted_utf16->length, sizeof(io->n.nt_hash->hash)));
+               }
        }
 
        /* Checks and converts the previous "unicodePwd" attribute */
@@ -1827,9 +1829,11 @@ static int setup_io(struct ph_context *ac,
                        return LDB_ERR_UNWILLING_TO_PERFORM;
                }
 
-               io->og.nt_hash = talloc(io->ac, struct samr_Password);
-               memcpy(io->og.nt_hash->hash, old_quoted_utf16->data,
-                      MIN(old_quoted_utf16->length, sizeof(io->og.nt_hash->hash)));
+               if (old_quoted_utf16 != NULL) {
+                       io->og.nt_hash = talloc(io->ac, struct samr_Password);
+                       memcpy(io->og.nt_hash->hash, old_quoted_utf16->data,
+                              MIN(old_quoted_utf16->length, sizeof(io->og.nt_hash->hash)));
+               }
        }
 
        /* Handles the "dBCSPwd" attribute (LM hash) */