diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2014-01-09 14:05:56 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2014-01-09 14:05:56 +0000 |
commit | 834c01a59e6ba29093ea41942faf4a5e4e86100f (patch) | |
tree | d4043b979b2e4e684fa08152761cae4197dbc4e9 /usr.bin | |
parent | e0360d0a1ab8ae6a77212b9b70b1864b45e68b97 (diff) |
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.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/client.c | 5 | ||||
-rw-r--r-- | usr.bin/tmux/screen.c | 8 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.c | 8 |
3 files changed, 11 insertions, 10 deletions
diff --git a/usr.bin/tmux/client.c b/usr.bin/tmux/client.c index db938a082fc..0d0aeac405d 100644 --- a/usr.bin/tmux/client.c +++ b/usr.bin/tmux/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.76 2013/11/13 20:43:36 benno Exp $ */ +/* $OpenBSD: client.c,v 1.77 2014/01/09 14:05:55 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -232,7 +232,8 @@ client_main(int argc, char **argv, int flags) /* Initialise the client socket and start the server. */ fd = client_connect(socket_path, cmdflags & CMD_STARTSERVER); if (fd == -1) { - fprintf(stderr, "failed to connect to server\n"); + fprintf(stderr, "failed to connect to server: %s\n", + strerror(errno)); return (1); } diff --git a/usr.bin/tmux/screen.c b/usr.bin/tmux/screen.c index 408c2818f18..8a571b30e5e 100644 --- a/usr.bin/tmux/screen.c +++ b/usr.bin/tmux/screen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen.c,v 1.26 2013/05/15 15:39:51 nicm Exp $ */ +/* $OpenBSD: screen.c,v 1.27 2014/01/09 14:05:55 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -110,12 +110,8 @@ screen_set_cursor_colour(struct screen *s, const char *colour_string) void screen_set_title(struct screen *s, const char *title) { - char tmp[BUFSIZ]; - - strlcpy(tmp, title, sizeof tmp); - free(s->title); - s->title = xstrdup(tmp); + s->title = xstrdup(title); } /* Resize screen. */ diff --git a/usr.bin/tmux/tmux.c b/usr.bin/tmux/tmux.c index 23aab622f1e..03a07c0af79 100644 --- a/usr.bin/tmux/tmux.c +++ b/usr.bin/tmux/tmux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.c,v 1.126 2013/10/10 12:29:35 nicm Exp $ */ +/* $OpenBSD: tmux.c,v 1.127 2014/01/09 14:05:55 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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. */ |