From fa2f6809c95c37db1461a1e9ed15514dd3e9513d Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 18 Dec 2017 22:13:36 +0000 Subject: [PATCH] Do not try to put more in command message than will fit when sending (the server will treat as a fatal error). GitHub issue 1200. --- usr.bin/tmux/client.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/usr.bin/tmux/client.c b/usr.bin/tmux/client.c index 17f10a5e100..152b9c883e9 100644 --- a/usr.bin/tmux/client.c +++ b/usr.bin/tmux/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.123 2017/07/14 18:49:07 nicm Exp $ */ +/* $OpenBSD: client.c,v 1.124 2017/12/18 22:13:36 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -337,6 +337,10 @@ client_main(struct event_base *base, int argc, char **argv, int flags) size = 0; for (i = 0; i < argc; i++) size += strlen(argv[i]) + 1; + if (size > MAX_IMSGSIZE - (sizeof *data)) { + fprintf(stderr, "command too long\n"); + return (1); + } data = xmalloc((sizeof *data) + size); /* Prepare command for server. */ -- 2.20.1