about summary refs log tree commit diff
path: root/sysdeps/unix/grantpt.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/grantpt.c')
-rw-r--r--sysdeps/unix/grantpt.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/sysdeps/unix/grantpt.c b/sysdeps/unix/grantpt.c
index 2a7a963162..260e8273f8 100644
--- a/sysdeps/unix/grantpt.c
+++ b/sysdeps/unix/grantpt.c
@@ -38,7 +38,7 @@
    this buffer, a sufficiently long buffer is allocated using malloc,
    and returned in PTS.  0 is returned upon success, -1 otherwise.  */
 static int
-pts_name (int fd, char **pts, size_t buf_len)
+pts_name (int fd, char **pts, size_t buf_len, struct stat64 *stp)
 {
   int rv;
   char *buf = *pts;
@@ -49,7 +49,7 @@ pts_name (int fd, char **pts, size_t buf_len)
 
       if (buf_len)
 	{
-	  rv = __ptsname_r (fd, buf, buf_len);
+	  rv = __ptsname_internal (fd, buf, buf_len, stp);
 	  if (rv != 0)
 	    {
 	      if (rv == ENOTTY)
@@ -107,8 +107,9 @@ grantpt (int fd)
   char _buf[512];
 #endif
   char *buf = _buf;
+  struct stat64 st;
 
-  if (__builtin_expect (pts_name (fd, &buf, sizeof (_buf)), 0))
+  if (__builtin_expect (pts_name (fd, &buf, sizeof (_buf), &st), 0))
     {
       int save_errno = errno;
 
@@ -127,10 +128,6 @@ grantpt (int fd)
        return -1;
     }
 
-  struct stat64 st;
-  if (__xstat64 (_STAT_VER, buf, &st) < 0)
-    goto cleanup;
-
   /* Make sure that we own the device.  */
   uid_t uid = __getuid ();
   if (st.st_uid != uid)