This commit is contained in:
Nikita Ivanov 2022-06-21 14:41:54 +05:00
parent 5b6e333366
commit 72e5ef62c8
No known key found for this signature in database
GPG Key ID: 6E656AC5B97B5133

View File

@ -122,6 +122,25 @@ static int check_file(char **f, char *f_link)
} }
} else { } else {
f_link[f_link_len] = '\0'; 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) if (access(f_link, R_OK) == 0)
*f = f_link; *f = f_link;
} }