winbind: Simplify winbindd_getsidaliases_recv()
authorVolker Lendecke <vl@samba.org>
Wed, 6 Oct 2021 08:09:45 +0000 (10:09 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 8 Oct 2021 19:28:31 +0000 (19:28 +0000)
Use talloc_asprintf_addbuf(), fix an realloc error path memleak

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/winbindd/winbindd_getsidaliases.c

index 6b1084a4a39896a2a5515532422dabcf485eda20..48c1596e1bd8011f56163127bcca4dc210d28d28 100644 (file)
@@ -134,20 +134,20 @@ NTSTATUS winbindd_getsidaliases_recv(struct tevent_req *req,
        }
 
        sidlist = talloc_strdup(response, "");
-       if (sidlist == NULL) {
-               return NT_STATUS_NO_MEMORY;
-       }
+
        for (i=0; i<state->num_aliases; i++) {
                struct dom_sid sid;
                struct dom_sid_buf tmp;
                sid_compose(&sid, &state->sid, state->aliases[i]);
 
-               sidlist = talloc_asprintf_append_buffer(
-                       sidlist, "%s\n", dom_sid_str_buf(&sid, &tmp));
-               if (sidlist == NULL) {
-                       return NT_STATUS_NO_MEMORY;
-               }
+               talloc_asprintf_addbuf(
+                       &sidlist, "%s\n", dom_sid_str_buf(&sid, &tmp));
        }
+
+       if (sidlist == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
        response->extra_data.data = sidlist;
        response->length += talloc_get_size(sidlist);
        response->data.num_entries = state->num_aliases;