From 72e5ef62c879dc2de7c9a40b35e4c1d57440db0a Mon Sep 17 00:00:00 2001 From: Nikita Ivanov Date: Tue, 21 Jun 2022 14:41:54 +0500 Subject: [PATCH] Fix --- src/ctpv.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/ctpv.c b/src/ctpv.c index da1f408..d13c4e6 100644 --- a/src/ctpv.c +++ b/src/ctpv.c @@ -122,6 +122,25 @@ static int check_file(char **f, char *f_link) } } else { f_link[f_link_len] = '\0'; + + /* If link is not an absolute path, get absolute path */ + if (f_link[0] != '/') { + char f_link_tmp[FILENAME_MAX]; + strncpy(f_link_tmp, f_link, f_link_len); + + ERRCHK_RET_ERN(getcwd(f_link, FILENAME_MAX) == NULL); + + f_link_len = strlen(f_link); + + if (f_link[f_link_len-1] != '/') { + f_link[f_link_len] = '/'; + f_link[f_link_len+1] = '\0'; + f_link_len++; + } + + strcpy(f_link + f_link_len, f_link_tmp); + } + if (access(f_link, R_OK) == 0) *f = f_link; }