From b7789da8468c3f070727011639d5f74aca76cb59 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 16 Feb 2018 16:13:16 +0100 Subject: [PATCH] winbind: cleanup winbindd_cli_state->grent_state if winbindd_getgrent_recv() returns an error A client may skip the explicit endgrent() if getgrent() fails. This allows client_is_idle() return true in more cases. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13293 Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke --- source3/winbindd/winbindd_getgrent.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source3/winbindd/winbindd_getgrent.c b/source3/winbindd/winbindd_getgrent.c index 1056555dc23..15a35f7044e 100644 --- a/source3/winbindd/winbindd_getgrent.c +++ b/source3/winbindd/winbindd_getgrent.c @@ -141,6 +141,7 @@ NTSTATUS winbindd_getgrent_recv(struct tevent_req *req, int i; if (tevent_req_is_nterror(req, &status)) { + TALLOC_FREE(state->cli->grent_state); DEBUG(5, ("getgrent failed: %s\n", nt_errstr(status))); return status; } @@ -151,6 +152,7 @@ NTSTATUS winbindd_getgrent_recv(struct tevent_req *req, memberstrings = talloc_array(talloc_tos(), char *, state->num_groups); if (memberstrings == NULL) { + TALLOC_FREE(state->cli->grent_state); return NT_STATUS_NO_MEMORY; } @@ -165,6 +167,7 @@ NTSTATUS winbindd_getgrent_recv(struct tevent_req *req, if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(memberstrings); + TALLOC_FREE(state->cli->grent_state); return status; } TALLOC_FREE(state->members[i]); @@ -180,6 +183,7 @@ NTSTATUS winbindd_getgrent_recv(struct tevent_req *req, result = talloc_realloc(state, state->groups, char, base_memberofs + total_memberlen); if (result == NULL) { + TALLOC_FREE(state->cli->grent_state); return NT_STATUS_NO_MEMORY; } state->groups = (struct winbindd_gr *)result; -- 2.34.1