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.
This commit is contained in:
Tiago Cunha
2009-07-28 22:12:16 +00:00
parent f5c0695605
commit d637cb33da
82 changed files with 335 additions and 862 deletions

View File

@ -1,4 +1,4 @@
/* $Id: cmd-if-shell.c,v 1.3 2009-07-14 06:43:32 nicm Exp $ */
/* $Id: cmd-if-shell.c,v 1.4 2009-07-28 22:12:16 tcunha Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@ -30,8 +30,6 @@
int cmd_if_shell_parse(struct cmd *, int, char **, char **);
int cmd_if_shell_exec(struct cmd *, struct cmd_ctx *);
void cmd_if_shell_send(struct cmd *, struct buffer *);
void cmd_if_shell_recv(struct cmd *, struct buffer *);
void cmd_if_shell_free(struct cmd *);
void cmd_if_shell_init(struct cmd *, int);
size_t cmd_if_shell_print(struct cmd *, char *, size_t);
@ -48,8 +46,6 @@ const struct cmd_entry cmd_if_shell_entry = {
cmd_if_shell_init,
cmd_if_shell_parse,
cmd_if_shell_exec,
cmd_if_shell_send,
cmd_if_shell_recv,
cmd_if_shell_free,
cmd_if_shell_print
};
@ -126,27 +122,6 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
return (0);
}
void
cmd_if_shell_send(struct cmd *self, struct buffer *b)
{
struct cmd_if_shell_data *data = self->data;
buffer_write(b, data, sizeof *data);
cmd_send_string(b, data->cmd);
cmd_send_string(b, data->sh_cmd);
}
void
cmd_if_shell_recv(struct cmd *self, struct buffer *b)
{
struct cmd_if_shell_data *data;
self->data = data = xmalloc(sizeof *data);
buffer_read(b, data, sizeof *data);
data->cmd = cmd_recv_string(b);
data->sh_cmd = cmd_recv_string(b);
}
void
cmd_if_shell_free(struct cmd *self)
{