From 6cb652e05c177377ba67b63d7d820f087cc05a46 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Wed, 14 Oct 2009 00:54:52 -0500 Subject: s4:ldb - fixed dangling pointer in ldb_request_add_control() --- source4/lib/ldb/common/ldb_controls.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb') diff --git a/source4/lib/ldb/common/ldb_controls.c b/source4/lib/ldb/common/ldb_controls.c index 32b2c0f66d..a8dd6b5859 100644 --- a/source4/lib/ldb/common/ldb_controls.c +++ b/source4/lib/ldb/common/ldb_controls.c @@ -123,7 +123,7 @@ int check_critical_controls(struct ldb_control **controls) int ldb_request_add_control(struct ldb_request *req, const char *oid, bool critical, void *data) { - unsigned n; + unsigned i, n; struct ldb_control **ctrls; struct ldb_control *ctrl; @@ -135,10 +135,15 @@ int ldb_request_add_control(struct ldb_request *req, const char *oid, bool criti n++; } - ctrls = talloc_realloc(req, req->controls, + ctrls = talloc_array(req, struct ldb_control *, n + 2); if (!ctrls) return LDB_ERR_OPERATIONS_ERROR; + + for (i=0; icontrols[i]; + } + req->controls = ctrls; ctrls[n] = NULL; ctrls[n+1] = NULL; -- cgit