append file path to symlink if link path is absolute

refs #643
This commit is contained in:
Tomoki Shirasawa
2015-12-25 15:50:39 +09:00
parent d477096cb0
commit 01117e92c9

View File

@ -483,7 +483,7 @@ retry:
} }
if ((sb.st_mode & S_IFMT) == S_IFLNK) { if ((sb.st_mode & S_IFMT) == S_IFLNK) {
char *link_path = malloc(max_len); link_path = malloc(max_len);
if (!link_path) { if (!link_path) {
fprintf(stderr, "lookup_exec_path(): error allocating\n"); fprintf(stderr, "lookup_exec_path(): error allocating\n");
return ENOMEM; return ENOMEM;
@ -498,6 +498,14 @@ retry:
__dprintf("lookup_exec_path(): %s is link -> %s\n", path, link_path); __dprintf("lookup_exec_path(): %s is link -> %s\n", path, link_path);
if(link_path[0] != '/'){
char *t = strrchr(path, '/');
if(t){
t++;
strcpy(t, link_path);
strcpy(link_path, path);
}
}
filename = link_path; filename = link_path;
goto retry; goto retry;
} }