summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2011-05-05 05:12:09 +0000
committerDamien Miller <djm@cvs.openbsd.org>2011-05-05 05:12:09 +0000
commit5ce94021ed18fce6f61f51402d37128336a400e6 (patch)
tree8886038c0c9f5ebea83cfef6422d9105429f6075 /usr.bin
parentf5809464cd36c0bd7104a5580e25f17399126ac1 (diff)
gracefully fall back when ControlPath is too large for a
sockaddr_un. ok markus@ as part of a larger diff
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/mux.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/usr.bin/ssh/mux.c b/usr.bin/ssh/mux.c
index 28daadbcd48..879546211fa 100644
--- a/usr.bin/ssh/mux.c
+++ b/usr.bin/ssh/mux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mux.c,v 1.25 2011/04/17 22:42:41 djm Exp $ */
+/* $OpenBSD: mux.c,v 1.26 2011/05/05 05:12:08 djm Exp $ */
/*
* Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org>
*
@@ -1077,21 +1077,25 @@ muxserver_listen(void)
strlen(options.control_path) + 1;
if (strlcpy(addr.sun_path, options.control_path,
- sizeof(addr.sun_path)) >= sizeof(addr.sun_path))
- fatal("ControlPath too long");
+ sizeof(addr.sun_path)) >= sizeof(addr.sun_path)) {
+ error("ControlPath \"%s\" too long for Unix domain socket",
+ options.control_path);
+ goto disable_mux_master;
+ }
if ((muxserver_sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
fatal("%s socket(): %s", __func__, strerror(errno));
old_umask = umask(0177);
if (bind(muxserver_sock, (struct sockaddr *)&addr, addr.sun_len) == -1) {
- muxserver_sock = -1;
if (errno == EINVAL || errno == EADDRINUSE) {
error("ControlSocket %s already exists, "
"disabling multiplexing", options.control_path);
disable_mux_master:
- close(muxserver_sock);
- muxserver_sock = -1;
+ if (muxserver_sock != -1) {
+ close(muxserver_sock);
+ muxserver_sock = -1;
+ }
xfree(options.control_path);
options.control_path = NULL;
options.control_master = SSHCTL_MASTER_NO;