diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | pty.c | 10 |
2 files changed, 11 insertions, 4 deletions
@@ -9,6 +9,9 @@ | |||
9 | Miskiewicz <misiek@pld.ORG.PL> | 9 | Miskiewicz <misiek@pld.ORG.PL> |
10 | - (djm) Robustify EGD/PRNGd code in face of socket closures. Patch from | 10 | - (djm) Robustify EGD/PRNGd code in face of socket closures. Patch from |
11 | Todd C. Miller <Todd.Miller@courtesan.com> | 11 | Todd C. Miller <Todd.Miller@courtesan.com> |
12 | - (djm) Use ttyname() to determine name of tty returned by openpty() | ||
13 | rather then risking overflow. Patch from Marek Michalkiewicz | ||
14 | <marekm@amelek.gda.pl> | ||
12 | 15 | ||
13 | 20010217 | 16 | 20010217 |
14 | - (bal) OpenBSD Sync: | 17 | - (bal) OpenBSD Sync: |
@@ -4016,4 +4019,4 @@ | |||
4016 | - Wrote replacements for strlcpy and mkdtemp | 4019 | - Wrote replacements for strlcpy and mkdtemp |
4017 | - Released 1.0pre1 | 4020 | - Released 1.0pre1 |
4018 | 4021 | ||
4019 | $Id: ChangeLog,v 1.787 2001/02/18 01:44:29 djm Exp $ | 4022 | $Id: ChangeLog,v 1.788 2001/02/18 01:49:35 djm Exp $ |
@@ -49,15 +49,19 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen) | |||
49 | { | 49 | { |
50 | #if defined(HAVE_OPENPTY) || defined(BSD4_4) | 50 | #if defined(HAVE_OPENPTY) || defined(BSD4_4) |
51 | /* openpty(3) exists in OSF/1 and some other os'es */ | 51 | /* openpty(3) exists in OSF/1 and some other os'es */ |
52 | char buf[64]; | 52 | char *name; |
53 | int i; | 53 | int i; |
54 | 54 | ||
55 | i = openpty(ptyfd, ttyfd, buf, NULL, NULL); | 55 | i = openpty(ptyfd, ttyfd, NULL, NULL, NULL); |
56 | if (i < 0) { | 56 | if (i < 0) { |
57 | error("openpty: %.100s", strerror(errno)); | 57 | error("openpty: %.100s", strerror(errno)); |
58 | return 0; | 58 | return 0; |
59 | } | 59 | } |
60 | strlcpy(namebuf, buf, namebuflen); /* possible truncation */ | 60 | name = ttyname(*ttyfd); |
61 | if (!name) | ||
62 | fatal("openpty returns device for which ttyname fails."); | ||
63 | |||
64 | strlcpy(namebuf, name, namebuflen); /* possible truncation */ | ||
61 | return 1; | 65 | return 1; |
62 | #else /* HAVE_OPENPTY */ | 66 | #else /* HAVE_OPENPTY */ |
63 | #ifdef HAVE__GETPTY | 67 | #ifdef HAVE__GETPTY |