bt_common_parse_lttng_live_url(): don't accept `net://RDHOST/host/TGTHOST`
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 17 Aug 2019 00:02:33 +0000 (20:02 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 17 Aug 2019 05:31:12 +0000 (01:31 -0400)
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 <eeppeliteloop@gmail.com>
Change-Id: I68a804c69ec557ed9cc77c9020afbbe2f79a7c43
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1961
Tested-by: jenkins <jenkins@lttng.org>
src/common/common.c

index b2b76cde1c0ec17107c45bef72151a4d9d91c51a..8961475fc5a91dea011205624035db56d5866d3c 100644 (file)
@@ -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 */
This page took 0.025758 seconds and 4 git commands to generate.