bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ptsname: fix bug inherited from glibc


From: Bruno Haible
Subject: ptsname: fix bug inherited from glibc
Date: Sun, 25 Apr 2010 22:23:12 +0200
User-agent: KMail/1.9.9

This fixes a bug relating to the invocation of ttyname_r. I've reported it
as glibc bug <http://sourceware.org/bugzilla/show_bug.cgi?id=11538>.


2010-04-25  Bruno Haible  <address@hidden>

        ptsname: Fix misuse of ttyname_r.
        * lib/ptsname.c (__ptsname_r): Use __ttyname_r's return value instead
        of errno.

--- lib/ptsname.c.orig  Sun Apr 25 22:17:33 2010
+++ lib/ptsname.c       Sun Apr 25 22:16:53 2010
@@ -63,6 +63,7 @@
 __ptsname_r (int fd, char *buf, size_t buflen)
 {
   int save_errno = errno;
+  int err;
   struct stat st;
 
   if (buf == NULL)
@@ -81,8 +82,12 @@
       return ERANGE;
     }
 
-  if (__ttyname_r (fd, buf, buflen) != 0)
-    return errno;
+  err = __ttyname_r (fd, buf, buflen);
+  if (err != 0)
+    {
+      __set_errno (err);
+      return errno;
+    }
 
   buf[sizeof (_PATH_DEV) - 1] = 't';
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]