From: djm Date: Fri, 9 Jun 2017 06:47:13 +0000 (+0000) Subject: return failure rather than fatal() for more cases during mux X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c3f3d768a4eac19e672fe90df8a3ac0b253b5814;p=openbsd 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@ --- diff --git a/usr.bin/ssh/mux.c b/usr.bin/ssh/mux.c index 745526385f7..6bbd90ec039 100644 --- a/usr.bin/ssh/mux.c +++ b/usr.bin/ssh/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 * @@ -1551,31 +1551,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) { @@ -1586,8 +1593,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