Skip to content

Commit

Permalink
patch 8.0.0954: /proc/self/exe might be a relative path
Browse files Browse the repository at this point in the history
Problem:    /proc/self/exe might be a relative path.
Solution:   Make the path a full path. (James McCoy, closes #1983)
  • Loading branch information
brammool committed Aug 17, 2017
1 parent f5be7cd commit bc906e4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
35 changes: 17 additions & 18 deletions src/main.c
Expand Up @@ -3597,36 +3597,35 @@ set_progpath(char_u *argv0)
{ {
char_u *val = argv0; char_u *val = argv0;


# ifdef PROC_EXE_LINK # if defined(WIN32)
char buf[MAXPATHL + 1];
ssize_t len;

len = readlink(PROC_EXE_LINK, buf, MAXPATHL);
if (len > 0)
{
buf[len] = NUL;
val = (char_u *)buf;
}
# else
/* A relative path containing a "/" will become invalid when using ":cd", /* A relative path containing a "/" will become invalid when using ":cd",
* turn it into a full path. * turn it into a full path.
* On MS-Windows "vim" should be expanded to "vim.exe", thus always do * On MS-Windows "vim" should be expanded to "vim.exe", thus always do
* this. */ * this. */
# ifdef WIN32
char_u *path = NULL; char_u *path = NULL;


if (mch_can_exe(argv0, &path, FALSE) && path != NULL) if (mch_can_exe(argv0, &path, FALSE) && path != NULL)
val = path; val = path;
# else # else
char_u buf[MAXPATHL]; char_u buf[MAXPATHL + 1];
# ifdef PROC_EXE_LINK
char linkbuf[MAXPATHL + 1];
ssize_t len;


if (!mch_isFullName(argv0)) len = readlink(PROC_EXE_LINK, linkbuf, MAXPATHL);
if (len > 0)
{ {
if (gettail(argv0) != argv0 linkbuf[len] = NUL;
&& vim_FullName(argv0, buf, MAXPATHL, TRUE) != FAIL) val = (char_u *)linkbuf;
val = buf;
} }
# endif # endif

if (!mch_isFullName(val))
{
if (gettail(val) != val
&& vim_FullName(val, buf, MAXPATHL, TRUE) != FAIL)
val = buf;
}
# endif # endif


set_vim_var_string(VV_PROGPATH, val, -1); set_vim_var_string(VV_PROGPATH, val, -1);
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -769,6 +769,8 @@ static char *(features[]) =


static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
954,
/**/ /**/
953, 953,
/**/ /**/
Expand Down

0 comments on commit bc906e4

Please sign in to comment.