summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-08-28 05:22:10 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:38:56 -0500
commit9ab430ac4b9555206c25d04cddd57283397dd529 (patch)
tree165b0fa680a13fc595b5cfe46321db7ff8ddd3ab
parent41d1f322f856c3e10d03c65a21c12e108338df8a (diff)
downloadsamba-9ab430ac4b9555206c25d04cddd57283397dd529.tar.gz
samba-9ab430ac4b9555206c25d04cddd57283397dd529.tar.xz
samba-9ab430ac4b9555206c25d04cddd57283397dd529.zip
r17875: Fix (rather theoretical, but still...) null deref found by
Stanford checker. Jeremy. (This used to be commit 45d77ae12235e6b39cc30845d69ac3777d3eefd0)
-rw-r--r--source3/auth/auth_util.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
index 2c20beb33c8..26d1eb710f6 100644
--- a/source3/auth/auth_util.c
+++ b/source3/auth/auth_util.c
@@ -1988,16 +1988,19 @@ NT_USER_TOKEN *dup_nt_token(TALLOC_CTX *mem_ctx, NT_USER_TOKEN *ptoken)
return NULL;
}
- token->user_sids = (DOM_SID *)talloc_memdup(
- token, ptoken->user_sids, sizeof(DOM_SID) * ptoken->num_sids );
+ ZERO_STRUCTP(token);
- if ((ptoken->user_sids != NULL) && (token->user_sids == NULL)) {
- DEBUG(0, ("talloc_memdup failed\n"));
- TALLOC_FREE(token);
- return NULL;
- }
+ if (ptoken->user_sids && ptoken->num_sids) {
+ token->user_sids = (DOM_SID *)talloc_memdup(
+ token, ptoken->user_sids, sizeof(DOM_SID) * ptoken->num_sids );
- token->num_sids = ptoken->num_sids;
+ if (token->user_sids == NULL) {
+ DEBUG(0, ("talloc_memdup failed\n"));
+ TALLOC_FREE(token);
+ return NULL;
+ }
+ token->num_sids = ptoken->num_sids;
+ }
/* copy the privileges; don't consider failure to be critical here */