diff options
author | Jeremy Allison <jra@samba.org> | 2006-06-28 00:50:14 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:19:01 -0500 |
commit | d1014c1cdfce116741ddd6eccd65b69530ce0b84 (patch) | |
tree | 04ba00b02632484f2492f979229b76e06bc92141 /source3/smbd | |
parent | 5a1a08d4286b85252233517373cad75a355b05a7 (diff) | |
download | samba-d1014c1cdfce116741ddd6eccd65b69530ce0b84.tar.gz samba-d1014c1cdfce116741ddd6eccd65b69530ce0b84.tar.bz2 samba-d1014c1cdfce116741ddd6eccd65b69530ce0b84.zip |
r16582: Fix Klocwork #1997 and all generic class of problems
where we don't correctly check the return from memdup.
Jeremy.
(This used to be commit ce14daf51c7ee2f9c68c77f7f4674e6f0e35c9ca)
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/sec_ctx.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/source3/smbd/sec_ctx.c b/source3/smbd/sec_ctx.c index a30123bfa7..51d1d6cc0a 100644 --- a/source3/smbd/sec_ctx.c +++ b/source3/smbd/sec_ctx.c @@ -252,13 +252,29 @@ void set_sec_ctx(uid_t uid, gid_t gid, int ngroups, gid_t *groups, NT_USER_TOKEN ctx_p->ut.ngroups = ngroups; SAFE_FREE(ctx_p->ut.groups); - if (token && (token == ctx_p->token)) + if (token && (token == ctx_p->token)) { smb_panic("DUPLICATE_TOKEN"); + } TALLOC_FREE(ctx_p->token); - ctx_p->ut.groups = memdup(groups, sizeof(gid_t) * ngroups); - ctx_p->token = dup_nt_token(NULL, token); + if (ngroups) { + ctx_p->ut.groups = memdup(groups, sizeof(gid_t) * ngroups); + if (!ctx_p->ut.groups) { + smb_panic("memdup failed"); + } + } else { + ctx_p->ut.groups = NULL; + } + + if (token) { + ctx_p->token = dup_nt_token(NULL, token); + if (!ctx_p->token) { + smb_panic("dup_nt_token failed"); + } + } else { + ctx_p->token = NULL; + } become_id(uid, gid); |