summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/tmux.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2014-01-15 11:46:28 +0000
committernicm <nicm@openbsd.org>2014-01-15 11:46:28 +0000
commitb533f7ee26cc158f0540fe5f53b8d86e470909a3 (patch)
tree7ab1d7c42a9eb405998cdc9eafab208f1394ca16 /usr.bin/tmux/tmux.c
parentCouple of fixes from cppcheck via Tiago Cunha. (diff)
downloadwireguard-openbsd-b533f7ee26cc158f0540fe5f53b8d86e470909a3.tar.xz
wireguard-openbsd-b533f7ee26cc158f0540fe5f53b8d86e470909a3.zip
Do not attempt to read .tmux.conf if we can't figure out a home
directory, from Tiago Cunha.
Diffstat (limited to 'usr.bin/tmux/tmux.c')
-rw-r--r--usr.bin/tmux/tmux.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c
index 03a07c0af79..f74d4995524 100644
--- a/usr.bin/tmux/tmux.c
+++ b/usr.bin/tmux/tmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.c,v 1.127 2014/01/09 14:05:55 nicm Exp $ */
+/* $OpenBSD: tmux.c,v 1.128 2014/01/15 11:46:28 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -202,8 +202,9 @@ int
main(int argc, char **argv)
{
struct passwd *pw;
- char *s, *path, *label, *home, **var, tmp[MAXPATHLEN];
+ char *s, *path, *label, **var, tmp[MAXPATHLEN];
char in[256];
+ const char *home;
long long pid;
int opt, flags, quiet, keys, session;
@@ -325,11 +326,15 @@ main(int argc, char **argv)
pw = getpwuid(getuid());
if (pw != NULL)
home = pw->pw_dir;
+ else
+ home = NULL;
}
- xasprintf(&cfg_file, "%s/.tmux.conf", home);
- if (access(cfg_file, R_OK) != 0 && errno == ENOENT) {
- free(cfg_file);
- cfg_file = NULL;
+ if (home != NULL) {
+ xasprintf(&cfg_file, "%s/.tmux.conf", home);
+ if (access(cfg_file, R_OK) != 0 && errno == ENOENT) {
+ free(cfg_file);
+ cfg_file = NULL;
+ }
}
}