Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 302be44

Browse files
committed
When following symlinks to the real executable, use a loop so a
symlink to a symlink can work. (Jack)
1 parent 91eeefd commit 302be44

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Modules/getpath.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ calculate_path()
437437
{
438438
char tmpbuffer[MAXPATHLEN+1];
439439
int linklen = readlink(progpath, tmpbuffer, MAXPATHLEN);
440-
if (linklen != -1) {
440+
while (linklen != -1) {
441441
/* It's not null terminated! */
442442
tmpbuffer[linklen] = '\0';
443443
if (tmpbuffer[0] == SEP)
@@ -447,6 +447,7 @@ calculate_path()
447447
reduce(argv0_path);
448448
joinpath(argv0_path, tmpbuffer);
449449
}
450+
linklen = readlink(argv0_path, tmpbuffer, MAXPATHLEN);
450451
}
451452
}
452453
#endif /* HAVE_READLINK */

0 commit comments

Comments
 (0)