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.
This commit is contained in:
Ulrich Drepper 1999-04-01 09:33:06 +00:00
parent 134c659cc7
commit 7081e0a34c
3 changed files with 20 additions and 3 deletions

View File

@ -1,3 +1,9 @@
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.
1999-04-01 Ulrich Drepper <drepper@cygnus.com>
* iconvdata/TESTS: Add ISO-8859-14 and ISO-8859-15.

View File

@ -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;

View File

@ -134,7 +134,10 @@ __ttyname_r (fd, buf, buflen)
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);