diff options
author | Matthias Dieter Wallnöfer <mwallnoefer@yahoo.de> | 2010-03-29 20:53:38 +0200 |
---|---|---|
committer | Matthias Dieter Wallnöfer <mwallnoefer@yahoo.de> | 2010-03-29 20:53:38 +0200 |
commit | e25e60ba2f4802a43a0a990c4f34fb23359dab28 (patch) | |
tree | 882181eb68374f723580c6ff10f3bf276546be13 | |
parent | 90d2902c73715c7777ad67b2a33f32a79f72764c (diff) | |
download | samba-e25e60ba2f4802a43a0a990c4f34fb23359dab28.tar.gz samba-e25e60ba2f4802a43a0a990c4f34fb23359dab28.tar.bz2 samba-e25e60ba2f4802a43a0a990c4f34fb23359dab28.zip |
s4:registry/ldb.c - Always check the "name" attribute for != NULL
If it's NULL return invalid parameter as Windows does. The name is "" if it
refers to the default value.
-rw-r--r-- | source4/lib/registry/ldb.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/source4/lib/registry/ldb.c b/source4/lib/registry/ldb.c index 36761e5273..80fbb85ac7 100644 --- a/source4/lib/registry/ldb.c +++ b/source4/lib/registry/ldb.c @@ -508,6 +508,10 @@ static WERROR ldb_open_key(TALLOC_CTX *mem_ctx, const struct hive_key *h, struct ldb_key_data *kd = talloc_get_type(h, struct ldb_key_data); struct ldb_context *c = kd->ldb; + if (name == NULL) { + return WERR_INVALID_PARAM; + } + ldap_path = reg_path_to_ldb(mem_ctx, h, name, NULL); W_ERROR_HAVE_NO_MEMORY(ldap_path); @@ -588,6 +592,10 @@ static WERROR ldb_add_key(TALLOC_CTX *mem_ctx, const struct hive_key *parent, struct ldb_key_data *newkd; int ret; + if (name == NULL) { + return WERR_INVALID_PARAM; + } + msg = ldb_msg_new(mem_ctx); W_ERROR_HAVE_NO_MEMORY(msg); @@ -634,7 +642,11 @@ static WERROR ldb_del_value(TALLOC_CTX *mem_ctx, struct hive_key *key, struct ldb_message *msg; struct ldb_dn *childdn; - if ((child == NULL) || (child[0] == '\0')) { + if (child == NULL) { + return WERR_INVALID_PARAM; + } + + if (child[0] == '\0') { /* default value */ msg = talloc_zero(mem_ctx, struct ldb_message); W_ERROR_HAVE_NO_MEMORY(msg); @@ -690,6 +702,10 @@ static WERROR ldb_del_key(TALLOC_CTX *mem_ctx, const struct hive_key *key, WERROR werr; struct hive_key *hk; + if (name == NULL) { + return WERR_INVALID_PARAM; + } + /* Verify key exists by opening it */ werr = ldb_open_key(mem_ctx, key, name, &hk); if (!W_ERROR_IS_OK(werr)) { @@ -793,13 +809,17 @@ static WERROR ldb_set_value(struct hive_key *parent, int ret; TALLOC_CTX *mem_ctx = talloc_init("ldb_set_value"); + if (name == NULL) { + return WERR_INVALID_PARAM; + } + msg = reg_ldb_pack_value(kd->ldb, mem_ctx, name, type, data); W_ERROR_HAVE_NO_MEMORY(msg); msg->dn = ldb_dn_copy(msg, kd->dn); W_ERROR_HAVE_NO_MEMORY(msg->dn); - if ((name != NULL) && (name[0] != '\0')) { + if (name[0] != '\0') { /* For a default value, we add/overwrite the attributes to/of the hive. For a normal value, we create a new child. */ if (!ldb_dn_add_child_fmt(msg->dn, "value=%s", |