summaryrefslogtreecommitdiff
path: root/mux.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2017-06-09 06:47:13 +0000
committerDamien Miller <djm@mindrot.org>2017-06-10 16:40:11 +1000
commit5b2f34a74aa6a524cd57e856b23e1b7b25007721 (patch)
treed248dee0f9175c64f3d06ce81ce03057da308ebf /mux.c
parent7f5637c4a67a49ef256cb4eedf14e8590ac30976 (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
Diffstat (limited to 'mux.c')
-rw-r--r--mux.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/mux.c b/mux.c
index 2d6639c5c..3dde4da40 100644
--- a/mux.c
+++ b/mux.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: mux.c,v 1.64 2017/01/21 11:32:04 guenther Exp $ */ 1/* $OpenBSD: mux.c,v 1.65 2017/06/09 06:47:13 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org> 3 * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org>
4 * 4 *
@@ -1570,31 +1570,38 @@ mux_client_hello_exchange(int fd)
1570{ 1570{
1571 Buffer m; 1571 Buffer m;
1572 u_int type, ver; 1572 u_int type, ver;
1573 int ret = -1;
1573 1574
1574 buffer_init(&m); 1575 buffer_init(&m);
1575 buffer_put_int(&m, MUX_MSG_HELLO); 1576 buffer_put_int(&m, MUX_MSG_HELLO);
1576 buffer_put_int(&m, SSHMUX_VER); 1577 buffer_put_int(&m, SSHMUX_VER);
1577 /* no extensions */ 1578 /* no extensions */
1578 1579
1579 if (mux_client_write_packet(fd, &m) != 0) 1580 if (mux_client_write_packet(fd, &m) != 0) {
1580 fatal("%s: write packet: %s", __func__, strerror(errno)); 1581 debug("%s: write packet: %s", __func__, strerror(errno));
1582 goto out;
1583 }
1581 1584
1582 buffer_clear(&m); 1585 buffer_clear(&m);
1583 1586
1584 /* Read their HELLO */ 1587 /* Read their HELLO */
1585 if (mux_client_read_packet(fd, &m) != 0) { 1588 if (mux_client_read_packet(fd, &m) != 0) {
1586 buffer_free(&m); 1589 debug("%s: read packet failed", __func__);
1587 return -1; 1590 goto out;
1588 } 1591 }
1589 1592
1590 type = buffer_get_int(&m); 1593 type = buffer_get_int(&m);
1591 if (type != MUX_MSG_HELLO) 1594 if (type != MUX_MSG_HELLO) {
1592 fatal("%s: expected HELLO (%u) received %u", 1595 error("%s: expected HELLO (%u) received %u",
1593 __func__, MUX_MSG_HELLO, type); 1596 __func__, MUX_MSG_HELLO, type);
1597 goto out;
1598 }
1594 ver = buffer_get_int(&m); 1599 ver = buffer_get_int(&m);
1595 if (ver != SSHMUX_VER) 1600 if (ver != SSHMUX_VER) {
1596 fatal("Unsupported multiplexing protocol version %d " 1601 error("Unsupported multiplexing protocol version %d "
1597 "(expected %d)", ver, SSHMUX_VER); 1602 "(expected %d)", ver, SSHMUX_VER);
1603 goto out;
1604 }
1598 debug2("%s: master version %u", __func__, ver); 1605 debug2("%s: master version %u", __func__, ver);
1599 /* No extensions are presently defined */ 1606 /* No extensions are presently defined */
1600 while (buffer_len(&m) > 0) { 1607 while (buffer_len(&m) > 0) {
@@ -1605,8 +1612,11 @@ mux_client_hello_exchange(int fd)
1605 free(name); 1612 free(name);
1606 free(value); 1613 free(value);
1607 } 1614 }
1615 /* success */
1616 ret = 0;
1617 out:
1608 buffer_free(&m); 1618 buffer_free(&m);
1609 return 0; 1619 return ret;
1610} 1620}
1611 1621
1612static u_int 1622static u_int