summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2015-10-23 21:17:25 +0200
committerJulian Andres Klode <jak@debian.org>2015-10-30 14:20:43 +0100
commit2a0cae347a058f0cc5d81477f75ed0c12b1e54e3 (patch)
tree0c58c076732d51d781cd0e54de4f7ad2ca1307b1 /apt-pkg/deb
parent2609e7cea39fb32a999acef014ea9ce6e9b3d141 (diff)
dpkgpm: Use ptsname_r() instead of ptsname() to be thread-safe
This function only exists on a limited number of platforms, so we add a configure check to make sure it exists. Gbp-Dch: ignore
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/dpkgpm.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 0f195b921..5c7710036 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -1082,8 +1082,13 @@ void pkgDPkgPM::StartPtyMagic()
_error->Errno("unlockpt", "Unlocking the slave of master fd %d failed!", d->master);
else
{
+#ifdef HAVE_PTS_NAME_R
+ char slave_name[64]; // 64 is used by bionic
+ if (ptsname_r(d->master, slave_name, sizeof(slave_name)) != 0)
+#else
char const * const slave_name = ptsname(d->master);
if (slave_name == NULL)
+#endif
_error->Errno("ptsname", "Getting name for slave of master fd %d failed!", d->master);
else
{