diff options
author | Ulrich Drepper <drepper@redhat.com> | 1999-04-01 09:33:06 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1999-04-01 09:33:06 +0000 |
commit | 7081e0a34c10eb54ab5f4ca62c5f4f4fa222cbff (patch) | |
tree | fda38fedb445849308078250919804b45243f99e /sysdeps/unix/sysv/linux/ttyname.c | |
parent | 134c659cc7af735b8e9dc4fc765eb5fa75ec9e14 (diff) | |
download | glibc-7081e0a34c10eb54ab5f4ca62c5f4f4fa222cbff.tar.gz glibc-7081e0a34c10eb54ab5f4ca62c5f4f4fa222cbff.tar.xz glibc-7081e0a34c10eb54ab5f4ca62c5f4f4fa222cbff.zip |
Update.
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.
Diffstat (limited to 'sysdeps/unix/sysv/linux/ttyname.c')
-rw-r--r-- | sysdeps/unix/sysv/linux/ttyname.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sysdeps/unix/sysv/linux/ttyname.c b/sysdeps/unix/sysv/linux/ttyname.c index 20c794daf4..0dd9c704af 100644 --- a/sysdeps/unix/sysv/linux/ttyname.c +++ b/sysdeps/unix/sysv/linux/ttyname.c @@ -112,6 +112,7 @@ ttyname (fd) int dostat = 0; char *name; int save = errno; + int len; if (!__isatty (fd)) return NULL; @@ -130,10 +131,17 @@ ttyname (fd) } } - 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; |