loadparm: Allocate service->copymap in service memory context
authorKamen Mazdrashki <kamenim@samba.org>
Wed, 10 Sep 2014 01:14:42 +0000 (03:14 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 1 Oct 2014 09:21:38 +0000 (11:21 +0200)
This patch adds a restriction that target service structure
must be a valid TALLOC_CTX memory context.

I have traced all call paths and at the moment this is the case,
pservice parameter layways gets allocated on TALLOC_CTX.

Signed-off-by: Kamen Mazdrashki <kamenim@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/param/loadparm.c

index 9953053..218ef69 100644 (file)
@@ -1376,13 +1376,17 @@ bool handle_smb_ports(struct loadparm_context *lp_ctx, struct loadparm_service *
  Initialise a copymap.
 ***************************************************************************/
 
+/**
+ * Initializes service copymap
+ * Note: pservice *must* be valid TALLOC_CTX
+ */
 void init_copymap(struct loadparm_service *pservice)
 {
        int i;
 
        TALLOC_FREE(pservice->copymap);
 
-       pservice->copymap = bitmap_talloc(NULL, num_parameters());
+       pservice->copymap = bitmap_talloc(pservice, num_parameters());
        if (!pservice->copymap)
                DEBUG(0,
                      ("Couldn't allocate copymap!! (size %d)\n",