From: Volker Lendecke Date: Wed, 6 Oct 2021 08:10:21 +0000 (+0200) Subject: winbind: Simplify winbindd_getusersids_recv() X-Git-Tag: ldb-2.5.0~509 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc4ee9c494d5a0c9330db50337dfec55d1bb127f;p=thirdparty%2Fsamba.git winbind: Simplify winbindd_getusersids_recv() Use talloc_asprintf_addbuf(), fix an realloc error path memleak Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/winbindd/winbindd_getusersids.c b/source3/winbindd/winbindd_getusersids.c index 3924d4933e5..1f2546a7ba1 100644 --- a/source3/winbindd/winbindd_getusersids.c +++ b/source3/winbindd/winbindd_getusersids.c @@ -101,18 +101,16 @@ NTSTATUS winbindd_getusersids_recv(struct tevent_req *req, } result = talloc_strdup(response, ""); - if (result == NULL) { - return NT_STATUS_NO_MEMORY; - } for (i=0; inum_sids; i++) { - result = talloc_asprintf_append_buffer( - result, + talloc_asprintf_addbuf( + &result, "%s\n", dom_sid_str_buf(&state->sids[i], &sidbuf)); - if (result == NULL) { - return NT_STATUS_NO_MEMORY; - } + } + + if (result == NULL) { + return NT_STATUS_NO_MEMORY; } response->data.num_entries = state->num_sids;