]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4/dsdb/util_samr: check some return codes (CID 1444977)
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 8 May 2019 02:52:31 +0000 (14:52 +1200)
committerDouglas Bagnall <dbagnall@samba.org>
Thu, 9 May 2019 22:39:27 +0000 (22:39 +0000)
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
source4/dsdb/common/util_samr.c

index bb906fa04883cb408150a0d423bf5f5d5a70dc7a..5370fc94ebac480846af25241b3cd81a1f43574d 100644 (file)
@@ -154,11 +154,20 @@ NTSTATUS dsdb_add_user(struct ldb_context *ldb,
                return NT_STATUS_FOOBAR;
        }
 
-       ldb_msg_add_string(msg, "sAMAccountName", account_name);
-       ldb_msg_add_string(msg, "objectClass", obj_class);
-       samdb_msg_add_uint(ldb, tmp_ctx, msg,
-                          "userAccountControl",
-                          user_account_control);
+       ret = ldb_msg_add_string(msg, "sAMAccountName", account_name);
+       if (ret != LDB_SUCCESS) {
+               goto failed;
+       }
+       ret = ldb_msg_add_string(msg, "objectClass", obj_class);
+       if (ret != LDB_SUCCESS) {
+               goto failed;
+       }
+       ret = samdb_msg_add_uint(ldb, tmp_ctx, msg,
+                                "userAccountControl",
+                                user_account_control);
+       if (ret != LDB_SUCCESS) {
+               goto failed;
+       }
 
        /* This is only here for migrations using pdb_samba4, the
         * caller and the samldb are responsible for ensuring it makes
@@ -237,6 +246,11 @@ NTSTATUS dsdb_add_user(struct ldb_context *ldb,
        }
        talloc_free(tmp_ctx);
        return NT_STATUS_OK;
+
+  failed:
+       ldb_transaction_cancel(ldb);
+       talloc_free(tmp_ctx);
+       return NT_STATUS_INTERNAL_ERROR;
 }
 
 /*