]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream commit
authordjm@openbsd.org <djm@openbsd.org>
Fri, 9 Jun 2017 06:47:13 +0000 (06:47 +0000)
committerDamien Miller <djm@mindrot.org>
Sat, 10 Jun 2017 06:40:11 +0000 (16:40 +1000)
return failure rather than fatal() for more cases during
mux negotiations. Causes the session to fall back to a non-mux connection if
they occur. bz#2707 ok dtucker@

Upstream-ID: d2a7892f464d434e1f615334a1c9d0cdb83b29ab

mux.c

diff --git a/mux.c b/mux.c
index 2d6639c5c19ac6a64954908b75bee0e68d3a6c5d..3dde4da40b89a4eb046ff8448c226f02dcbb6163 100644 (file)
--- a/mux.c
+++ b/mux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mux.c,v 1.64 2017/01/21 11:32:04 guenther Exp $ */
+/* $OpenBSD: mux.c,v 1.65 2017/06/09 06:47:13 djm Exp $ */
 /*
  * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org>
  *
@@ -1570,31 +1570,38 @@ mux_client_hello_exchange(int fd)
 {
        Buffer m;
        u_int type, ver;
+       int ret = -1;
 
        buffer_init(&m);
        buffer_put_int(&m, MUX_MSG_HELLO);
        buffer_put_int(&m, SSHMUX_VER);
        /* no extensions */
 
-       if (mux_client_write_packet(fd, &m) != 0)
-               fatal("%s: write packet: %s", __func__, strerror(errno));
+       if (mux_client_write_packet(fd, &m) != 0) {
+               debug("%s: write packet: %s", __func__, strerror(errno));
+               goto out;
+       }
 
        buffer_clear(&m);
 
        /* Read their HELLO */
        if (mux_client_read_packet(fd, &m) != 0) {
-               buffer_free(&m);
-               return -1;
+               debug("%s: read packet failed", __func__);
+               goto out;
        }
 
        type = buffer_get_int(&m);
-       if (type != MUX_MSG_HELLO)
-               fatal("%s: expected HELLO (%u) received %u",
+       if (type != MUX_MSG_HELLO) {
+               error("%s: expected HELLO (%u) received %u",
                    __func__, MUX_MSG_HELLO, type);
+               goto out;
+       }
        ver = buffer_get_int(&m);
-       if (ver != SSHMUX_VER)
-               fatal("Unsupported multiplexing protocol version %d "
+       if (ver != SSHMUX_VER) {
+               error("Unsupported multiplexing protocol version %d "
                    "(expected %d)", ver, SSHMUX_VER);
+               goto out;
+       }
        debug2("%s: master version %u", __func__, ver);
        /* No extensions are presently defined */
        while (buffer_len(&m) > 0) {
@@ -1605,8 +1612,11 @@ mux_client_hello_exchange(int fd)
                free(name);
                free(value);
        }
+       /* success */
+       ret = 0;
+ out:
        buffer_free(&m);
-       return 0;
+       return ret;
 }
 
 static u_int