diff options
author | marcus <marcus@FreeBSD.org> | 2005-07-07 17:48:40 +0000 |
---|---|---|
committer | marcus <marcus@FreeBSD.org> | 2005-07-07 17:48:40 +0000 |
commit | 979be5a2e14d0620c8c3f9349fa59057243ab738 (patch) | |
tree | e6971802a667e9de8d82db62d2f08e6ce2a29f6c /lib/libc/stdlib/grantpt.c | |
parent | 28b7f562fc678fae0db68e2f56a58b703f9a93dd (diff) | |
download | FreeBSD-src-979be5a2e14d0620c8c3f9349fa59057243ab738.zip FreeBSD-src-979be5a2e14d0620c8c3f9349fa59057243ab738.tar.gz |
Fix ptsname(3) by converting it to use devname(3) to obtain the name of
a tty device instead of the legacy minor number approach. This is known to
fix gnome-vfs' sftp module as well as kio_sftp and kdesu on -CURRENT.
Thanks to scottl for the snprintf() approach idea.
Reviewed by: phk
Tested by: pav
mich
Approved by: re (scottl)
Diffstat (limited to 'lib/libc/stdlib/grantpt.c')
-rw-r--r-- | lib/libc/stdlib/grantpt.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libc/stdlib/grantpt.c b/lib/libc/stdlib/grantpt.c index d0cb4eb..a466cba 100644 --- a/lib/libc/stdlib/grantpt.c +++ b/lib/libc/stdlib/grantpt.c @@ -223,9 +223,10 @@ ptsname(int fildes) if (!ISPTM(sbuf)) errno = EINVAL; else { - (void)sprintf(slave, _PATH_DEV PTS_PREFIX "%c%c", - PT_DEV1[minor(sbuf.st_rdev) / 32], - PT_DEV2[minor(sbuf.st_rdev) % 32]); + (void)snprintf(slave, sizeof(slave), + _PATH_DEV PTS_PREFIX "%s", + devname(sbuf.st_rdev, S_IFCHR) + + strlen(PTM_PREFIX)); retval = slave; } } |