summaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-07-28 22:12:16 +0000
committerTiago Cunha <tcunha@gmx.com>2009-07-28 22:12:16 +0000
commitd637cb33da212a74636984be0ce9dfface6be6b4 (patch)
tree414de53bc14b91edcda17ee2cb99cf081440a2de /client.c
parentf5c0695605f65b7b8d0c41e0816186e979c3e130 (diff)
Sync OpenBSD patchset 181:
Make all messages sent between the client and server fixed size. This is the first of two changes to make the protocol more resilient and less sensitive to other changes in the code, particularly with commands. The client now packs argv into a buffer and sends it to the server for parsing, rather than doing it itself and sending the parsed command data. As a side-effect this also removes a lot of now-unused command marshalling code. Mixing a server without this change and a client with or vice versa will cause tmux to hang or crash, please ensure that tmux is entirely killed before upgrading.
Diffstat (limited to 'client.c')
-rw-r--r--client.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/client.c b/client.c
index 34aad32d..a7afa80e 100644
--- a/client.c
+++ b/client.c
@@ -1,4 +1,4 @@
-/* $Id: client.c,v 1.56 2009-07-23 23:47:23 tcunha Exp $ */
+/* $Id: client.c,v 1.57 2009-07-28 22:12:16 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -44,8 +44,7 @@ client_init(char *path, struct client_ctx *cctx, int cmdflags, int flags)
struct winsize ws;
size_t size;
int mode;
- struct buffer *b;
- char *name;
+ char *name, *term;
#ifdef HAVE_SETPROCTITLE
char rpathbuf[MAXPATHLEN];
#endif
@@ -107,20 +106,24 @@ server_started:
data.flags = flags;
data.sx = ws.ws_col;
data.sy = ws.ws_row;
- *data.tty = '\0';
+
if (getcwd(data.cwd, sizeof data.cwd) == NULL)
*data.cwd = '\0';
+ *data.term = '\0';
+ if ((term = getenv("TERM")) != NULL) {
+ if (strlcpy(data.term,
+ term, sizeof data.term) >= sizeof data.term)
+ *data.term = '\0';
+ }
+
+ *data.tty = '\0';
if ((name = ttyname(STDIN_FILENO)) == NULL)
fatal("ttyname failed");
if (strlcpy(data.tty, name, sizeof data.tty) >= sizeof data.tty)
fatalx("ttyname failed");
- b = buffer_create(BUFSIZ);
- cmd_send_string(b, getenv("TERM"));
- client_write_server2(cctx, MSG_IDENTIFY,
- &data, sizeof data, BUFFER_OUT(b), BUFFER_USED(b));
- buffer_destroy(b);
+ client_write_server(cctx, MSG_IDENTIFY, &data, sizeof data);
}
return (0);