aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tmux.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/tmux.c b/tmux.c
index b47b9025..d3495f13 100644
--- a/tmux.c
+++ b/tmux.c
@@ -1,4 +1,4 @@
-/* $Id: tmux.c,v 1.41 2007-11-16 21:12:31 nicm Exp $ */
+/* $Id: tmux.c,v 1.42 2007-11-20 12:59:27 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -219,8 +219,19 @@ main(int argc, char **argv)
"%s/%s-%lu", _PATH_TMP, __progname, (u_long) getuid());
}
if (realpath(path, rpath) == NULL) {
- log_warn("%s", path);
- exit(1);
+ if (errno != ENOENT) {
+ log_warn("%s", path);
+ exit(1);
+ }
+ /*
+ * Linux appears to fill in the buffer fine but then returns
+ * ENOENT if the file doesn't exist. But since it returns an
+ * error, we can't rely on the buffer. Grr.
+ */
+ if (strlcpy(rpath, path, sizeof rpath) >= sizeof rpath) {
+ log_warnx("%s: %s", path, strerror(ENAMETOOLONG));
+ exit(1);
+ }
}
xfree(path);