mirror of
https://github.com/clearml/dropbear
synced 2025-01-31 10:57:01 +00:00
* close a file descriptor after we've shutdown() both sides, to avoid a leak
--HG-- extra : convert_revision : 06fda32c634cf16a4c75797441ec2bd533f571c6
This commit is contained in:
parent
9888ffd8d1
commit
5002c95048
@ -1019,6 +1019,7 @@ static void closechanfd(struct Channel *channel, int fd, int how) {
|
|||||||
|
|
||||||
/* XXX server */
|
/* XXX server */
|
||||||
if (channel->type->sepfds) {
|
if (channel->type->sepfds) {
|
||||||
|
TRACE(("shutdown((%d), %d)", fd, how))
|
||||||
shutdown(fd, how);
|
shutdown(fd, how);
|
||||||
if (how == 0) {
|
if (how == 0) {
|
||||||
closeout = 1;
|
closeout = 1;
|
||||||
@ -1043,4 +1044,11 @@ static void closechanfd(struct Channel *channel, int fd, int how) {
|
|||||||
if (closein && (channel->extrabuf != NULL) && (fd == channel->errfd)) {
|
if (closein && (channel->extrabuf != NULL) && (fd == channel->errfd)) {
|
||||||
channel->errfd = FD_CLOSED;
|
channel->errfd = FD_CLOSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if we called shutdown on it and all references are gone, then we
|
||||||
|
* need to close() it to stop it lingering */
|
||||||
|
if (channel->type->sepfds && channel->outfd == FD_CLOSED
|
||||||
|
&& channel->infd == FD_CLOSED && channel->errfd == FD_CLOSED) {
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user