summaryrefslogtreecommitdiff
path: root/source3/libads
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2019-08-13 16:30:07 +0200
committerAndreas Schneider <asn@cryptomilk.org>2019-10-09 07:06:35 +0000
commit8ed993789f93624b7b60dd5314fe5472e69e903a (patch)
tree02912e540c1d9a819153a64309bd2d3308f3397f /source3/libads
parentb84abb3a46211dc84e52ef95750627e4dd081f2f (diff)
downloadsamba-8ed993789f93624b7b60dd5314fe5472e69e903a.tar.gz
s3:libads: Cleanup error code paths in ads_create_machine_acct()
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
Diffstat (limited to 'source3/libads')
-rw-r--r--source3/libads/ldap.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index 793e97efdac..5353ac5bf88 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -2092,11 +2092,12 @@ ADS_STATUS ads_create_machine_acct(ADS_STRUCT *ads,
uint32_t etype_list)
{
ADS_STATUS ret;
- char *samAccountName, *controlstr;
- TALLOC_CTX *ctx;
+ char *samAccountName = NULL;
+ char *controlstr = NULL;
+ TALLOC_CTX *ctx = NULL;
ADS_MODLIST mods;
char *machine_escaped = NULL;
- char *new_dn;
+ char *new_dn = NULL;
const char *objectClass[] = {"top", "person", "organizationalPerson",
"user", "computer", NULL};
LDAPMessage *res = NULL;
@@ -2110,13 +2111,14 @@ ADS_STATUS ads_create_machine_acct(ADS_STRUCT *ads,
return ret;
}
- if (!(ctx = talloc_init("ads_add_machine_acct")))
+ ctx = talloc_init("ads_add_machine_acct");
+ if (ctx == NULL) {
return ADS_ERROR(LDAP_NO_MEMORY);
-
- ret = ADS_ERROR(LDAP_NO_MEMORY);
+ }
machine_escaped = escape_rdn_val_string_alloc(machine_name);
- if (!machine_escaped) {
+ if (machine_escaped == NULL) {
+ ret = ADS_ERROR(LDAP_NO_MEMORY);
goto done;
}
@@ -2131,17 +2133,26 @@ ADS_STATUS ads_create_machine_acct(ADS_STRUCT *ads,
ads_msgfree(ads, res);
new_dn = talloc_asprintf(ctx, "cn=%s,%s", machine_escaped, org_unit);
- samAccountName = talloc_asprintf(ctx, "%s$", machine_name);
+ if (new_dn == NULL) {
+ ret = ADS_ERROR(LDAP_NO_MEMORY);
+ goto done;
+ }
- if ( !new_dn || !samAccountName ) {
+ samAccountName = talloc_asprintf(ctx, "%s$", machine_name);
+ if (samAccountName == NULL) {
+ ret = ADS_ERROR(LDAP_NO_MEMORY);
goto done;
}
- if (!(controlstr = talloc_asprintf(ctx, "%u", acct_control))) {
+ controlstr = talloc_asprintf(ctx, "%u", acct_control);
+ if (controlstr == NULL) {
+ ret = ADS_ERROR(LDAP_NO_MEMORY);
goto done;
}
- if (!(mods = ads_init_mods(ctx))) {
+ mods = ads_init_mods(ctx);
+ if (mods == NULL) {
+ ret = ADS_ERROR(LDAP_NO_MEMORY);
goto done;
}
@@ -2155,6 +2166,7 @@ ADS_STATUS ads_create_machine_acct(ADS_STRUCT *ads,
etype_list_str = talloc_asprintf(ctx, "%d", (int)etype_list);
if (etype_list_str == NULL) {
+ ret = ADS_ERROR(LDAP_NO_MEMORY);
goto done;
}
ads_mod_str(ctx, &mods, "msDS-SupportedEncryptionTypes",