summaryrefslogtreecommitdiffstats
path: root/source4/lib
diff options
context:
space:
mode:
authorGarming Sam <garming@catalyst.net.nz>2014-02-13 17:51:11 +1300
committerAndreas Schneider <asn@cryptomilk.org>2014-03-05 16:33:21 +0100
commit952bc3cad05467959ba5aa08682d754bd80d543b (patch)
treeec59adb15fc07fbc6c50b9eeeeb17a7dada26905 /source4/lib
parent1f60aa8ec2e685517235aadbc11324d3b4a1a74d (diff)
downloadsamba-952bc3cad05467959ba5aa08682d754bd80d543b.tar.gz
samba-952bc3cad05467959ba5aa08682d754bd80d543b.tar.xz
samba-952bc3cad05467959ba5aa08682d754bd80d543b.zip
Remove a number of NT_STATUS_HAVE_NO_MEMORY_AND_FREE macros from the codebase.
Following the current coding guidelines, it is considered bad practice to return from within a macro and change control flow as they look like normal function calls. Change-Id: I133eb5a699757ae57b87d3bd3ebbcf5b556b0268 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/policy/gp_filesys.c30
-rw-r--r--source4/lib/policy/gp_ldap.c165
-rw-r--r--source4/lib/policy/gp_manage.c55
3 files changed, 200 insertions, 50 deletions
diff --git a/source4/lib/policy/gp_filesys.c b/source4/lib/policy/gp_filesys.c
index b6107fceae7..a18c51341d9 100644
--- a/source4/lib/policy/gp_filesys.c
+++ b/source4/lib/policy/gp_filesys.c
@@ -280,12 +280,18 @@ static NTSTATUS gp_get_files(struct smbcli_tree *tree, const char *share_path,
/* Get local path by replacing backslashes with slashes */
local_rel_path = talloc_strdup(mem_ctx, list->files[i].rel_path);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(local_rel_path, mem_ctx);
+ if (local_rel_path == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
string_replace(local_rel_path, '\\', '/');
full_local_path = talloc_asprintf(mem_ctx, "%s%s", local_path,
local_rel_path);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(full_local_path, mem_ctx);
+ if (full_local_path == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
/* If the entry is a directory, create it. */
if (list->files[i].is_directory == true) {
@@ -301,7 +307,10 @@ static NTSTATUS gp_get_files(struct smbcli_tree *tree, const char *share_path,
full_remote_path = talloc_asprintf(mem_ctx, "%s%s", share_path,
list->files[i].rel_path);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(full_remote_path, mem_ctx);
+ if (full_remote_path == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
/* Get the file */
status = gp_get_file(tree, full_remote_path, full_local_path);
@@ -340,15 +349,24 @@ NTSTATUS gp_fetch_gpt (struct gp_context *gp_ctx, struct gp_object *gpo,
/* Get the remote path to copy from */
share_path = gp_get_share_path(mem_ctx, gpo->file_sys_path);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(share_path, mem_ctx);
+ if (share_path == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
/* Get the local path to copy to */
local_path = talloc_asprintf(gp_ctx, "%s/%s", gp_tmpdir(mem_ctx), gpo->name);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(local_path, mem_ctx);
+ if (local_path == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
/* Prepare the state structure */
state = talloc_zero(mem_ctx, struct gp_list_state);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(state, mem_ctx);
+ if (state == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
state->tree = gp_ctx->cli->tree;
state->share_path = share_path;
diff --git a/source4/lib/policy/gp_ldap.c b/source4/lib/policy/gp_ldap.c
index c390be2ad3d..ee7c07fef27 100644
--- a/source4/lib/policy/gp_ldap.c
+++ b/source4/lib/policy/gp_ldap.c
@@ -61,26 +61,41 @@ static NTSTATUS parse_gpo(TALLOC_CTX *mem_ctx, struct ldb_message *msg, struct g
NT_STATUS_HAVE_NO_MEMORY(gpo);
gpo->dn = talloc_strdup(mem_ctx, ldb_dn_get_linearized(msg->dn));
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->dn, gpo);
+ if (gpo->dn == NULL) {
+ TALLOC_FREE(gpo);
+ return NT_STATUS_NO_MEMORY;
+ }
DEBUG(9, ("Parsing GPO LDAP data for %s\n", gpo->dn));
gpo->display_name = talloc_strdup(gpo, ldb_msg_find_attr_as_string(msg, "displayName", ""));
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->display_name, gpo);
+ if (gpo->display_name == NULL) {
+ TALLOC_FREE(gpo);
+ return NT_STATUS_NO_MEMORY;
+ }
gpo->name = talloc_strdup(gpo, ldb_msg_find_attr_as_string(msg, "name", ""));
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->name, gpo);
+ if (gpo->name == NULL) {
+ TALLOC_FREE(gpo);
+ return NT_STATUS_NO_MEMORY;
+ }
gpo->flags = ldb_msg_find_attr_as_uint(msg, "flags", 0);
gpo->version = ldb_msg_find_attr_as_uint(msg, "versionNumber", 0);
gpo->file_sys_path = talloc_strdup(gpo, ldb_msg_find_attr_as_string(msg, "gPCFileSysPath", ""));
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->file_sys_path, gpo);
+ if (gpo->file_sys_path == NULL) {
+ TALLOC_FREE(gpo);
+ return NT_STATUS_NO_MEMORY;
+ }
/* Pull the security descriptor through the NDR library */
data = ldb_msg_find_ldb_val(msg, "nTSecurityDescriptor");
gpo->security_descriptor = talloc(gpo, struct security_descriptor);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->security_descriptor, gpo);
+ if (gpo->security_descriptor == NULL) {
+ TALLOC_FREE(gpo);
+ return NT_STATUS_NO_MEMORY;
+ }
ndr_err = ndr_pull_struct_blob(data,
mem_ctx,
@@ -218,7 +233,10 @@ NTSTATUS gp_list_all_gpos(struct gp_context *gp_ctx, struct gp_object ***ret)
DEBUG(10, ("Searching for policies in DN: %s\n", ldb_dn_get_linearized(dn)));
attrs = talloc_array(mem_ctx, const char *, 7);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(attrs, mem_ctx);
+ if (attrs == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
attrs[0] = "nTSecurityDescriptor";
attrs[1] = "versionNumber";
@@ -236,7 +254,10 @@ NTSTATUS gp_list_all_gpos(struct gp_context *gp_ctx, struct gp_object ***ret)
}
gpo = talloc_array(gp_ctx, struct gp_object *, result->count+1);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo, mem_ctx);
+ if (gpo == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
gpo[result->count] = NULL;
@@ -273,7 +294,10 @@ NTSTATUS gp_get_gpo_info(struct gp_context *gp_ctx, const char *dn_str, struct g
dn = ldb_dn_new(mem_ctx, gp_ctx->ldb_ctx, dn_str);
attrs = talloc_array(mem_ctx, const char *, 7);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(attrs, mem_ctx);
+ if (attrs == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
attrs[0] = "nTSecurityDescriptor";
attrs[1] = "versionNumber";
@@ -341,12 +365,18 @@ static NTSTATUS parse_gplink (TALLOC_CTX *mem_ctx, const char *gplink_str, struc
gplinks[idx]->dn = talloc_strndup(mem_ctx,
gplink_str + start,
pos - start);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gplinks[idx]->dn, gplinks);
+ if (gplinks[idx]->dn == NULL) {
+ TALLOC_FREE(gplinks);
+ return NT_STATUS_NO_MEMORY;
+ }
for (start = pos + 1; gplink_str[pos] != ']'; pos++);
buf = talloc_strndup(gplinks, gplink_str + start, pos - start);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(buf, gplinks);
+ if (buf == NULL) {
+ TALLOC_FREE(gplinks);
+ return NT_STATUS_NO_MEMORY;
+ }
gplinks[idx]->options = (uint32_t) strtoll(buf, &end, 0);
talloc_free(buf);
@@ -397,13 +427,19 @@ NTSTATUS gp_get_gplinks(struct gp_context *gp_ctx, const char *dn_str, struct gp
if (strcmp(element->name, "gPLink") == 0) {
SMB_ASSERT(element->num_values > 0);
gplink_str = talloc_strdup(mem_ctx, (char *) element->values[0].data);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gplink_str, mem_ctx);
+ if (gplink_str == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
goto found;
}
}
}
gplink_str = talloc_strdup(mem_ctx, "");
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gplink_str, mem_ctx);
+ if (gplink_str == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
found:
@@ -479,7 +515,10 @@ NTSTATUS gp_list_gpos(struct gp_context *gp_ctx, struct security_token *token, c
}
gpos = talloc_array(gp_ctx, const char *, 1);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpos, mem_ctx);
+ if (gpos == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
gpos[0] = NULL;
/* Walk through the containers until we hit the root */
@@ -559,9 +598,15 @@ NTSTATUS gp_list_gpos(struct gp_context *gp_ctx, struct security_token *token, c
/* Add the GPO to the list */
gpos = talloc_realloc(gp_ctx, gpos, const char *, count+2);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpos, mem_ctx);
+ if (gpos == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
gpos[count] = talloc_strdup(gp_ctx, gplinks[i]->dn);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpos[count], mem_ctx);
+ if (gpos[count] == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
gpos[count+1] = NULL;
count++;
@@ -624,18 +669,27 @@ NTSTATUS gp_set_gplink(struct gp_context *gp_ctx, const char *dn_str, struct gp_
start++;
}
gplink_str = talloc_asprintf(mem_ctx, "%s;%d%s", gplink_str, gplink->options, start);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gplink_str, mem_ctx);
+ if (gplink_str == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
} else {
/* Prepend the new GPO link to the string. This list is backwards in priority. */
gplink_str = talloc_asprintf(mem_ctx, "[LDAP://%s;%d]%s", gplink->dn, gplink->options, gplink_str);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gplink_str, mem_ctx);
+ if (gplink_str == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
}
msg = ldb_msg_new(mem_ctx);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg, mem_ctx);
+ if (msg == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
msg->dn = dn;
@@ -691,7 +745,10 @@ NTSTATUS gp_del_gplink(struct gp_context *gp_ctx, const char *dn_str, const char
/* If this GPO link already exists, alter the options, else add it */
search_string = talloc_asprintf(mem_ctx, "[LDAP://%s]", gplink_dn);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(search_string, mem_ctx);
+ if (search_string == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
p = strcasestr(gplink_str, search_string);
if (p == NULL) {
@@ -706,11 +763,17 @@ NTSTATUS gp_del_gplink(struct gp_context *gp_ctx, const char *dn_str, const char
}
p++;
gplink_str = talloc_asprintf(mem_ctx, "%s%s", gplink_str, p);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gplink_str, mem_ctx);
+ if (gplink_str == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
msg = ldb_msg_new(mem_ctx);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg, mem_ctx);
+ if (msg == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
msg->dn = dn;
@@ -785,7 +848,10 @@ NTSTATUS gp_set_inheritance(struct gp_context *gp_ctx, const char *dn_str, enum
msg->dn = ldb_dn_new(msg, gp_ctx->ldb_ctx, dn_str);
inheritance_string = talloc_asprintf(msg, "%d", inheritance);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(inheritance_string, msg);
+ if (inheritance_string == NULL) {
+ TALLOC_FREE(msg);
+ return NT_STATUS_NO_MEMORY;
+ }
rv = ldb_msg_add_string(msg, "gPOptions", inheritance_string);
if (rv != LDB_SUCCESS) {
@@ -819,21 +885,33 @@ NTSTATUS gp_create_ldap_gpo(struct gp_context *gp_ctx, struct gp_object *gpo)
/* CN={GUID} */
msg = ldb_msg_new(mem_ctx);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg, mem_ctx);
+ if (msg == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
msg->dn = ldb_get_default_basedn(gp_ctx->ldb_ctx);
dn_str = talloc_asprintf(mem_ctx, "CN=%s,CN=Policies,CN=System", gpo->name);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(dn_str, mem_ctx);
+ if (dn_str == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
child_dn = ldb_dn_new(mem_ctx, gp_ctx->ldb_ctx, dn_str);
rv = ldb_dn_add_child(msg->dn, child_dn);
if (!rv) goto ldb_msg_add_error;
flags_str = talloc_asprintf(mem_ctx, "%d", gpo->flags);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(flags_str, mem_ctx);
+ if (flags_str == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
version_str = talloc_asprintf(mem_ctx, "%d", gpo->version);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(version_str, mem_ctx);
+ if (version_str == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
rv = ldb_msg_add_string(msg, "objectClass", "top");
if (rv != LDB_SUCCESS) goto ldb_msg_add_error;
@@ -869,7 +947,10 @@ NTSTATUS gp_create_ldap_gpo(struct gp_context *gp_ctx, struct gp_object *gpo)
/* CN=User */
msg = ldb_msg_new(mem_ctx);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg, mem_ctx);
+ if (msg == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
msg->dn = ldb_dn_copy(mem_ctx, gpo_dn);
child_dn = ldb_dn_new(mem_ctx, gp_ctx->ldb_ctx, "CN=User");
@@ -896,7 +977,10 @@ NTSTATUS gp_create_ldap_gpo(struct gp_context *gp_ctx, struct gp_object *gpo)
/* CN=Machine */
msg = ldb_msg_new(mem_ctx);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg, mem_ctx);
+ if (msg == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
msg->dn = ldb_dn_copy(mem_ctx, gpo_dn);
child_dn = ldb_dn_new(mem_ctx, gp_ctx->ldb_ctx, "CN=Machine");
@@ -922,7 +1006,10 @@ NTSTATUS gp_create_ldap_gpo(struct gp_context *gp_ctx, struct gp_object *gpo)
}
gpo->dn = talloc_strdup(gpo, ldb_dn_get_linearized(gpo_dn));
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->dn, mem_ctx);
+ if (gpo->dn == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
talloc_free(mem_ctx);
return NT_STATUS_OK;
@@ -957,7 +1044,10 @@ NTSTATUS gp_set_ads_acl (struct gp_context *gp_ctx, const char *dn_str, const st
/* Create a LDB message */
msg = ldb_msg_new(mem_ctx);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg, mem_ctx);
+ if (msg == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
msg->dn = ldb_dn_new(mem_ctx, gp_ctx->ldb_ctx, dn_str);
@@ -991,15 +1081,24 @@ NTSTATUS gp_set_ldap_gpo(struct gp_context *gp_ctx, struct gp_object *gpo)
mem_ctx = talloc_new(gp_ctx);
msg = ldb_msg_new(mem_ctx);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg, mem_ctx);
+ if (msg == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
msg->dn = ldb_dn_new(mem_ctx, gp_ctx->ldb_ctx, gpo->dn);
version_str = talloc_asprintf(mem_ctx, "%d", gpo->version);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg, mem_ctx);
+ if (msg == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
flags_str = talloc_asprintf(mem_ctx, "%d", gpo->flags);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(msg, mem_ctx);
+ if (msg == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
rv = ldb_msg_add_string(msg, "flags", flags_str);
if (rv != LDB_SUCCESS) {
diff --git a/source4/lib/policy/gp_manage.c b/source4/lib/policy/gp_manage.c
index e4321e50b1f..80336edf700 100644
--- a/source4/lib/policy/gp_manage.c
+++ b/source4/lib/policy/gp_manage.c
@@ -67,21 +67,33 @@ NTSTATUS gp_create_gpt_security_descriptor (TALLOC_CTX *mem_ctx, struct security
/* Copy the basic information from the directory server security descriptor */
fs_sd->owner_sid = talloc_memdup(fs_sd, ds_sd->owner_sid, sizeof(struct dom_sid));
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(fs_sd->owner_sid, fs_sd);
+ if (fs_sd->owner_sid == NULL) {
+ TALLOC_FREE(fs_sd);
+ return NT_STATUS_NO_MEMORY;
+ }
fs_sd->group_sid = talloc_memdup(fs_sd, ds_sd->group_sid, sizeof(struct dom_sid));
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(fs_sd->group_sid, fs_sd);
+ if (fs_sd->group_sid == NULL) {
+ TALLOC_FREE(fs_sd);
+ return NT_STATUS_NO_MEMORY;
+ }
fs_sd->type = ds_sd->type;
fs_sd->revision = ds_sd->revision;
/* Copy the sacl */
fs_sd->sacl = security_acl_dup(fs_sd, ds_sd->sacl);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(fs_sd->sacl, fs_sd);
+ if (fs_sd->sacl == NULL) {
+ TALLOC_FREE(fs_sd);
+ return NT_STATUS_NO_MEMORY;
+ }
/* Copy the dacl */
fs_sd->dacl = talloc_zero(fs_sd, struct security_acl);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(fs_sd->dacl, fs_sd);
+ if (fs_sd->dacl == NULL) {
+ TALLOC_FREE(fs_sd);
+ return NT_STATUS_NO_MEMORY;
+ }
for (i = 0; i < ds_sd->dacl->num_aces; i++) {
char *trustee = dom_sid_string(fs_sd, &ds_sd->dacl->aces[i].trustee);
@@ -96,7 +108,10 @@ NTSTATUS gp_create_gpt_security_descriptor (TALLOC_CTX *mem_ctx, struct security
/* Copy the ace from the directory server security descriptor */
ace = talloc_memdup(fs_sd, &ds_sd->dacl->aces[i], sizeof(struct security_ace));
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(ace, fs_sd);
+ if (ace == NULL) {
+ TALLOC_FREE(fs_sd);
+ return NT_STATUS_NO_MEMORY;
+ }
/* Set specific inheritance flags for within the GPO */
ace->flags |= SEC_ACE_FLAG_OBJECT_INHERIT | SEC_ACE_FLAG_CONTAINER_INHERIT;
@@ -139,14 +154,23 @@ NTSTATUS gp_create_gpo (struct gp_context *gp_ctx, const char *display_name, str
/* Create the gpo struct to return later */
gpo = talloc(gp_ctx, struct gp_object);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo, mem_ctx);
+ if (gpo == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
/* Generate a GUID */
guid_struct = GUID_random();
guid_str = GUID_string2(mem_ctx, &guid_struct);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(guid_str, mem_ctx);
+ if (guid_str == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
name = strupper_talloc(mem_ctx, guid_str);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(name, mem_ctx);
+ if (name == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
/* Prepare the GPO struct */
gpo->dn = NULL;
@@ -154,10 +178,16 @@ NTSTATUS gp_create_gpo (struct gp_context *gp_ctx, const char *display_name, str
gpo->flags = 0;
gpo->version = 0;
gpo->display_name = talloc_strdup(gpo, display_name);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->display_name, mem_ctx);
+ if (gpo->display_name == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
gpo->file_sys_path = talloc_asprintf(gpo, "\\\\%s\\sysvol\\%s\\Policies\\%s", lpcfg_dnsdomain(gp_ctx->lp_ctx), lpcfg_dnsdomain(gp_ctx->lp_ctx), name);
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(gpo->file_sys_path, mem_ctx);
+ if (gpo->file_sys_path == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
/* Create the GPT */
status = gp_create_gpt(gp_ctx, name, gpo->file_sys_path);
@@ -266,7 +296,10 @@ NTSTATUS gp_push_gpo (struct gp_context *gp_ctx, const char *local_path, struct
/* Get version from ini file */
/* FIXME: The local file system may be case sensitive */
filename = talloc_asprintf(mem_ctx, "%s/%s", local_path, "GPT.INI");
- NT_STATUS_HAVE_NO_MEMORY_AND_FREE(filename, mem_ctx);
+ if (filename == NULL) {
+ TALLOC_FREE(mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
status = gp_parse_ini(mem_ctx, gp_ctx, local_path, &ini);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Failed to parse GPT.INI.\n"));