From: Mathieu Desnoyers Date: Wed, 23 Nov 2011 09:49:46 +0000 (+0100) Subject: Use realpath on trace collection path X-Git-Tag: v0.8~8 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=4ede433e0d35dd10e8026e9e76872674eea9fd31;hp=e38f07e9fae685c92366a0492f234c5576abdd63 Use realpath on trace collection path Signed-off-by: Mathieu Desnoyers --- 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);