summaryrefslogtreecommitdiff
path: root/source3/nsswitch/winbindd_acct.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/nsswitch/winbindd_acct.c')
-rw-r--r--source3/nsswitch/winbindd_acct.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/source3/nsswitch/winbindd_acct.c b/source3/nsswitch/winbindd_acct.c
index 34c7238b84..e6496695cb 100644
--- a/source3/nsswitch/winbindd_acct.c
+++ b/source3/nsswitch/winbindd_acct.c
@@ -219,7 +219,7 @@ static WINBINDD_GR* string2group( char *string )
if ( num_gr_members ) {
fstring buffer;
- gr_members = (char**)smb_xmalloc(sizeof(char*)*num_gr_members+1);
+ gr_members = (char**)smb_xmalloc(sizeof(char*)*(num_gr_members+1));
i = 0;
while ( next_token(&str, buffer, ",", sizeof(buffer)) && i<num_gr_members ) {
@@ -661,9 +661,11 @@ static BOOL wb_delgrpmember( WINBINDD_GR *grp, const char *user )
if ( !grp || !user )
return False;
- for ( i=0; i<grp->num_gr_mem && !found; i++ ) {
- if ( StrCaseCmp( grp->gr_mem[i], user ) == 0 )
+ for ( i=0; i<grp->num_gr_mem; i++ ) {
+ if ( StrCaseCmp( grp->gr_mem[i], user ) == 0 ) {
found = True;
+ break;
+ }
}
if ( !found )
@@ -672,8 +674,10 @@ static BOOL wb_delgrpmember( WINBINDD_GR *grp, const char *user )
/* still some remaining members */
if ( grp->num_gr_mem > 1 ) {
- memmove( grp->gr_mem[i], grp->gr_mem[i+1], sizeof(char*)*(grp->num_gr_mem-(i+1)) );
+ SAFE_FREE(grp->gr_mem[i]);
grp->num_gr_mem--;
+ grp->gr_mem[i] = grp->gr_mem[grp->num_gr_mem];
+ grp->gr_mem[grp->num_gr_mem] = NULL;
}
else { /* last one */
free_winbindd_gr( grp );
@@ -1083,7 +1087,7 @@ enum winbindd_result winbindd_remove_user_from_group(struct winbindd_cli_state *
group = state->request.data.acct_mgt.groupname;
user = state->request.data.acct_mgt.username;
- DEBUG(3, ("[%5lu]: remove_user_to_group: delete %s from %s\n", (unsigned long)state->pid,
+ DEBUG(3, ("[%5lu]: remove_user_from_group: delete %s from %s\n", (unsigned long)state->pid,
user, group));
/* don't worry about checking the username since we're removing it anyways */
@@ -1091,7 +1095,7 @@ enum winbindd_result winbindd_remove_user_from_group(struct winbindd_cli_state *
/* make sure it is a valid group */
if ( !(grp = wb_getgrnam( group )) ) {
- DEBUG(4,("winbindd_remove_user_to_group: Cannot remove a user to a non-extistent group\n"));
+ DEBUG(4,("winbindd_remove_user_from_group: Cannot remove a user from a non-extistent group\n"));
return WINBINDD_ERROR;
}