diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-10-10 12:27:39 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-10-10 12:27:39 +0000 |
commit | d0d3c583615b84ac6930b809734adaf12cf8a07d (patch) | |
tree | 3cb00f401118263c2becca24dc8830ef0ad305a3 /usr.bin/tmux | |
parent | 45f3bf15f28f8351e44e2910c4c7c3652363e9de (diff) |
Don't look at string[length - 1] if length == 0.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/client.c | 6 | ||||
-rw-r--r-- | usr.bin/tmux/server-client.c | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/usr.bin/tmux/client.c b/usr.bin/tmux/client.c index c18dd09950c..6c114abaf22 100644 --- a/usr.bin/tmux/client.c +++ b/usr.bin/tmux/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.71 2013/10/10 12:26:34 nicm Exp $ */ +/* $OpenBSD: client.c,v 1.72 2013/10/10 12:27:38 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -575,7 +575,7 @@ client_dispatch_wait(void *data0) imsg_free(&imsg); return (-1); case MSG_SHELL: - if (data[datalen - 1] != '\0') + if (datalen == 0 || data[datalen - 1] != '\0') fatalx("bad MSG_SHELL string"); clear_signals(0); @@ -659,7 +659,7 @@ client_dispatch_attached(void) kill(getpid(), SIGTSTP); break; case MSG_LOCK: - if (data[datalen - 1] != '\0') + if (datalen == 0 || data[datalen - 1] != '\0') fatalx("bad MSG_LOCK string"); system(data); diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index 7426c9de375..00d6e9903b9 100644 --- a/usr.bin/tmux/server-client.c +++ b/usr.bin/tmux/server-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-client.c,v 1.109 2013/10/10 12:26:36 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.110 2013/10/10 12:27:38 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -961,12 +961,12 @@ server_client_msg_identify(struct client *c, struct imsg *imsg) c->flags |= flags; break; case MSG_IDENTIFY_TERM: - if (data[datalen - 1] != '\0') + if (datalen == 0 || data[datalen - 1] != '\0') fatalx("bad MSG_IDENTIFY_TERM string"); c->term = xstrdup(data); break; case MSG_IDENTIFY_TTYNAME: - if (data[datalen - 1] != '\0') + if (datalen == 0 || data[datalen - 1] != '\0') fatalx("bad MSG_IDENTIFY_TTYNAME string"); c->ttyname = xstrdup(data); break; @@ -981,7 +981,7 @@ server_client_msg_identify(struct client *c, struct imsg *imsg) c->fd = imsg->fd; break; case MSG_IDENTIFY_ENVIRON: - if (data[datalen - 1] != '\0') + if (datalen == 0 || data[datalen - 1] != '\0') fatalx("bad MSG_IDENTIFY_ENVIRON string"); if (strchr(data, '=') != NULL) environ_put(&c->environ, data); |