diff options
-rw-r--r-- | channels.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/channels.c b/channels.c index 1c381e0e2..bdee1f386 100644 --- a/channels.c +++ b/channels.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: channels.c,v 1.378 2018/01/23 05:27:21 djm Exp $ */ | 1 | /* $OpenBSD: channels.c,v 1.379 2018/02/05 05:36:49 tb 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 |
@@ -436,10 +436,15 @@ channel_close_fd(struct ssh *ssh, int *fdp) | |||
436 | static void | 436 | static void |
437 | channel_close_fds(struct ssh *ssh, Channel *c) | 437 | channel_close_fds(struct ssh *ssh, Channel *c) |
438 | { | 438 | { |
439 | int sock = c->sock, rfd = c->rfd, wfd = c->wfd, efd = c->efd; | ||
440 | |||
439 | channel_close_fd(ssh, &c->sock); | 441 | channel_close_fd(ssh, &c->sock); |
440 | channel_close_fd(ssh, &c->rfd); | 442 | if (rfd != sock) |
441 | channel_close_fd(ssh, &c->wfd); | 443 | channel_close_fd(ssh, &c->rfd); |
442 | channel_close_fd(ssh, &c->efd); | 444 | if (wfd != sock && wfd != rfd) |
445 | channel_close_fd(ssh, &c->wfd); | ||
446 | if (efd != sock && efd != rfd && efd != wfd) | ||
447 | channel_close_fd(ssh, &c->efd); | ||
443 | } | 448 | } |
444 | 449 | ||
445 | static void | 450 | static void |