From 7340d5adfdc8cc6d845a373f3e0d59bfd10a45d1 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 7 Oct 2015 09:52:58 +0000 Subject: [PATCH 1/2] Couple of memory leaks in error paths, from Frederik Vanderstraeten. --- cmd-capture-pane.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd-capture-pane.c b/cmd-capture-pane.c index a348e155..bd9ecebb 100644 --- a/cmd-capture-pane.c +++ b/cmd-capture-pane.c @@ -196,6 +196,7 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_q *cmdq) if (c == NULL || (c->session != NULL && !(c->flags & CLIENT_CONTROL))) { cmdq_error(cmdq, "can't write to stdout"); + free(buf); return (CMD_RETURN_ERROR); } evbuffer_add(c->stdout_data, buf, len); @@ -210,11 +211,12 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_q *cmdq) if (paste_set(buf, len, bufname, &cause) != 0) { cmdq_error(cmdq, "%s", cause); - free(buf); free(cause); + free(buf); return (CMD_RETURN_ERROR); } } + free(buf); return (CMD_RETURN_NORMAL); } From 241fd72f754388c140036eb1b826a07700f5be3b Mon Sep 17 00:00:00 2001 From: guenther Date: Sun, 11 Oct 2015 00:26:23 +0000 Subject: [PATCH 2/2] Userspace doesn't need to use SUN_LEN(): connect() and bind() must accept sizeof(struct sockaddr_un), so do the simple, portable thing ok beck@ deraadt@ --- client.c | 2 +- server.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client.c b/client.c index da7bb314..2eb48a49 100644 --- a/client.c +++ b/client.c @@ -119,7 +119,7 @@ retry: fatal("socket failed"); log_debug("trying connect"); - if (connect(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) { + if (connect(fd, (struct sockaddr *) &sa, sizeof(sa)) == -1) { log_debug("connect failed: %s", strerror(errno)); if (errno != ECONNREFUSED && errno != ENOENT) goto failed; diff --git a/server.c b/server.c index 045daead..fd77ff38 100644 --- a/server.c +++ b/server.c @@ -145,7 +145,7 @@ server_create_socket(void) return (-1); mask = umask(S_IXUSR|S_IXGRP|S_IRWXO); - if (bind(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1) + if (bind(fd, (struct sockaddr *) &sa, sizeof(sa)) == -1) return (-1); umask(mask);