Skip to content

Commit

Permalink
dsdb/password_hash: make sure that io->n.cleartext_utf8.data is a nul…
Browse files Browse the repository at this point in the history
…l terminated string

Signed-off-by: Stefan Metzmacher <[email protected]>
Reviewed-by: Michael Adam <[email protected]>
  • Loading branch information
metze-samba authored and obnoxxx committed Feb 4, 2013
1 parent 9292e5b commit 6eccfc7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions source4/dsdb/samdb/ldb_modules/password_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -2203,6 +2203,29 @@ static int setup_io(struct ph_context *ac,
}
}

if (io->n.cleartext_utf8 != NULL) {
struct ldb_val *cleartext_utf8_blob;
char *p;

cleartext_utf8_blob = talloc(io->ac, struct ldb_val);
if (!cleartext_utf8_blob) {
return ldb_oom(ldb);
}

*cleartext_utf8_blob = *io->n.cleartext_utf8;

/* make sure we have a null terminated string */
p = talloc_strndup(cleartext_utf8_blob,
(const char *)io->n.cleartext_utf8->data,
io->n.cleartext_utf8->length);
if ((p == NULL) && (io->n.cleartext_utf8->length > 0)) {
return ldb_oom(ldb);
}
cleartext_utf8_blob->data = (uint8_t *)p;

io->n.cleartext_utf8 = cleartext_utf8_blob;
}

ret = msg_find_old_and_new_pwd_val(orig_msg, "clearTextPassword",
ac->req->operation,
&io->n.cleartext_utf16,
Expand Down

0 comments on commit 6eccfc7

Please sign in to comment.