MFC: r279364
Use realpath(3) to properly expand $ORIGIN to its absolute path.
This commit is contained in:
parent
b6bec41c3d
commit
88fa6bbce5
@ -3420,17 +3420,16 @@ rtld_dirname(const char *path, char *bname)
|
||||
static int
|
||||
rtld_dirname_abs(const char *path, char *base)
|
||||
{
|
||||
char base_rel[PATH_MAX];
|
||||
char *last;
|
||||
|
||||
if (rtld_dirname(path, base) == -1)
|
||||
if (realpath(path, base) == NULL)
|
||||
return (-1);
|
||||
if (base[0] == '/')
|
||||
return (0);
|
||||
if (getcwd(base_rel, sizeof(base_rel)) == NULL ||
|
||||
strlcat(base_rel, "/", sizeof(base_rel)) >= sizeof(base_rel) ||
|
||||
strlcat(base_rel, base, sizeof(base_rel)) >= sizeof(base_rel))
|
||||
dbg("%s -> %s", path, base);
|
||||
last = strrchr(base, '/');
|
||||
if (last == NULL)
|
||||
return (-1);
|
||||
strcpy(base, base_rel);
|
||||
if (last != base)
|
||||
*last = '\0';
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user