From 61ab5b46cfb93939651b4426016845a035315bf7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 1 Jun 2000 18:17:22 +0000 Subject: Back to building. Now to test with insure. Added some frees needed to stop memory leaks. Jeremy. (This used to be commit eba31e4e802120c9eb8c4688f521b4de9cb91f5c) --- source3/rpc_parse/parse_sec.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'source3/rpc_parse/parse_sec.c') diff --git a/source3/rpc_parse/parse_sec.c b/source3/rpc_parse/parse_sec.c index 76e246ca9e..2aba894834 100644 --- a/source3/rpc_parse/parse_sec.c +++ b/source3/rpc_parse/parse_sec.c @@ -250,18 +250,41 @@ BOOL sec_io_acl(char *desc, SEC_ACL **ppsa, prs_struct *ps, int depth) return True; } +/******************************************************************* + Works out the linearization size of a SEC_DESC. +********************************************************************/ + +size_t sec_desc_size(SEC_DESC *psd) +{ + size_t offset = SD_HEADER_SIZE; + + if (psd->owner_sid != NULL) + offset += ((sid_size(psd->owner_sid) + 3) & ~3); + + if (psd->grp_sid != NULL) + offset += ((sid_size(psd->grp_sid) + 3) & ~3); + + if (psd->sacl != NULL) + offset += ((psd->sacl->size + 3) & ~3); + + if (psd->dacl != NULL) + offset += ((psd->dacl->size + 3) & ~3); + + return offset; +} + /******************************************************************* Creates a SEC_DESC structure ********************************************************************/ SEC_DESC *make_sec_desc(uint16 revision, uint16 type, DOM_SID *owner_sid, DOM_SID *grp_sid, - SEC_ACL *sacl, SEC_ACL *dacl, size_t *sec_desc_size) + SEC_ACL *sacl, SEC_ACL *dacl, size_t *sd_size) { SEC_DESC *dst; uint32 offset; - *sec_desc_size = 0; + *sd_size = 0; if(( dst = (SEC_DESC *)malloc(sizeof(SEC_DESC))) == NULL) return NULL; @@ -288,7 +311,7 @@ SEC_DESC *make_sec_desc(uint16 revision, uint16 type, if(dacl && ((dst->dacl = dup_sec_acl(dacl)) == NULL)) goto error_exit; - offset = 0x0; + offset = 0; /* * Work out the linearization sizes. @@ -330,12 +353,12 @@ SEC_DESC *make_sec_desc(uint16 revision, uint16 type, offset += ((dacl->size + 3) & ~3); } - *sec_desc_size = (size_t)((offset == 0) ? SD_HEADER_SIZE : offset); + *sd_size = (size_t)((offset == 0) ? SD_HEADER_SIZE : offset); return dst; error_exit: - *sec_desc_size = 0; + *sd_size = 0; free_sec_desc(&dst); return NULL; } @@ -382,10 +405,10 @@ void free_sec_desc(SEC_DESC **ppsd) ********************************************************************/ SEC_DESC *make_standard_sec_desc(DOM_SID *owner_sid, DOM_SID *grp_sid, - SEC_ACL *dacl, size_t *sec_desc_size) + SEC_ACL *dacl, size_t *sd_size) { return make_sec_desc(1, SEC_DESC_SELF_RELATIVE|SEC_DESC_DACL_PRESENT, - owner_sid, grp_sid, NULL, dacl, sec_desc_size); + owner_sid, grp_sid, NULL, dacl, sd_size); } -- cgit