summaryrefslogtreecommitdiff
path: root/source3/services
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2010-09-20 04:58:27 +0200
committerMichael Adam <obnox@samba.org>2010-09-21 06:53:31 +0200
commite464ca9f311e3becd5f88f41fa7a95520fe6fbc3 (patch)
tree5a81956bb2412b0cbdabd80125b3f94d20165867 /source3/services
parenta4b1042f33b505dcb51ac25bf84a597d98fa9d4b (diff)
downloadsamba-e464ca9f311e3becd5f88f41fa7a95520fe6fbc3.tar.gz
s3:services_db: make svcctl_lookup_dispname() use a temp talloc ctx
Diffstat (limited to 'source3/services')
-rw-r--r--source3/services/services_db.c24
1 files 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;
}
/********************************************************************