From b1a95f61f294264bd0f749e764d355f6ef843543 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Wed, 19 Mar 2014 16:19:49 -0400 Subject: [PATCH] Fix: use uri API to parse url for save command Signed-off-by: David Goulet --- src/lib/lttng-ctl/save.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/lib/lttng-ctl/save.c b/src/lib/lttng-ctl/save.c index f215468a2..d136b2d98 100644 --- a/src/lib/lttng-ctl/save.c +++ b/src/lib/lttng-ctl/save.c @@ -99,26 +99,39 @@ int lttng_save_session_attr_set_output_url( struct lttng_save_session_attr *attr, const char *url) { int ret = 0; + size_t len, size; + struct lttng_uri *uris = NULL; if (!attr) { ret = -LTTNG_ERR_INVALID; goto error; } - if (url) { - size_t len; + if (!url) { + attr->configuration_url[0] = '\0'; + ret = 0; + goto end; + } - len = strlen(url); - if (len >= PATH_MAX) { - ret = -LTTNG_ERR_INVALID; - goto error; - } + len = strlen(url); + if (len >= PATH_MAX) { + ret = -LTTNG_ERR_INVALID; + goto error; + } - strncpy(attr->configuration_url, url, len); - } else { - attr->configuration_url[0] = '\0'; + size = uri_parse_str_urls(url, NULL, &uris); + if (size <= 0 || uris[0].dtype != LTTNG_DST_PATH) { + ret = -LTTNG_ERR_INVALID; + goto error; } + + /* Copy string plus the NULL terminated byte. */ + lttng_ctl_copy_string(attr->configuration_url, uris[0].dst.path, + sizeof(attr->configuration_url)); + +end: error: + free(uris); return ret; } -- 2.34.1