summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authormarcus <marcus@FreeBSD.org>2005-07-07 17:48:40 +0000
committermarcus <marcus@FreeBSD.org>2005-07-07 17:48:40 +0000
commit979be5a2e14d0620c8c3f9349fa59057243ab738 (patch)
treee6971802a667e9de8d82db62d2f08e6ce2a29f6c /lib
parent28b7f562fc678fae0db68e2f56a58b703f9a93dd (diff)
downloadFreeBSD-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')
-rw-r--r--lib/libc/stdlib/grantpt.c7
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;
}
}
OpenPOWER on IntegriCloud