From 203ec1a45b67a7e750e10bb467292c0d6c92b6d8 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 23 Dec 2011 14:29:38 +0100 Subject: [PATCH] s3-winbind: Fix segfault if we can't map the last user. This fixes bug #8678. The issue is caused by bug #8608. Signed-off-by: Andreas Schneider --- source3/winbindd/wb_next_pwent.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/source3/winbindd/wb_next_pwent.c b/source3/winbindd/wb_next_pwent.c index d47b2fc..9091e48 100644 --- a/source3/winbindd/wb_next_pwent.c +++ b/source3/winbindd/wb_next_pwent.c @@ -155,6 +155,33 @@ static void wb_next_pwent_fill_done(struct tevent_req *subreq) if (NT_STATUS_EQUAL(status, NT_STATUS_NONE_MAPPED)) { state->gstate->next_user += 1; + if (state->gstate->next_user >= state->gstate->num_users) { + TALLOC_FREE(state->gstate->users); + + if (state->gstate->domain == NULL) { + state->gstate->domain = domain_list(); + } else { + state->gstate->domain = state->gstate->domain->next; + } + + if ((state->gstate->domain != NULL) + && sid_check_is_domain(&state->gstate->domain->sid)) { + state->gstate->domain = state->gstate->domain->next; + } + + if (state->gstate->domain == NULL) { + tevent_req_nterror(req, NT_STATUS_NO_MORE_ENTRIES); + return; + } + subreq = wb_query_user_list_send(state, state->ev, + state->gstate->domain); + if (tevent_req_nomem(subreq, req)) { + return; + } + tevent_req_set_callback(subreq, wb_next_pwent_fetch_done, req); + return; + } + subreq = wb_fill_pwent_send(state, state->ev, &state->gstate->users[state->gstate->next_user], -- 1.7.8