mirror of
https://github.com/tmate-io/tmate.git
synced 2025-01-23 14:28:55 +01:00
Skip exec on cmds. Also use xmemstrdup where appropriate.
This commit is contained in:
parent
ab6170d6bf
commit
a5a17b40ee
14
server-msg.c
14
server-msg.c
@ -1,4 +1,4 @@
|
||||
/* $Id: server-msg.c,v 1.18 2007-10-03 12:34:16 nicm Exp $ */
|
||||
/* $Id: server-msg.c,v 1.19 2007-10-03 13:07:42 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -398,15 +398,9 @@ server_msg_fn_bindkey(struct hdr *hdr, struct client *c)
|
||||
if (data.flags & BIND_STRING) {
|
||||
hdr->size -= sizeof data;
|
||||
|
||||
if (hdr->size != 0) {
|
||||
str = xmalloc(hdr->size + 1);
|
||||
buffer_read(c->in, str, hdr->size);
|
||||
str[hdr->size] = '\0';
|
||||
}
|
||||
if (*str == '\0') {
|
||||
xfree(str);
|
||||
str = NULL;
|
||||
}
|
||||
str = xmemstrdup(BUFFER_OUT(c->in), hdr->size);
|
||||
if (hdr->size > 0)
|
||||
buffer_remove(c->in, hdr->size);
|
||||
}
|
||||
|
||||
data.cmd[(sizeof data.cmd) - 1] = '\0';
|
||||
|
6
window.c
6
window.c
@ -1,4 +1,4 @@
|
||||
/* $Id: window.c,v 1.16 2007-10-03 10:18:32 nicm Exp $ */
|
||||
/* $Id: window.c,v 1.17 2007-10-03 13:07:42 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -104,6 +104,10 @@ window_create(const char *cmd, const char **environ, u_int sx, u_int sy)
|
||||
screen_create(&w->screen, sx, sy);
|
||||
input_init(&w->ictx, &w->screen);
|
||||
|
||||
/* XXX */
|
||||
if (strncmp(cmd, "exec ", (sizeof "exec ") - 1) == 0)
|
||||
name = xstrdup(cmd + sizeof "exec ");
|
||||
else
|
||||
name = xstrdup(cmd);
|
||||
if ((ptr = strchr(name, ' ')) != NULL) {
|
||||
if (ptr != name && ptr[-1] != '\\')
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: xmalloc.c,v 1.3 2007-09-29 14:25:49 nicm Exp $ */
|
||||
/* $Id: xmalloc.c,v 1.4 2007-10-03 13:07:42 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -75,6 +75,7 @@ xmemstrdup(const char *buf, size_t len)
|
||||
char *s;
|
||||
|
||||
s = xmalloc(len + 1);
|
||||
if (len > 0)
|
||||
memcpy(s, buf, len);
|
||||
s[len] = '\0';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user