diff options
author | djm@openbsd.org <djm@openbsd.org> | 2017-06-09 06:47:13 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2017-06-10 16:40:11 +1000 |
commit | 5b2f34a74aa6a524cd57e856b23e1b7b25007721 (patch) | |
tree | d248dee0f9175c64f3d06ce81ce03057da308ebf | |
parent | 7f5637c4a67a49ef256cb4eedf14e8590ac30976 (diff) |
upstream commit
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
-rw-r--r-- | mux.c | 30 |
1 files changed, 20 insertions, 10 deletions
@@ -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 |