r3988: made dom_sid_add_rid() allocate the new sid with proper parent/child talloc
authorAndrew Tridgell <tridge@samba.org>
Mon, 29 Nov 2004 03:19:28 +0000 (03:19 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:06:11 +0000 (13:06 -0500)
relationship

source/libcli/security/dom_sid.c

index dbd03108e49d0e60658a2e5f9e5fac521e00ed5b..108e2f550077c7ec49248651ffc8e25f7fdd0cd6 100644 (file)
@@ -217,7 +217,8 @@ struct dom_sid *dom_sid_dup(TALLOC_CTX *mem_ctx, const struct dom_sid *dom_sid)
 }
 
 /*
-  add a rid to a domain dom_sid to make a full dom_sid
+  add a rid to a domain dom_sid to make a full dom_sid. This function
+  returns a new sid in the suppplied memory context
 */
 struct dom_sid *dom_sid_add_rid(TALLOC_CTX *mem_ctx, 
                                const struct dom_sid *domain_sid, 
@@ -229,14 +230,15 @@ struct dom_sid *dom_sid_add_rid(TALLOC_CTX *mem_ctx,
        if (!sid) return NULL;
 
        *sid = *domain_sid;
-       /*TODO: use realloc! */
-       sid->sub_auths = talloc_array_p(mem_ctx, uint32_t, sid->num_auths+1);
+
+       sid->sub_auths = talloc_array_p(sid, uint32_t, sid->num_auths+1);
        if (!sid->sub_auths) {
                return NULL;
        }
        memcpy(sid->sub_auths, domain_sid->sub_auths, sid->num_auths*sizeof(uint32_t));
        sid->sub_auths[sid->num_auths] = rid;
        sid->num_auths++;
+
        return sid;
 }