winbindd: Do not use group_list->out.resume_index after free
authorAndrew Bartlett <abartlet@samba.org>
Tue, 2 Sep 2014 22:21:01 +0000 (10:21 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 8 Sep 2014 05:26:34 +0000 (07:26 +0200)
Found by AddressSanitizer

Change-Id: I59009144b28c390ddb80b7b3fbb4007dfd16db0e
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Kamen Mazdrashki <kamenim@samba.org>
source4/winbind/wb_cmd_setgrent.c

index 452d9e736a276f228b83e823f8a1244cbdd51a6f..aed5c7088b5f483b37c4e78c97fab7381c18ae9b 100644 (file)
@@ -115,6 +115,7 @@ static void cmd_setgrent_recv_group_list(struct composite_context *ctx)
                        group_list);
        if (NT_STATUS_IS_OK(state->ctx->status) ||
                NT_STATUS_EQUAL(state->ctx->status, STATUS_MORE_ENTRIES)) {
+               uint32_t resume_index = group_list->out.resume_index;
                if( state->result->page_index == -1) { /* First run*/
                        state->result->group_list = group_list;
                        state->result->page_index = 0;
@@ -130,7 +131,7 @@ static void cmd_setgrent_recv_group_list(struct composite_context *ctx)
                                tmp[i+state->result->group_list->out.count].groupname = talloc_steal(state->result,group_list->out.groups[i].groupname);
                        }
                        state->result->group_list->out.count += group_list->out.count;
-                       talloc_free(group_list);
+                       TALLOC_FREE(group_list);
                }
 
 
@@ -140,7 +141,7 @@ static void cmd_setgrent_recv_group_list(struct composite_context *ctx)
                        group_list_send = talloc(state->result, struct libnet_GroupList);
                        if (composite_nomem(group_list_send, state->ctx)) return;
                        group_list_send->in.domain_name =  talloc_strdup(state, state->domain_name);
-                       group_list_send->in.resume_index = group_list->out.resume_index;
+                       group_list_send->in.resume_index = resume_index;
                        group_list_send->in.page_size = 128;
                        ctx = libnet_GroupList_send(state->libnet_ctx, state->result, group_list_send, NULL);
                        composite_continue(state->ctx, ctx, cmd_setgrent_recv_group_list, state);