This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] linux ttyname and ttyname_r: return link if appropriate


On Wed, Apr 20, 2016 at 06:51:41PM +0000, Serge Hallyn wrote:
> 1. If the passed-in link (say /proc/self/fd/0) points to a
> device, say /dev/pts/2, in a parent mount namespace, and a
> /dev/pts/2 exists (in a different devpts) in the current
> namespace, then it returns /dev/pts/2.  But /dev/pts/2 is
> NOT the current tty, it is a different file and device.
[...]
> --- a/sysdeps/unix/sysv/linux/ttyname.c
> +++ b/sysdeps/unix/sysv/linux/ttyname.c
[...]
> @@ -170,12 +184,19 @@ ttyname (int fd)
>  #ifdef _STATBUF_ST_RDEV
>  	  && S_ISCHR (st1.st_mode)
>  	  && st1.st_rdev == st.st_rdev
> +	  && st1.st_dev == st.st_dev
>  #else
>  	  && st1.st_ino == st.st_ino
>  	  && st1.st_dev == st.st_dev
>  #endif

__ttyname_r also needs this st_dev check.

To be on the safe side, I'd check st_ino in _STATBUF_ST_RDEV case as well.


-- 
ldv

Attachment: pgpxJ7PSgysj_.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]