diff options
author | djm@openbsd.org <djm@openbsd.org> | 2017-09-23 22:04:07 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2017-09-24 14:08:36 +1000 |
commit | 55486f5cef117354f0c64f991895835077b7c7f7 (patch) | |
tree | 0f7b089d087a17370f3f8c2cb1e6cfc76c47200d | |
parent | 609d7a66ce578abf259da2d5f6f68795c2bda731 (diff) |
upstream commit
fix tunnel forwarding problem introduced in refactor;
reported by stsp@ ok markus@
Upstream-ID: 81a731cdae1122c8522134095d1a8b60fa9dcd04
-rw-r--r-- | channels.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/channels.c b/channels.c index 8ef37c453..b3c490eb4 100644 --- a/channels.c +++ b/channels.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: channels.c,v 1.372 2017/09/21 19:16:53 markus Exp $ */ | 1 | /* $OpenBSD: channels.c,v 1.373 2017/09/23 22:04:07 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -2450,7 +2450,8 @@ channel_after_select(struct ssh *ssh, fd_set *readset, fd_set *writeset) | |||
2450 | static void | 2450 | static void |
2451 | channel_output_poll_input_open(struct ssh *ssh, Channel *c) | 2451 | channel_output_poll_input_open(struct ssh *ssh, Channel *c) |
2452 | { | 2452 | { |
2453 | size_t len, dlen; | 2453 | size_t len, plen; |
2454 | const u_char *pkt; | ||
2454 | int r; | 2455 | int r; |
2455 | 2456 | ||
2456 | if ((len = sshbuf_len(c->input)) == 0) { | 2457 | if ((len = sshbuf_len(c->input)) == 0) { |
@@ -2477,27 +2478,27 @@ channel_output_poll_input_open(struct ssh *ssh, Channel *c) | |||
2477 | 2478 | ||
2478 | if (c->datagram) { | 2479 | if (c->datagram) { |
2479 | /* Check datagram will fit; drop if not */ | 2480 | /* Check datagram will fit; drop if not */ |
2480 | if ((r = sshbuf_peek_string_direct(c->input, NULL, &dlen)) != 0) | 2481 | if ((r = sshbuf_get_string_direct(c->input, &pkt, &plen)) != 0) |
2481 | fatal("%s: channel %d: peek datagram: %s", __func__, | 2482 | fatal("%s: channel %d: get datagram: %s", __func__, |
2482 | c->self, ssh_err(r)); | 2483 | c->self, ssh_err(r)); |
2483 | /* | 2484 | /* |
2484 | * XXX this does tail-drop on the datagram queue which is | 2485 | * XXX this does tail-drop on the datagram queue which is |
2485 | * usually suboptimal compared to head-drop. Better to have | 2486 | * usually suboptimal compared to head-drop. Better to have |
2486 | * backpressure at read time? (i.e. read + discard) | 2487 | * backpressure at read time? (i.e. read + discard) |
2487 | */ | 2488 | */ |
2488 | if (dlen > c->remote_window || dlen > c->remote_maxpacket) { | 2489 | if (plen > c->remote_window || plen > c->remote_maxpacket) { |
2489 | debug("channel %d: datagram too big", c->self); | 2490 | debug("channel %d: datagram too big", c->self); |
2490 | return; | 2491 | return; |
2491 | } | 2492 | } |
2492 | /* Enqueue it */ | 2493 | /* Enqueue it */ |
2493 | if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_DATA)) != 0 || | 2494 | if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_DATA)) != 0 || |
2494 | (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || | 2495 | (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || |
2495 | (r = sshpkt_put_stringb(ssh, c->input)) != 0 || | 2496 | (r = sshpkt_put_string(ssh, pkt, plen)) != 0 || |
2496 | (r = sshpkt_send(ssh)) != 0) { | 2497 | (r = sshpkt_send(ssh)) != 0) { |
2497 | fatal("%s: channel %i: datagram: %s", __func__, | 2498 | fatal("%s: channel %i: datagram: %s", __func__, |
2498 | c->self, ssh_err(r)); | 2499 | c->self, ssh_err(r)); |
2499 | } | 2500 | } |
2500 | c->remote_window -= dlen; | 2501 | c->remote_window -= plen; |
2501 | return; | 2502 | return; |
2502 | } | 2503 | } |
2503 | 2504 | ||