From 01117e92c9674fbddd51cb9dd86909641e560166 Mon Sep 17 00:00:00 2001 From: Tomoki Shirasawa Date: Fri, 25 Dec 2015 15:50:39 +0900 Subject: [PATCH] append file path to symlink if link path is absolute refs #643 --- executer/user/mcexec.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/executer/user/mcexec.c b/executer/user/mcexec.c index 6fa966e2..fd03064d 100644 --- a/executer/user/mcexec.c +++ b/executer/user/mcexec.c @@ -483,7 +483,7 @@ retry: } if ((sb.st_mode & S_IFMT) == S_IFLNK) { - char *link_path = malloc(max_len); + link_path = malloc(max_len); if (!link_path) { fprintf(stderr, "lookup_exec_path(): error allocating\n"); return ENOMEM; @@ -498,6 +498,14 @@ retry: __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; goto retry; }