From adc1f21eaee899b8ecfdb6ef3676d9a25019e4fa Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 9 Jan 2014 14:05:55 +0000 Subject: Three small changes from Tiago Cunha: - Check for truncation when copying path. - Don't need to use a temporary buffer in screen_set_title. - Include strerror in output when connecting to server fails. --- tmux.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tmux.c') diff --git a/tmux.c b/tmux.c index 74d827a5..c8f9e059 100644 --- a/tmux.c +++ b/tmux.c @@ -361,7 +361,11 @@ main(int argc, char **argv) } } free(label); - strlcpy(socket_path, path, sizeof socket_path); + + if (strlcpy(socket_path, path, sizeof socket_path) >= sizeof socket_path) { + fprintf(stderr, "socket path too long: %s\n", path); + exit(1); + } free(path); /* Set process title. */ -- cgit From 938768ed3de3e38cb96344b8ec7b794b5e828acf Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 15 Jan 2014 11:46:28 +0000 Subject: Do not attempt to read .tmux.conf if we can't figure out a home directory, from Tiago Cunha. --- tmux.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'tmux.c') diff --git a/tmux.c b/tmux.c index c8f9e059..d4848396 100644 --- a/tmux.c +++ b/tmux.c @@ -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; + } } } -- cgit