if (uri->stype == LTTNG_STREAM_CONTROL) {
/* On a new subdir, reappend the default trace dir. */
- strncat(consumer->subdir, default_trace_dir, sizeof(consumer->subdir));
+ strncat(consumer->subdir, default_trace_dir,
+ sizeof(consumer->subdir) - strlen(consumer->subdir) - 1);
DBG3("Append domain trace name to subdir %s", consumer->subdir);
}
sizeof(consumer->dst.trace_path));
/* Append default trace dir */
strncat(consumer->dst.trace_path, default_trace_dir,
- sizeof(consumer->dst.trace_path));
+ sizeof(consumer->dst.trace_path) -
+ strlen(consumer->dst.trace_path) - 1);
/* Flag consumer as local. */
consumer->type = CONSUMER_DST_LOCAL;
break;
/* Append default kernel trace dir to subdir */
strncat(ksess->consumer->subdir, DEFAULT_KERNEL_TRACE_DIR,
- sizeof(ksess->consumer->subdir));
+ sizeof(ksess->consumer->subdir) -
+ strlen(ksess->consumer->subdir) - 1);
/*
* @session-lock
/* Append default kernel trace dir to subdir */
strncat(usess->consumer->subdir, DEFAULT_UST_TRACE_DIR,
- sizeof(usess->consumer->subdir));
+ sizeof(usess->consumer->subdir) -
+ strlen(usess->consumer->subdir) - 1);
/*
* @session-lock
break;
case CONSUMER_DST_LOCAL:
/* Add stream file name to stream path */
- strncat(msg->u.stream.path_name, "/", sizeof(msg->u.stream.path_name));
+ strncat(msg->u.stream.path_name, "/",
+ sizeof(msg->u.stream.path_name) -
+ strlen(msg->u.stream.path_name) - 1);
strncat(msg->u.stream.path_name, msg->u.stream.name,
- sizeof(msg->u.stream.path_name));
+ sizeof(msg->u.stream.path_name) -
+ strlen(msg->u.stream.path_name) - 1);
msg->u.stream.path_name[sizeof(msg->u.stream.path_name) - 1] = '\0';
/* Indicate that the stream is NOT network */
msg->u.stream.net_index = -1;
}
/* Append correct directory to subdir */
- strncat(consumer->subdir, dir_name, sizeof(consumer->subdir));
+ strncat(consumer->subdir, dir_name,
+ sizeof(consumer->subdir) - strlen(consumer->subdir) - 1);
DBG3("Copy session consumer subdir %s", consumer->subdir);
ret = LTTCOMM_OK;