diff options
Diffstat (limited to 'sysdeps/posix')
-rw-r--r-- | sysdeps/posix/ttyname.c | 3 | ||||
-rw-r--r-- | sysdeps/posix/ttyname_r.c | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/sysdeps/posix/ttyname.c b/sysdeps/posix/ttyname.c index b0650b38b0..7c7ed2428a 100644 --- a/sysdeps/posix/ttyname.c +++ b/sysdeps/posix/ttyname.c @@ -44,6 +44,9 @@ DEFUN(ttyname, (fd), int fd) struct dirent *d; int save = errno; + if (!__isatty (fd)) + return NULL; + if (fstat (fd, &st) < 0) return NULL; mydev = st.st_dev; diff --git a/sysdeps/posix/ttyname_r.c b/sysdeps/posix/ttyname_r.c index a05dbd5be3..e6172f1c97 100644 --- a/sysdeps/posix/ttyname_r.c +++ b/sysdeps/posix/ttyname_r.c @@ -54,6 +54,9 @@ __ttyname_r (fd, buf, buflen) return -1; } + if (!__isatty (fd)) + return -1; + if (fstat (fd, &st) < 0) return -1; mydev = st.st_dev; |