diff options
author | Andrew Bartlett <abartlet@samba.org> | 2003-02-10 11:47:21 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2003-02-10 11:47:21 +0000 |
commit | 8a20407442efa0f9fe43e1b1c61140a0771c6ff8 (patch) | |
tree | bbf0328ea060ca5986c92f45c7feacecf014be7a /source3/auth/auth_util.c | |
parent | 4703248a8e7287b738fa82edfd91fb2b13e7c222 (diff) | |
download | samba-8a20407442efa0f9fe43e1b1c61140a0771c6ff8.tar.gz samba-8a20407442efa0f9fe43e1b1c61140a0771c6ff8.tar.bz2 samba-8a20407442efa0f9fe43e1b1c61140a0771c6ff8.zip |
Cleanups: (merge from HEAD)
- use safe_strcpy() instead of pstrcpy() for malloc()ed strings
- CUPS: a failure in an attempt to automaticly add a printer is not level 0 stuff.
- Fix up a possible Realloc() failure segfault
Andrew Bartlett
(This used to be commit c1cfc296c2efdb2b5972202146e80f0e3b6a3da4)
Diffstat (limited to 'source3/auth/auth_util.c')
-rw-r--r-- | source3/auth/auth_util.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c index 5fdfd0694a..bbe0c7cf43 100644 --- a/source3/auth/auth_util.c +++ b/source3/auth/auth_util.c @@ -671,14 +671,22 @@ static NTSTATUS get_user_groups_from_local_sam(const DOM_SID *user_sid, }; n_unix_groups = groups_max(); - if ((*unix_groups = malloc( sizeof(gid_t) * groups_max() ) ) == NULL) { + if ((*unix_groups = malloc( sizeof(gid_t) * n_unix_groups ) ) == NULL) { DEBUG(0, ("get_user_groups_from_local_sam: Out of memory allocating unix group list\n")); passwd_free(&usr); return NT_STATUS_NO_MEMORY; } if (sys_getgrouplist(usr->pw_name, usr->pw_gid, *unix_groups, &n_unix_groups) == -1) { - *unix_groups = Realloc(*unix_groups, sizeof(gid_t) * n_unix_groups); + gid_t *groups_tmp; + groups_tmp = Realloc(*unix_groups, sizeof(gid_t) * n_unix_groups); + if (!groups_tmp) { + SAFE_FREE(*unix_groups); + passwd_free(&usr); + return NT_STATUS_NO_MEMORY; + } + *unix_groups = groups_tmp; + if (sys_getgrouplist(usr->pw_name, usr->pw_gid, *unix_groups, &n_unix_groups) == -1) { DEBUG(0, ("get_user_groups_from_local_sam: failed to get the unix group list\n")); SAFE_FREE(*unix_groups); |