]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
winbind: Avoid explicit NULL checks with talloc_asprintf_addbuf()
authorVolker Lendecke <vl@samba.org>
Tue, 30 Jun 2026 11:12:12 +0000 (13:12 +0200)
committerAnoop C S <anoopcs@samba.org>
Fri, 3 Jul 2026 04:47:29 +0000 (04:47 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/winbindd/idmap_ad.c
source3/winbindd/winbindd_lookupsids.c

index 6f707d122f1d9da8edfe41f47ea9d6563d04cc1b..36aaa4f0a8eb67d4b5bcd66b04764ffe314e7cc0 100644 (file)
@@ -1107,9 +1107,6 @@ static NTSTATUS idmap_ad_sids_to_unixids(struct idmap_domain *dom,
                ATYPE_NORMAL_ACCOUNT, ATYPE_WORKSTATION_TRUST,
                ATYPE_INTERDOMAIN_TRUST, ATYPE_SECURITY_GLOBAL_GROUP,
                ATYPE_SECURITY_LOCAL_GROUP);
-       if (filter == NULL) {
-               return NT_STATUS_NO_MEMORY;
-       }
 
        for (i=0; ids[i]; i++) {
                char *sidstr;
@@ -1121,15 +1118,11 @@ static NTSTATUS idmap_ad_sids_to_unixids(struct idmap_domain *dom,
                        return NT_STATUS_NO_MEMORY;
                }
 
-               filter = talloc_asprintf_append_buffer(
-                       filter, "(objectSid=%s)", sidstr);
+               talloc_asprintf_addbuf(&filter, "(objectSid=%s)", sidstr);
                TALLOC_FREE(sidstr);
-               if (filter == NULL) {
-                       return NT_STATUS_NO_MEMORY;
-               }
        }
 
-       filter = talloc_asprintf_append_buffer(filter, "))");
+       talloc_asprintf_addbuf(&filter, "))");
        if (filter == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
index a289fd86f0f363b722e753809e08a61c2fec6447..d0cc706a1a99a97b04029a55746941d5878e45e4 100644 (file)
@@ -101,41 +101,34 @@ NTSTATUS winbindd_lookupsids_recv(struct tevent_req *req,
        }
 
        result = talloc_asprintf(response, "%d\n", (int)state->domains->count);
-       if (result == NULL) {
-               return NT_STATUS_NO_MEMORY;
-       }
 
        for (i=0; i<state->domains->count; i++) {
                struct dom_sid_buf sid_str;
 
-               result = talloc_asprintf_append_buffer(
-                       result, "%s %s\n",
+               talloc_asprintf_addbuf(
+                       &result,
+                       "%s %s\n",
                        dom_sid_str_buf(state->domains->domains[i].sid,
                                        &sid_str),
                        state->domains->domains[i].name.string);
-               if (result == NULL) {
-                       return NT_STATUS_NO_MEMORY;
-               }
        }
 
-       result = talloc_asprintf_append_buffer(
-               result, "%d\n", (int)state->names->count);
-       if (result == NULL) {
-               return NT_STATUS_NO_MEMORY;
-       }
+       talloc_asprintf_addbuf(&result, "%d\n", (int)state->names->count);
 
        for (i=0; i<state->names->count; i++) {
                struct lsa_TranslatedName *name;
 
                name = &state->names->names[i];
 
-               result = talloc_asprintf_append_buffer(
-                       result, "%d %d %s\n",
-                       (int)name->sid_index, (int)name->sid_type,
-                       name->name.string);
-               if (result == NULL) {
-                       return NT_STATUS_NO_MEMORY;
-               }
+               talloc_asprintf_addbuf(&result,
+                                      "%" PRIu32 " %d %s\n",
+                                      name->sid_index,
+                                      (int)name->sid_type,
+                                      name->name.string);
+       }
+
+       if (result == NULL) {
+               return NT_STATUS_NO_MEMORY;
        }
 
        response->extra_data.data = result;