From 87cd0f0b350a1ca1c65e98770d9a487e698eb37e Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Fri, 16 Aug 2019 20:02:33 -0400 Subject: [PATCH] bt_common_parse_lttng_live_url(): don't accept `net://RDHOST/host/TGTHOST` This patch makes the bt_common_parse_lttng_live_url() function not accept LTTng live URLs with the form: net[4]://RDHOST[:RDPORT]/host/TGTHOST This was previously accepted for the session listing feature, but in fact the `babeltrace` program (Babeltrace 1) only accepts this form: net[4]://RDHOST[:RDPORT] and the list of URLs that the `babeltrace2` program prints with the first form is invalid. Signed-off-by: Philippe Proulx Change-Id: I68a804c69ec557ed9cc77c9020afbbe2f79a7c43 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1961 Tested-by: jenkins --- src/common/common.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/common/common.c b/src/common/common.c index b2b76cde..8961475f 100644 --- a/src/common/common.c +++ b/src/common/common.c @@ -673,7 +673,7 @@ struct bt_common_lttng_live_url_parts bt_common_parse_lttng_live_url( at += end_pos; - /* :// */ + /* `://` */ if (strncmp(at, "://", 3) != 0) { if (error_buf) { snprintf(error_buf, error_buf_size, @@ -683,6 +683,7 @@ struct bt_common_lttng_live_url_parts bt_common_parse_lttng_live_url( goto error; } + /* Skip `://` */ at += 3; /* Hostname */ @@ -732,12 +733,13 @@ struct bt_common_lttng_live_url_parts bt_common_parse_lttng_live_url( } if (at[end_pos] == '\0') { + /* Relay daemon hostname and ports provided only */ goto end; } at += end_pos; - /* /host/ */ + /* `/host/` */ if (strncmp(at, "/host/", 6) != 0) { if (error_buf) { snprintf(error_buf, error_buf_size, @@ -761,9 +763,16 @@ struct bt_common_lttng_live_url_parts bt_common_parse_lttng_live_url( } if (at[end_pos] == '\0') { - goto end; + if (error_buf) { + snprintf(error_buf, error_buf_size, + "Missing `/` after target hostname (`%s`)", + parts.target_hostname->str); + } + + goto error; } + /* Skip `/` */ at += end_pos + 1; /* Session name */ -- 2.34.1