Permalink
Browse files

patch 8.0.0954: /proc/self/exe might be a relative path

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 bc906e445c77eb4fb5ef97465a45b46499bba111
Showing with 19 additions and 18 deletions.
  1. +17 −18 src/main.c
  2. +2 −0 src/version.c
View
@@ -3597,36 +3597,35 @@ set_progpath(char_u *argv0)
{
char_u *val = argv0;
# ifdef PROC_EXE_LINK
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
# if defined(WIN32)
/* A relative path containing a "/" will become invalid when using ":cd",
* turn it into a full path.
* On MS-Windows "vim" should be expanded to "vim.exe", thus always do
* this. */
# ifdef WIN32
char_u *path = NULL;
if (mch_can_exe(argv0, &path, FALSE) && path != NULL)
val = path;
# else
char_u buf[MAXPATHL];
# else
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
&& vim_FullName(argv0, buf, MAXPATHL, TRUE) != FAIL)
val = buf;
linkbuf[len] = NUL;
val = (char_u *)linkbuf;
}
# endif
if (!mch_isFullName(val))
{
if (gettail(val) != val
&& vim_FullName(val, buf, MAXPATHL, TRUE) != FAIL)
val = buf;
}
# endif
set_vim_var_string(VV_PROGPATH, val, -1);
View
@@ -769,6 +769,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
954,
/**/
953,
/**/

0 comments on commit bc906e4

Please sign in to comment.