]> andersk Git - gssapi-openssh.git/blobdiff - openssh/channels.c
Import of OpenSSH 3.2.2p1
[gssapi-openssh.git] / openssh / channels.c
index 2b1f33f34792d474387854accef728fbe1794d6c..520bff82292345903f6619c6b4d42b9287a8dc53 100644 (file)
@@ -39,7 +39,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: channels.c,v 1.171 2002/03/04 19:37:58 markus Exp $");
+RCSID("$OpenBSD: channels.c,v 1.173 2002/04/22 21:04:52 markus Exp $");
 
 #include "ssh.h"
 #include "ssh1.h"
@@ -706,7 +706,11 @@ channel_pre_open(Channel *c, fd_set * readset, fd_set * writeset)
                if (buffer_len(&c->output) > 0) {
                        FD_SET(c->wfd, writeset);
                } else if (c->ostate == CHAN_OUTPUT_WAIT_DRAIN) {
-                       chan_obuf_empty(c);
+                       if (CHANNEL_EFD_OUTPUT_ACTIVE(c))
+                               debug2("channel %d: obuf_empty delayed efd %d/(%d)",
+                                   c->self, c->efd, buffer_len(&c->extended));
+                       else
+                               chan_obuf_empty(c);
                }
        }
        /** XXX check close conditions, too */
@@ -714,7 +718,8 @@ channel_pre_open(Channel *c, fd_set * readset, fd_set * writeset)
                if (c->extended_usage == CHAN_EXTENDED_WRITE &&
                    buffer_len(&c->extended) > 0)
                        FD_SET(c->efd, writeset);
-               else if (c->extended_usage == CHAN_EXTENDED_READ &&
+               else if (!(c->flags & CHAN_EOF_SENT) &&
+                   c->extended_usage == CHAN_EXTENDED_READ &&
                    buffer_len(&c->extended) < c->remote_window)
                        FD_SET(c->efd, readset);
        }
@@ -1632,12 +1637,18 @@ channel_output_poll(void)
                                fatal("cannot happen: istate == INPUT_WAIT_DRAIN for proto 1.3");
                        /*
                         * input-buffer is empty and read-socket shutdown:
-                        * tell peer, that we will not send more data: send IEOF
+                        * tell peer, that we will not send more data: send IEOF.
+                        * hack for extended data: delay EOF if EFD still in use.
                         */
-                       chan_ibuf_empty(c);
+                       if (CHANNEL_EFD_INPUT_ACTIVE(c))
+                               debug2("channel %d: ibuf_empty delayed efd %d/(%d)",
+                                   c->self, c->efd, buffer_len(&c->extended));
+                       else
+                               chan_ibuf_empty(c);
                }
                /* Send extended data, i.e. stderr */
                if (compat20 &&
+                   !(c->flags & CHAN_EOF_SENT) &&
                    c->remote_window > 0 &&
                    (len = buffer_len(&c->extended)) > 0 &&
                    c->extended_usage == CHAN_EXTENDED_READ) {
@@ -1726,6 +1737,13 @@ channel_input_extended_data(int type, u_int32_t seq, void *ctxt)
                log("channel %d: ext data for non open", id);
                return;
        }
+       if (c->flags & CHAN_EOF_RCVD) {
+               if (datafellows & SSH_BUG_EXTEOF)
+                       debug("channel %d: accepting ext data after eof", id);
+               else
+                       packet_disconnect("Received extended_data after EOF "
+                           "on channel %d.", id);
+       }
        tcode = packet_get_int();
        if (c->efd == -1 ||
            c->extended_usage != CHAN_EXTENDED_WRITE ||
@@ -2112,7 +2130,7 @@ channel_request_remote_forwarding(u_short listen_port,
                const char *address_to_bind = "0.0.0.0";
                packet_start(SSH2_MSG_GLOBAL_REQUEST);
                packet_put_cstring("tcpip-forward");
-               packet_put_char(0);                     /* boolean: want reply */
+               packet_put_char(1);                     /* boolean: want reply */
                packet_put_cstring(address_to_bind);
                packet_put_int(listen_port);
                packet_send();
This page took 0.079229 seconds and 4 git commands to generate.