1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-28 00:21:52 +03:00

BZ #11538: Fix ttyname_r callers not to expect errno was set.

This commit is contained in:
Bruno Haible
2010-04-28 15:00:14 -07:00
committed by Roland McGrath
parent 6cffee3611
commit 8c0677fe5d
3 changed files with 20 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1998,2002 Free Software Foundation, Inc.
/* Copyright (C) 1998,2002,2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@ -44,6 +44,7 @@ int
__ptsname_r (int fd, char *buf, size_t buflen)
{
int save_errno = errno;
int err;
struct stat st;
if (buf == NULL)
@ -62,8 +63,12 @@ __ptsname_r (int fd, char *buf, size_t buflen)
return ERANGE;
}
if (__ttyname_r (fd, buf, buflen) != 0)
return errno;
err = __ttyname_r (fd, buf, buflen);
if (err != 0)
{
__set_errno (err);
return errno;
}
buf[sizeof (_PATH_DEV) - 1] = 't';