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

Bug#35378: Bug#35315: screen: Broken UNIX98 ptys



>>>>> J H M Dassen writes:

Ray> On Wed, Mar 31, 1999 at 09:25:14 +0200, J.H.M. Dassen wrote:
>> Package: screen

>> penguin ray 9:21 ~ > screen
>> Cannot access '/dev/pts/ÿÿÿÿÿÿÿÿ': No such file or directory
>> zsh: exit 1     screen

Ray> On Wed, Mar 31, 1999 at 17:16:55 -0500, William R. McDonough wrote:
>> Package: libc6

>> [wrmcd@janitor: ~]$ screen -S bitchx bitchx
>> Cannot access '/dev/ttypÿÿÿÿÿÿÿÿ': No such file or directory

Ray> This is just to let you know there are now two bug reports about this issue,
Ray> one for libc6 and one for screen.

I noticed a strange behaviour with tty and Unix98 Ptys:
$ tty
/dev/pts/0/locale

The following patch fixes my problem - and I guess the screen one
also.  It has been added to glibc 2.1.

Andreas

1999-04-01  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* sysdeps/unix/sysv/linux/ttyname.c (ttyname): Terminate the
	string.
	* sysdeps/unix/sysv/linux/ttyname_r.c (__ttyname_r): Likewise.

Index: sysdeps/unix/sysv/linux/ttyname.c
===================================================================
--- ttyname.c	1999/03/08 11:46:01	1.8
+++ ttyname.c	1999/04/01 09:32:31	1.9
@@ -112,6 +112,7 @@
   int dostat = 0;
   char *name;
   int save = errno;
+  int len;
 
   if (!__isatty (fd))
     return NULL;
@@ -130,10 +131,17 @@
 	}
     }
 
-  if (__readlink (procname, buf, buflen) != -1
+  len = __readlink (procname, buf, buflen);
+  if (len != -1
       /* This is for Linux 2.0.  */
       && buf[0] != '[')
-    return buf;
+    {
+      if (len >= buflen)
+	return NULL;
+      /* readlink need not terminate the string.  */
+      buf[len] = '\0';
+      return buf;
+    }
 
   if (__fxstat (_STAT_VER, fd, &st) < 0)
     return NULL;
Index: sysdeps/unix/sysv/linux/ttyname_r.c
===================================================================
--- ttyname_r.c	1999/03/08 11:46:10	1.9
+++ ttyname_r.c	1999/04/01 09:32:17	1.10
@@ -134,7 +134,10 @@
 
   ret = __readlink (procname, buf, buflen - 1);
   if (ret != -1 && buf[0] != '[')
-    return 0;
+    {
+      buf[ret] = '\0';
+      return 0;
+    }
   if (ret == -1 && errno == ENAMETOOLONG)
     {
       __set_errno (ERANGE);


-- 
 Andreas Jaeger   aj@arthur.rhein-neckar.de    jaeger@informatik.uni-kl.de
  for pgp-key finger ajaeger@aixd1.rhrk.uni-kl.de


Reply to: