summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-11-17 15:06:35 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2014-11-18 02:41:20 +0100
commit0c78757010a17173bdc79b818133697e7dcbf6a4 (patch)
tree666aa7d48511f0f3c8d31a0bf8a3f5f0f06e83d8 /apt-pkg/deb
parent4bb006d1ddcf1807474067dcbef9fb0bb5def0ac (diff)
close leaking slave fd after setting up pty magic
The fd moves out of scope here anyway, so we should close it properly instead of leaking it which will tickle down to dpkg maintainer scripts. Closes: 767774
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/dpkgpm.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 3f6039e0d..dd03eac2c 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -1158,8 +1158,7 @@ void pkgDPkgPM::SetupSlavePtyMagic()
int const slaveFd = open(d->slave, O_RDWR);
if (slaveFd == -1)
_error->FatalE("open", _("Can not write log (%s)"), _("Is /dev/pts mounted?"));
-
- if (ioctl(slaveFd, TIOCSCTTY, 0) < 0)
+ else if (ioctl(slaveFd, TIOCSCTTY, 0) < 0)
_error->FatalE("ioctl", "Setting TIOCSCTTY for slave fd %d failed!", slaveFd);
else
{
@@ -1170,6 +1169,9 @@ void pkgDPkgPM::SetupSlavePtyMagic()
if (tcsetattr(0, TCSANOW, &d->tt) < 0)
_error->FatalE("tcsetattr", "Setting in Setup via TCSANOW for slave fd %d failed!", slaveFd);
}
+
+ if (slaveFd != -1)
+ close(slaveFd);
}
void pkgDPkgPM::StopPtyMagic()
{