X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Furi.c;h=4af94072cb6100ab99e70228087022a20840e560;hb=4b29f1cec9f8e93d4dde0c982f30e3201f0f4e65;hp=8d7cf9074beb02ab5f9981edd1f790dfd042070d;hpb=bc89445574c5bef2a905f213c3a615ea559bd4c8;p=lttng-tools.git diff --git a/src/common/uri.c b/src/common/uri.c index 8d7cf9074..4af94072c 100644 --- a/src/common/uri.c +++ b/src/common/uri.c @@ -186,7 +186,7 @@ int uri_to_str_url(struct lttng_uri *uri, char *dst, size_t size) { int ipver, ret; const char *addr; - char proto[4], port[7]; + char proto[5], port[7]; assert(uri); assert(dst); @@ -194,13 +194,13 @@ int uri_to_str_url(struct lttng_uri *uri, char *dst, size_t size) if (uri->dtype == LTTNG_DST_PATH) { ipver = 0; addr = uri->dst.path; - (void) snprintf(proto, sizeof(proto), "file"); - (void) snprintf(port, sizeof(port), "%s", ""); + (void) snprintf(proto, sizeof(proto) + 1, "file"); + (void) snprintf(port, sizeof(port) + 1, "%s", ""); } else { ipver = (uri->dtype == LTTNG_DST_IPV4) ? 4 : 6; addr = (ipver == 4) ? uri->dst.ipv4 : uri->dst.ipv6; - (void) snprintf(proto, sizeof(proto), "net%d", ipver); - (void) snprintf(port, sizeof(port), ":%d", uri->port); + (void) snprintf(proto, sizeof(proto) + 1, "net%d", ipver); + (void) snprintf(port, sizeof(port) + 1, ":%d", uri->port); } ret = snprintf(dst, size, "%s://%s%s%s%s/%s", proto,