summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
2f77fc4)
When using strncat, the size_t n argument must indicate the left over
space remaining in the buffer, *not* the total buffer size. Also, proper
care must be taken for the case where src contains n or more bytes and
thus allow space for the null terminating byte appended to dest (e.g.
strncat() will write n+1 bytes).
Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
if (uri->stype == LTTNG_STREAM_CONTROL) {
/* On a new subdir, reappend the default trace dir. */
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);
}
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));
/* 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;
/* 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,
/* 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);
/* Append default kernel trace dir to subdir */
strncat(usess->consumer->subdir, DEFAULT_UST_TRACE_DIR,
/* 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);
break;
case CONSUMER_DST_LOCAL:
/* Add stream file name to stream path */
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,
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;
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 */
}
/* 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;
DBG3("Copy session consumer subdir %s", consumer->subdir);
ret = LTTCOMM_OK;
}
/* Add end part to expanded path */
}
/* Add end part to expanded path */
- strncat(expanded_path, end_path, PATH_MAX);
+ strncat(expanded_path, end_path, PATH_MAX - strlen(expanded_path) - 1);
free(cut_path);
return expanded_path;
free(cut_path);
return expanded_path;