summaryrefslogtreecommitdiff
path: root/nchan.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2002-03-26 03:26:24 +0000
committerBen Lindstrom <mouring@eviladmin.org>2002-03-26 03:26:24 +0000
commitcf15944c2355f61116d7fb5e793c097dd347284f (patch)
tree15203eed8ed647b7f11f7e5347e8a9bc0f18f2b5 /nchan.c
parent4f054607f05f18a705579a2475f490ed47e31028 (diff)
- markus@cvs.openbsd.org 2002/03/25 21:13:51
[channels.c channels.h compat.c compat.h nchan.c] don't send stderr data after EOF, accept this from older known (broken) sshd servers only, fixes http://bugzilla.mindrot.org/show_bug.cgi?id=179
Diffstat (limited to 'nchan.c')
-rw-r--r--nchan.c60
1 files changed, 27 insertions, 33 deletions
diff --git a/nchan.c b/nchan.c
index fc8e7f18d..db38de6ac 100644
--- a/nchan.c
+++ b/nchan.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: nchan.c,v 1.44 2002/01/21 23:27:10 markus Exp $"); 26RCSID("$OpenBSD: nchan.c,v 1.45 2002/03/25 21:13:51 markus Exp $");
27 27
28#include "ssh1.h" 28#include "ssh1.h"
29#include "ssh2.h" 29#include "ssh2.h"
@@ -302,6 +302,7 @@ static void
302chan_rcvd_eof2(Channel *c) 302chan_rcvd_eof2(Channel *c)
303{ 303{
304 debug("channel %d: rcvd eof", c->self); 304 debug("channel %d: rcvd eof", c->self);
305 c->flags |= CHAN_EOF_RCVD;
305 if (c->ostate == CHAN_OUTPUT_OPEN) 306 if (c->ostate == CHAN_OUTPUT_OPEN)
306 chan_set_ostate(c, CHAN_OUTPUT_WAIT_DRAIN); 307 chan_set_ostate(c, CHAN_OUTPUT_WAIT_DRAIN);
307} 308}
@@ -330,6 +331,7 @@ chan_send_eof2(Channel *c)
330 packet_start(SSH2_MSG_CHANNEL_EOF); 331 packet_start(SSH2_MSG_CHANNEL_EOF);
331 packet_put_int(c->remote_id); 332 packet_put_int(c->remote_id);
332 packet_send(); 333 packet_send();
334 c->flags |= CHAN_EOF_SENT;
333 break; 335 break;
334 default: 336 default:
335 error("channel %d: cannot send eof for istate %d", 337 error("channel %d: cannot send eof for istate %d",
@@ -365,7 +367,8 @@ chan_rcvd_ieof(Channel *c)
365 else 367 else
366 chan_rcvd_ieof1(c); 368 chan_rcvd_ieof1(c);
367 if (c->ostate == CHAN_OUTPUT_WAIT_DRAIN && 369 if (c->ostate == CHAN_OUTPUT_WAIT_DRAIN &&
368 buffer_len(&c->output) == 0) 370 buffer_len(&c->output) == 0 &&
371 !CHANNEL_EFD_OUTPUT_ACTIVE(c))
369 chan_obuf_empty(c); 372 chan_obuf_empty(c);
370} 373}
371void 374void
@@ -404,39 +407,30 @@ chan_is_dead(Channel *c, int send)
404 debug("channel %d: is dead", c->self); 407 debug("channel %d: is dead", c->self);
405 return 1; 408 return 1;
406 } 409 }
407 /* 410 if ((datafellows & SSH_BUG_EXTEOF) &&
408 * we have to delay the close message if the efd (for stderr) is 411 c->extended_usage == CHAN_EXTENDED_WRITE &&
409 * still active 412 c->efd != -1 &&
410 */ 413 buffer_len(&c->extended) > 0) {
411 if (((c->extended_usage != CHAN_EXTENDED_IGNORE) && 414 debug2("channel %d: active efd: %d len %d",
412 buffer_len(&c->extended) > 0) 415 c->self, c->efd, buffer_len(&c->extended));
413#if 0 416 return 0;
414 || ((c->extended_usage == CHAN_EXTENDED_READ) && 417 }
415 c->efd != -1) 418 if (!(c->flags & CHAN_CLOSE_SENT)) {
416#endif 419 if (send) {
417 ) { 420 chan_send_close2(c);
418 debug2("channel %d: active efd: %d len %d type %s", 421 } else {
419 c->self, c->efd, buffer_len(&c->extended), 422 /* channel would be dead if we sent a close */
420 c->extended_usage==CHAN_EXTENDED_READ ? 423 if (c->flags & CHAN_CLOSE_RCVD) {
421 "read": "write"); 424 debug("channel %d: almost dead",
422 } else { 425 c->self);
423 if (!(c->flags & CHAN_CLOSE_SENT)) { 426 return 1;
424 if (send) {
425 chan_send_close2(c);
426 } else {
427 /* channel would be dead if we sent a close */
428 if (c->flags & CHAN_CLOSE_RCVD) {
429 debug("channel %d: almost dead",
430 c->self);
431 return 1;
432 }
433 } 427 }
434 } 428 }
435 if ((c->flags & CHAN_CLOSE_SENT) && 429 }
436 (c->flags & CHAN_CLOSE_RCVD)) { 430 if ((c->flags & CHAN_CLOSE_SENT) &&
437 debug("channel %d: is dead", c->self); 431 (c->flags & CHAN_CLOSE_RCVD)) {
438 return 1; 432 debug("channel %d: is dead", c->self);
439 } 433 return 1;
440 } 434 }
441 return 0; 435 return 0;
442} 436}