mirror of
https://github.com/tmux/tmux.git
synced 2024-11-16 01:18:52 +00:00
Call realpath earlier on the socket directory path rather than on the
socket file path because the latter may not exist yet and in that case realpath is allowed to fail. From Romain Francoise.
This commit is contained in:
parent
260419f48e
commit
d762ced298
8
tmux.c
8
tmux.c
@ -159,7 +159,7 @@ parseenvironment(void)
|
|||||||
char *
|
char *
|
||||||
makesocketpath(const char *label)
|
makesocketpath(const char *label)
|
||||||
{
|
{
|
||||||
char base[MAXPATHLEN], *path, *s;
|
char base[MAXPATHLEN], realbase[MAXPATHLEN], *path, *s;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
u_int uid;
|
u_int uid;
|
||||||
|
|
||||||
@ -183,7 +183,10 @@ makesocketpath(const char *label)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
xasprintf(&path, "%s/%s", base, label);
|
if (realpath(base, realbase) == NULL)
|
||||||
|
strlcpy(realbase, base, sizeof realbase);
|
||||||
|
|
||||||
|
xasprintf(&path, "%s/%s", realbase, label);
|
||||||
return (path);
|
return (path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,7 +387,6 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(label);
|
free(label);
|
||||||
if (realpath(path, socket_path) == NULL)
|
|
||||||
strlcpy(socket_path, path, sizeof socket_path);
|
strlcpy(socket_path, path, sizeof socket_path);
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user