]> git.saurik.com Git - apt.git/commitdiff
dpkgpm: Use ptsname_r() instead of ptsname() to be thread-safe
authorJulian Andres Klode <jak@debian.org>
Fri, 23 Oct 2015 19:17:25 +0000 (21:17 +0200)
committerJulian Andres Klode <jak@debian.org>
Fri, 30 Oct 2015 13:20:43 +0000 (14:20 +0100)
This function only exists on a limited number of platforms, so
we add a configure check to make sure it exists.

Gbp-Dch: ignore

apt-pkg/deb/dpkgpm.cc
buildlib/config.h.in
configure.ac

index 0f195b9218312d64bd832db1f62ba5bd16bb17b0..5c77100366fa0944d9725a19867fa608192d8464 100644 (file)
@@ -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
       {
index c6b1ee6698ce81477c1b222ed18bb343649a0296..a887ebf88e6202fc5de92f793e81b93e46ab35a8 100644 (file)
@@ -34,6 +34,9 @@
 #undef HAVE_SETRESUID
 #undef HAVE_SETRESGID
 
+/* Check for ptsname_r() */
+#undef HAVE_PTSNAME_R
+
 /* Define to the size of the filesize containing structures */
 #undef _FILE_OFFSET_BITS
 
index 5c880845ccd690105d20ae995dc315f95f00bf6f..8bf87754b5535b4b7b76040a229ae5a60c370651 100644 (file)
@@ -180,6 +180,9 @@ AC_SUBST(HAVE_GETRESGID)
 AC_SUBST(HAVE_SETRESUID)
 AC_SUBST(HAVE_SETRESGID)
 
+AC_CHECK_FUNC(ptsname_r)
+AC_SUBST(HAVE_PTSNAME_R)
+
 dnl Check for doxygen
 AC_PATH_PROG(DOXYGEN, doxygen)