X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Flib%2Flttng-ctl%2Flttng-ctl.c;h=d0deade2e5b2d0216c5012153d7b587b744ae9eb;hp=61396eb461958b179f5975f1e19f3739da13bac9;hb=62a7b8edf965b89d3ca57da120dcedfcf36dfe02;hpb=93ec662e687dc15a3601704a1e0c96c51ad228c9 diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 61396eb46..d0deade2e 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -519,10 +519,6 @@ struct lttng_handle *lttng_create_handle(const char *session_name, { struct lttng_handle *handle = NULL; - if (domain == NULL) { - goto end; - } - handle = zmalloc(sizeof(struct lttng_handle)); if (handle == NULL) { PERROR("malloc handle"); @@ -533,8 +529,10 @@ struct lttng_handle *lttng_create_handle(const char *session_name, lttng_ctl_copy_string(handle->session_name, session_name, sizeof(handle->session_name)); - /* Copy lttng domain */ - lttng_ctl_copy_lttng_domain(&handle->domain, domain); + /* Copy lttng domain or leave initialized to 0. */ + if (domain) { + lttng_ctl_copy_lttng_domain(&handle->domain, domain); + } end: return handle; @@ -736,9 +734,16 @@ int lttng_add_context(struct lttng_handle *handle, memcpy(buf + provider_len, ctx_name, ctx_len); } memcpy(&lsm.u.context.ctx, ctx, sizeof(struct lttng_event_context)); - /* Don't leak application addresses to the sessiond. */ - lsm.u.context.ctx.u.app_ctx.provider_name = NULL; - lsm.u.context.ctx.u.app_ctx.ctx_name = NULL; + + if (ctx->ctx == LTTNG_EVENT_CONTEXT_APP_CONTEXT) { + /* + * Don't leak application addresses to the sessiond. + * This is only necessary when ctx is for an app ctx otherwise + * the values inside the union (type & config) are overwritten. + */ + lsm.u.context.ctx.u.app_ctx.provider_name = NULL; + lsm.u.context.ctx.u.app_ctx.ctx_name = NULL; + } ret = lttng_ctl_ask_sessiond_varlen_no_cmd_header(&lsm, buf, len, NULL); end: @@ -1554,6 +1559,7 @@ int lttng_create_session(const char *name, const char *url) * Destroy session using name. * Returns size of returned session payload data or a negative error code. */ +static int _lttng_destroy_session(const char *session_name) { struct lttcomm_session_msg lsm;