summaryrefslogtreecommitdiff
path: root/mux.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2011-05-15 08:34:46 +1000
committerDamien Miller <djm@mindrot.org>2011-05-15 08:34:46 +1000
commit60432d8cf250e2176f50fd486342612a822d70e3 (patch)
treed1096e216a9d1277eaf9bb84c84c4af6892a270a /mux.c
parentd6548fe4cf3bcfe4e473a452757f1e307bf0eaf1 (diff)
downloadopenssh-git-60432d8cf250e2176f50fd486342612a822d70e3.tar.gz
- djm@cvs.openbsd.org 2011/05/05 05:12:08
[mux.c] gracefully fall back when ControlPath is too large for a sockaddr_un. ok markus@ as part of a larger diff
Diffstat (limited to 'mux.c')
-rw-r--r--mux.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/mux.c b/mux.c
index 09468359..fb24c0f9 100644
--- a/mux.c
+++ b/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>
*
@@ -1095,21 +1095,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, 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;