summaryrefslogtreecommitdiff
path: root/source3/nsswitch/winbindd_user.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-05-12 01:08:09 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:22:00 -0500
commita4b034d19544601129eb1b7db75b1c2973246e36 (patch)
treebed6ff25433d2d379625b51c5c9e717ac2bb84b9 /source3/nsswitch/winbindd_user.c
parent0484aca691c727ce4694924db6daac82011d1740 (diff)
downloadsamba-a4b034d19544601129eb1b7db75b1c2973246e36.tar.gz
samba-a4b034d19544601129eb1b7db75b1c2973246e36.tar.bz2
samba-a4b034d19544601129eb1b7db75b1c2973246e36.zip
r22812: Fix bug #3024 (and also the group varient). Patch from
Johann Hanne <jhml@gmx.net> and also Kaya Bekiro?lu <kaya.bekiroglu@isilon.com> Jeremy. (This used to be commit c0ba891be06f49968317a90079554cfce2344f39)
Diffstat (limited to 'source3/nsswitch/winbindd_user.c')
-rw-r--r--source3/nsswitch/winbindd_user.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/source3/nsswitch/winbindd_user.c b/source3/nsswitch/winbindd_user.c
index 5e1ce8d137..48b470cdd0 100644
--- a/source3/nsswitch/winbindd_user.c
+++ b/source3/nsswitch/winbindd_user.c
@@ -662,7 +662,7 @@ void winbindd_getpwent(struct winbindd_cli_state *state)
{
struct getent_state *ent;
struct winbindd_pw *user_list;
- int num_users, user_list_ndx = 0, i;
+ int num_users, user_list_ndx;
DEBUG(3, ("[%5lu]: getpwent\n", (unsigned long)state->pid));
@@ -676,6 +676,11 @@ void winbindd_getpwent(struct winbindd_cli_state *state)
/* Allocate space for returning a chunk of users */
num_users = MIN(MAX_GETPWENT_USERS, state->request.data.num_entries);
+
+ if (num_users == 0) {
+ request_error(state);
+ return;
+ }
if ((state->response.extra_data.data = SMB_MALLOC_ARRAY(struct winbindd_pw, num_users)) == NULL) {
request_error(state);
@@ -697,7 +702,7 @@ void winbindd_getpwent(struct winbindd_cli_state *state)
/* Start sending back users */
- for (i = 0; i < num_users; i++) {
+ for (user_list_ndx = 0; user_list_ndx < num_users; ) {
struct getpwent_user *name_list = NULL;
uint32 result;
@@ -740,8 +745,6 @@ void winbindd_getpwent(struct winbindd_cli_state *state)
name_list[ent->sam_entry_index].shell,
&user_list[user_list_ndx]);
- ent->sam_entry_index++;
-
/* Add user to return list */
if (result) {
@@ -754,6 +757,9 @@ void winbindd_getpwent(struct winbindd_cli_state *state)
} else
DEBUG(1, ("could not lookup domain user %s\n",
name_list[ent->sam_entry_index].name));
+
+ ent->sam_entry_index++;
+
}
/* Out of domains */