Skip to content
Snippets Groups Projects
Commit ee0f24a0 authored by Julian Rother's avatar Julian Rother
Browse files

Threw realpath out of buildpath

In contrast to the commandline tool "realpath" the library function
fails for any path pointing to non-existing files (even if the parent
directory exists). This breaks most use-cases for this function.
parent cbecc66c
No related branches found
No related tags found
No related merge requests found
......@@ -4,18 +4,8 @@
char *buildpath(char *root, char *path)
{
char *tmp;
if (!path)
job_failed("Cannot build path: Value is empty");
if (!(root = realpath(root, 0)))
job_failed("Building path failed: %s", strerror(errno));
tmp = mprintf("%s/%s", root, path);
if (!(path = realpath(tmp, 0)))
job_failed("Building path failed: %s", strerror(errno));
free(tmp);
if (strncmp(root, path, strlen(root)))
job_failed("Cannot build path: Path points out of root directory");
free(root);
return path;
return mprintf("%s/%s", root, path);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment