From 4ede433e0d35dd10e8026e9e76872674eea9fd31 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 23 Nov 2011 10:49:46 +0100 Subject: [PATCH] Use realpath on trace collection path Signed-off-by: Mathieu Desnoyers --- formats/ctf/ctf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index 20f2dae0..7839bb33 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -1239,6 +1239,7 @@ int ctf_open_trace_read(struct ctf_trace *td, const char *collection_path, struct dirent *dirent; struct dirent *diriter; size_t dirent_len; + char *respath; td->flags = flags; @@ -1257,8 +1258,11 @@ int ctf_open_trace_read(struct ctf_trace *td, const char *collection_path, ret = -errno; goto error_dirfd; } - strncpy(td->collection_path, collection_path, PATH_MAX); - td->collection_path[PATH_MAX - 1] = '\0'; + respath = realpath(collection_path, td->collection_path); + if (!respath) { + fprintf(stdout, "[error] path resolution failure\n"); + return -EINVAL; + } strncpy(td->path, path, PATH_MAX); td->path[PATH_MAX - 1] = '\0'; init_domain_name(td); -- 2.34.1