winbind: cleanup winbindd_cli_state->grent_state if winbindd_getgrent_recv() returns...
authorStefan Metzmacher <metze@samba.org>
Fri, 16 Feb 2018 15:13:16 +0000 (16:13 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 23 Feb 2018 03:09:18 +0000 (04:09 +0100)
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 <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/winbindd/winbindd_getgrent.c

index 1056555dc230dbab32777d6eff13b9706797946d..15a35f7044e7224c92dbf6b4068dc607bb033a61 100644 (file)
@@ -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;