The remain[2] array is being used uninitialized when such URI is used:
`net://localhost:1234`.
The following line (142) will return 1:
`ret = sscanf(remain[0], ":%d%s", &ctx->port, remain[1]);`
because `sscanf` won't match on the string (%s) delimiter.
This will leave `remain[2]` uninitialized.
This potentially uninitialized array is being used further down the function.
As a fix, we zero out the array at initialization time to prevent the
`strlen(remain[2])` call from using uninitialized memory.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
static
int parse_url(const char *path, struct lttng_live_ctx *ctx)
{
- char remain[3][MAXNAMLEN];
+ char remain[3][MAXNAMLEN] = { 0 };
int ret = -1, proto, proto_offset = 0;
size_t path_len = strlen(path); /* not accounting \0 */
if (ret != 2) {
fprintf(stderr, "[error] Format : "
"net://<hostname>/host/<traced_hostname>/<session_name>\n");
+ ret = -1;
goto end;
}