]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lsa_server4: Simplify get_tdo() with talloc_asprintf_addbuf()
authorVolker Lendecke <vl@samba.org>
Fri, 27 May 2022 18:57:53 +0000 (20:57 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 6 Jun 2022 19:22:28 +0000 (19:22 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/rpc_server/lsa/dcesrv_lsa.c

index 8861cf95af85925496befe1a681c072ed5129262..185e0044de12cceef7638bff331d5808498878a5 100644 (file)
@@ -1684,47 +1684,32 @@ static NTSTATUS get_tdo(struct ldb_context *sam, TALLOC_CTX *mem_ctx,
                filter = talloc_strdup(mem_ctx,
                                       "(objectclass=trustedDomain)");
        }
-       if (!filter) {
-               return NT_STATUS_NO_MEMORY;
-       }
 
        if (dns_domain) {
                dns = ldb_binary_encode_string(mem_ctx, dns_domain);
                if (!dns) {
                        return NT_STATUS_NO_MEMORY;
                }
-               filter = talloc_asprintf_append(filter,
-                                               "(trustPartner=%s)", dns);
-               if (!filter) {
-                       return NT_STATUS_NO_MEMORY;
-               }
+               talloc_asprintf_addbuf(&filter, "(trustPartner=%s)", dns);
        }
        if (netbios) {
                nbn = ldb_binary_encode_string(mem_ctx, netbios);
                if (!nbn) {
                        return NT_STATUS_NO_MEMORY;
                }
-               filter = talloc_asprintf_append(filter,
-                                               "(flatname=%s)", nbn);
-               if (!filter) {
-                       return NT_STATUS_NO_MEMORY;
-               }
+               talloc_asprintf_addbuf(&filter, "(flatname=%s)", nbn);
        }
        if (sid) {
                struct dom_sid_buf buf;
                char *sidstr = dom_sid_str_buf(sid, &buf);
-               filter = talloc_asprintf_append(filter,
-                                               "(securityIdentifier=%s)",
-                                               sidstr);
-               if (!filter) {
-                       return NT_STATUS_NO_MEMORY;
-               }
+               talloc_asprintf_addbuf(
+                       &filter, "(securityIdentifier=%s)", sidstr);
        }
        if (dns_domain || netbios || sid) {
-               filter = talloc_asprintf_append(filter, "))");
-               if (!filter) {
-                       return NT_STATUS_NO_MEMORY;
-               }
+               talloc_asprintf_addbuf(&filter, "))");
+       }
+       if (filter == NULL) {
+               return NT_STATUS_NO_MEMORY;
        }
 
        ret = gendb_search(sam, mem_ctx, basedn, msgs, attrs, "%s", filter);