svn commit: samba r22812 - in branches: SAMBA_3_0/source/nsswitch SAMBA_3_0_25/source/nsswitch SAMBA_3_0_26/source/nsswitch

jra at samba.org jra at samba.org
Sat May 12 01:08:10 GMT 2007


Author: jra
Date: 2007-05-12 01:08:09 +0000 (Sat, 12 May 2007)
New Revision: 22812

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=22812

Log:
Fix bug #3024 (and also the group varient). Patch from
Johann Hanne <jhml at gmx.net> and also Kaya Bekiro?lu <kaya.bekiroglu at isilon.com>
Jeremy.

Modified:
   branches/SAMBA_3_0/source/nsswitch/winbindd_group.c
   branches/SAMBA_3_0/source/nsswitch/winbindd_user.c
   branches/SAMBA_3_0_25/source/nsswitch/winbindd_group.c
   branches/SAMBA_3_0_25/source/nsswitch/winbindd_user.c
   branches/SAMBA_3_0_26/source/nsswitch/winbindd_group.c
   branches/SAMBA_3_0_26/source/nsswitch/winbindd_user.c


Changeset:
Modified: branches/SAMBA_3_0/source/nsswitch/winbindd_group.c
===================================================================
--- branches/SAMBA_3_0/source/nsswitch/winbindd_group.c	2007-05-11 21:51:53 UTC (rev 22811)
+++ branches/SAMBA_3_0/source/nsswitch/winbindd_group.c	2007-05-12 01:08:09 UTC (rev 22812)
@@ -902,7 +902,7 @@
 {
 	struct getent_state *ent;
 	struct winbindd_gr *group_list = NULL;
-	int num_groups, group_list_ndx = 0, i, gr_mem_list_len = 0;
+	int num_groups, group_list_ndx, gr_mem_list_len = 0;
 	char *gr_mem_list = NULL;
 
 	DEBUG(3, ("[%5lu]: getgrent\n", (unsigned long)state->pid));
@@ -916,6 +916,11 @@
 
 	num_groups = MIN(MAX_GETGRENT_GROUPS, state->request.data.num_entries);
 
+	if (num_groups == 0) {
+		request_error(state);
+		return;
+	}
+
 	if ((state->response.extra_data.data = SMB_MALLOC_ARRAY(struct winbindd_gr, num_groups)) == NULL) {
 		request_error(state);
 		return;
@@ -938,7 +943,7 @@
 
 	/* Start sending back groups */
 
-	for (i = 0; i < num_groups; i++) {
+	for (group_list_ndx = 0; group_list_ndx < num_groups; ) {
 		struct acct_info *name_list = NULL;
 		fstring domain_group_name;
 		uint32 result;

Modified: branches/SAMBA_3_0/source/nsswitch/winbindd_user.c
===================================================================
--- branches/SAMBA_3_0/source/nsswitch/winbindd_user.c	2007-05-11 21:51:53 UTC (rev 22811)
+++ branches/SAMBA_3_0/source/nsswitch/winbindd_user.c	2007-05-12 01:08:09 UTC (rev 22812)
@@ -662,7 +662,7 @@
 {
 	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 @@
 	/* 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 @@
 
 	/* 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 @@
 			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 @@
 		} else
 			DEBUG(1, ("could not lookup domain user %s\n",
 				  name_list[ent->sam_entry_index].name));
+
+		ent->sam_entry_index++;
+		
 	}
 
 	/* Out of domains */

Modified: branches/SAMBA_3_0_25/source/nsswitch/winbindd_group.c
===================================================================
--- branches/SAMBA_3_0_25/source/nsswitch/winbindd_group.c	2007-05-11 21:51:53 UTC (rev 22811)
+++ branches/SAMBA_3_0_25/source/nsswitch/winbindd_group.c	2007-05-12 01:08:09 UTC (rev 22812)
@@ -902,7 +902,7 @@
 {
 	struct getent_state *ent;
 	struct winbindd_gr *group_list = NULL;
-	int num_groups, group_list_ndx = 0, i, gr_mem_list_len = 0;
+	int num_groups, group_list_ndx, gr_mem_list_len = 0;
 	char *gr_mem_list = NULL;
 
 	DEBUG(3, ("[%5lu]: getgrent\n", (unsigned long)state->pid));
@@ -916,6 +916,11 @@
 
 	num_groups = MIN(MAX_GETGRENT_GROUPS, state->request.data.num_entries);
 
+	if (num_groups == 0) {
+		request_error(state);
+		return;
+	}
+
 	if ((state->response.extra_data.data = SMB_MALLOC_ARRAY(struct winbindd_gr, num_groups)) == NULL) {
 		request_error(state);
 		return;
@@ -938,7 +943,7 @@
 
 	/* Start sending back groups */
 
-	for (i = 0; i < num_groups; i++) {
+	for (group_list_ndx = 0; group_list_ndx < num_groups; ) {
 		struct acct_info *name_list = NULL;
 		fstring domain_group_name;
 		uint32 result;

Modified: branches/SAMBA_3_0_25/source/nsswitch/winbindd_user.c
===================================================================
--- branches/SAMBA_3_0_25/source/nsswitch/winbindd_user.c	2007-05-11 21:51:53 UTC (rev 22811)
+++ branches/SAMBA_3_0_25/source/nsswitch/winbindd_user.c	2007-05-12 01:08:09 UTC (rev 22812)
@@ -631,7 +631,7 @@
 {
 	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));
 
@@ -645,6 +645,11 @@
 	/* 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);
@@ -666,7 +671,7 @@
 
 	/* 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;
 
@@ -709,8 +714,6 @@
 			name_list[ent->sam_entry_index].shell,
 			&user_list[user_list_ndx]);
 		
-		ent->sam_entry_index++;
-		
 		/* Add user to return list */
 		
 		if (result) {
@@ -723,6 +726,9 @@
 		} else
 			DEBUG(1, ("could not lookup domain user %s\n",
 				  name_list[ent->sam_entry_index].name));
+
+		ent->sam_entry_index++;
+		
 	}
 
 	/* Out of domains */

Modified: branches/SAMBA_3_0_26/source/nsswitch/winbindd_group.c
===================================================================
--- branches/SAMBA_3_0_26/source/nsswitch/winbindd_group.c	2007-05-11 21:51:53 UTC (rev 22811)
+++ branches/SAMBA_3_0_26/source/nsswitch/winbindd_group.c	2007-05-12 01:08:09 UTC (rev 22812)
@@ -902,7 +902,7 @@
 {
 	struct getent_state *ent;
 	struct winbindd_gr *group_list = NULL;
-	int num_groups, group_list_ndx = 0, i, gr_mem_list_len = 0;
+	int num_groups, group_list_ndx, gr_mem_list_len = 0;
 	char *gr_mem_list = NULL;
 
 	DEBUG(3, ("[%5lu]: getgrent\n", (unsigned long)state->pid));
@@ -916,6 +916,11 @@
 
 	num_groups = MIN(MAX_GETGRENT_GROUPS, state->request.data.num_entries);
 
+	if (num_groups == 0) {
+		request_error(state);
+		return;
+	}
+
 	if ((state->response.extra_data.data = SMB_MALLOC_ARRAY(struct winbindd_gr, num_groups)) == NULL) {
 		request_error(state);
 		return;
@@ -938,7 +943,7 @@
 
 	/* Start sending back groups */
 
-	for (i = 0; i < num_groups; i++) {
+	for (group_list_ndx = 0; group_list_ndx < num_groups; ) {
 		struct acct_info *name_list = NULL;
 		fstring domain_group_name;
 		uint32 result;

Modified: branches/SAMBA_3_0_26/source/nsswitch/winbindd_user.c
===================================================================
--- branches/SAMBA_3_0_26/source/nsswitch/winbindd_user.c	2007-05-11 21:51:53 UTC (rev 22811)
+++ branches/SAMBA_3_0_26/source/nsswitch/winbindd_user.c	2007-05-12 01:08:09 UTC (rev 22812)
@@ -662,7 +662,7 @@
 {
 	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 @@
 	/* 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 @@
 
 	/* 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 @@
 			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 @@
 		} else
 			DEBUG(1, ("could not lookup domain user %s\n",
 				  name_list[ent->sam_entry_index].name));
+
+		ent->sam_entry_index++;
+		
 	}
 
 	/* Out of domains */



More information about the samba-cvs mailing list