From e464ca9f311e3becd5f88f41fa7a95520fe6fbc3 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 20 Sep 2010 04:58:27 +0200 Subject: [PATCH 1/1] s3:services_db: make svcctl_lookup_dispname() use a temp talloc ctx --- source3/services/services_db.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/source3/services/services_db.c b/source3/services/services_db.c index 118091f6826..ee565001584 100644 --- a/source3/services/services_db.c +++ b/source3/services/services_db.c @@ -629,26 +629,23 @@ const char *svcctl_lookup_dispname(TALLOC_CTX *ctx, const char *name, struct sec char *path = NULL; WERROR wresult; DATA_BLOB blob; + TALLOC_CTX *mem_ctx = talloc_stackframe(); - /* now add the security descriptor */ - - if (asprintf(&path, "%s\\%s", KEY_SERVICES, name) < 0) { - return NULL; + path = talloc_asprintf(mem_ctx, "%s\\%s", KEY_SERVICES, name); + if (path == NULL) { + goto done; } - wresult = regkey_open_internal( NULL, &key, path, token, + wresult = regkey_open_internal(mem_ctx, &key, path, token, REG_KEY_READ ); if ( !W_ERROR_IS_OK(wresult) ) { DEBUG(0,("svcctl_lookup_dispname: key lookup failed! [%s] (%s)\n", path, win_errstr(wresult))); - SAFE_FREE(path); goto fail; } - SAFE_FREE(path); wresult = regval_ctr_init(key, &values); if (!W_ERROR_IS_OK(wresult)) { DEBUG(0,("svcctl_lookup_dispname: talloc() failed!\n")); - TALLOC_FREE( key ); goto fail; } @@ -660,14 +657,15 @@ const char *svcctl_lookup_dispname(TALLOC_CTX *ctx, const char *name, struct sec blob = data_blob_const(regval_data_p(val), regval_size(val)); pull_reg_sz(ctx, &blob, &display_name); - TALLOC_FREE( key ); - - return display_name; + goto done; fail: /* default to returning the service name */ - TALLOC_FREE( key ); - return talloc_strdup(ctx, name); + display_name = talloc_strdup(ctx, name); + +done: + talloc_free(mem_ctx); + return display_name; } /******************************************************************** -- 2.34.1