mirror of
https://github.com/samba-team/samba.git
synced 2025-12-07 20:23:50 +03:00
r20090: Fix a class of bugs found by James Peach. Ensure
we never mix malloc and talloc'ed contexts in the add_XX_to_array() and add_XX_to_array_unique() calls. Ensure that these calls always return False on out of memory, True otherwise and always check them. Ensure that the relevent parts of the conn struct and the nt_user_tokens are TALLOC_DESTROYED not SAFE_FREE'd. James - this should fix your crash bug in both branches. Jeremy.
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
3d6f387783
commit
0ffca7559e
@@ -181,11 +181,18 @@ BOOL getgroups_unix_user(TALLOC_CTX *mem_ctx, const char *user,
|
||||
groups = NULL;
|
||||
|
||||
/* Add in primary group first */
|
||||
add_gid_to_array_unique(mem_ctx, primary_gid, &groups, &ngrp);
|
||||
if (!add_gid_to_array_unique(mem_ctx, primary_gid, &groups, &ngrp)) {
|
||||
SAFE_FREE(temp_groups);
|
||||
return False;
|
||||
}
|
||||
|
||||
for (i=0; i<max_grp; i++)
|
||||
add_gid_to_array_unique(mem_ctx, temp_groups[i],
|
||||
&groups, &ngrp);
|
||||
for (i=0; i<max_grp; i++) {
|
||||
if (!add_gid_to_array_unique(mem_ctx, temp_groups[i],
|
||||
&groups, &ngrp)) {
|
||||
SAFE_FREE(temp_groups);
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
||||
*p_ngroups = ngrp;
|
||||
*ret_groups = groups;
|
||||
|
||||
Reference in New Issue
Block a user