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.
This commit is contained in:
nicm 2014-01-09 14:05:55 +00:00
parent 994cb872cf
commit adc1f21eae
3 changed files with 8 additions and 7 deletions

View File

@ -232,7 +232,8 @@ client_main(int argc, char **argv, int flags)
/* Initialise the client socket and start the server. */ /* Initialise the client socket and start the server. */
fd = client_connect(socket_path, cmdflags & CMD_STARTSERVER); fd = client_connect(socket_path, cmdflags & CMD_STARTSERVER);
if (fd == -1) { if (fd == -1) {
fprintf(stderr, "failed to connect to server\n"); fprintf(stderr, "failed to connect to server: %s\n",
strerror(errno));
return (1); return (1);
} }

View File

@ -110,12 +110,8 @@ screen_set_cursor_colour(struct screen *s, const char *colour_string)
void void
screen_set_title(struct screen *s, const char *title) screen_set_title(struct screen *s, const char *title)
{ {
char tmp[BUFSIZ];
strlcpy(tmp, title, sizeof tmp);
free(s->title); free(s->title);
s->title = xstrdup(tmp); s->title = xstrdup(title);
} }
/* Resize screen. */ /* Resize screen. */

6
tmux.c
View File

@ -361,7 +361,11 @@ main(int argc, char **argv)
} }
} }
free(label); 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); free(path);
/* Set process title. */ /* Set process title. */