Bug#35695: libc6: ttyname() broken ?
Package: libc6
Version: 2.1.1-0.1
After upgrading to kernel 2.2.5-ac4, screen does not work. It seems to be a
problem with glibc. Here are the facts:
# screen
Cannot access '/dev/ptsÿÿÿÿÿÿÿÿ': No such file or directory
ltracing it reveals the following:
ttyname(0) = "/dev/pts/0\b\bEOFEOFEOFEOFEOFEOFEOFEOF"
__xstat(3, "/dev/pts/0\b\bEOFEOFEOFEOFEOFEOFEOFEOF", 0xbfffe930) = -1
If I strace it, it says the following:
readlink("/proc/self/fd/0", "/dev/pts/0", 4095) = 10
stat("/dev/pts/^H<FF><FF><FF><FF><FF><FF><FF><FF>", 0xbfffe7d0) = -1 ENOENT
(No such file or directory)
See the return value of readlink. On a non-ac kernel it returns 11,
terminating the string with a \0. Here is the relevant part of the patch of
the ac kernel:
--- linux.vanilla/fs/proc/link.c Sun Nov 8 15:06:32 1998
+++ linux.ac/fs/proc/link.c Wed Mar 24 18:14:32 1999
@@ -158,7 +158,7 @@
path = tmp;
} else {
path = d_path(dentry, tmp, PAGE_SIZE);
- len = tmp + PAGE_SIZE - path;
+ len = tmp + PAGE_SIZE - 1 - path;
}
if (len < buflen)
Reading the manpage of readlink() it seems that this patch is correct, and
readlink should not terminate the string with a \0:
DESCRIPTION
readlink places the contents of the symbolic link path in
the buffer buf, which has size bufsiz. readlink does not
append a NUL character to buf...
RETURN VALUES
The call returns the count of characters placed in the
buffer if it succeeds, or a -1 if an error occurs, placing
the error code in errno.
In this case the ttyname() function of libc should take care of terminating
the string with \0 before returning it to the caller.
-- System Information
Debian Release: potato
Kernel Version: Linux thunderchild 2.2.5 #2 Fri Apr 2 15:44:43 CEST 1999 i586 unknown
Versions of the packages libc6 depends on:
ii ldso 1.9.10-1.2 The Linux dynamic linker, library and utilit
Reply to: