X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fcommon%2Futils.c;h=5420490a76a40f1d66d504f46e545aaebba56f78;hb=8a5422a0a990db34189f2c159820e36e0ace7dd1;hp=17a313ee16f66efe8c574ddfddc8f94f156b9e11;hpb=ec5c678a3251fa27151adcecac8372811b548bc3;p=lttng-tools.git diff --git a/src/common/utils.c b/src/common/utils.c index 17a313ee1..5420490a7 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -300,7 +300,7 @@ int expand_double_slashes_dot_and_dotdot(char *path) * Copy the current token which is neither a '.' nor a '..'. */ path[expanded_path_len++] = '/'; - memcpy(&path[expanded_path_len], curr_char, curr_token_len); + memmove(&path[expanded_path_len], curr_char, curr_token_len); expanded_path_len += curr_token_len; } @@ -547,6 +547,7 @@ void utils_close_pipe(int *src) if (ret) { PERROR("close pipe"); } + src[i] = -1; } } @@ -742,7 +743,8 @@ int utils_stream_file_path(const char *path_name, const char *file_name, char count_str[MAX_INT_DEC_LEN(count) + 1] = {}; const char *path_separator; - if (path_name && path_name[strlen(path_name) - 1] == '/') { + if (path_name && (path_name[0] == '\0' || + path_name[strlen(path_name) - 1] == '/')) { path_separator = ""; } else { path_separator = "/";