s4-dsdb: Use ldb_dn_copy() rather than talloc_reference()
authorAndrew Bartlett <abartlet@samba.org>
Tue, 14 Aug 2012 07:49:12 +0000 (17:49 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 14 Aug 2012 13:37:22 +0000 (15:37 +0200)
As the normal case (outside provision) uses a copy, this avoids a case
where a caller might modify a global variable accidentily.

As suggested by metze.

Andrew Bartlett

source4/dsdb/common/util.c

index fd54e4adb94d9af4f1b33951e6960df372430620..565dc3630633e3d3009a9ae0c3cc786b98e08bd8 100644 (file)
@@ -1252,7 +1252,7 @@ struct ldb_dn *samdb_ntds_settings_dn(struct ldb_context *ldb, TALLOC_CTX *mem_c
        /* see if we have a cached copy */
        settings_dn = (struct ldb_dn *)ldb_get_opaque(ldb, "forced.ntds_settings_dn");
        if (settings_dn) {
-               return talloc_reference(mem_ctx, settings_dn);
+               return ldb_dn_copy(mem_ctx, settings_dn);
        }
 
        tmp_ctx = talloc_new(mem_ctx);