[openssh-commits] [openssh] 01/03: Don't deref NULL on STREAMS tty alloc failure.

git+noreply at mindrot.org git+noreply at mindrot.org
Sun Sep 20 12:04:02 AEST 2026


This is an automated email from the git hooks/post-receive script.

dtucker pushed a commit to branch master
in repository openssh.

commit b836083ed96a0f7b729d84d066cc657e6616112f
Author: Darren Tucker <dtucker at dtucker.net>
AuthorDate: Sat Sep 19 15:13:55 2026 -0600

    Don't deref NULL on STREAMS tty alloc failure.
---
 openbsd-compat/bsd-openpty.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/openbsd-compat/bsd-openpty.c b/openbsd-compat/bsd-openpty.c
index 45b858855..5636c5990 100644
--- a/openbsd-compat/bsd-openpty.c
+++ b/openbsd-compat/bsd-openpty.c
@@ -161,15 +161,17 @@ openpty(int *amaster, int *aslave, char *name, const struct termios *termp,
 	 */
 	int r, fd;
 	static int junk_ptyfd = -1, junk_ttyfd;
+	char *junk_name;
 
 	r = openpty_streams(amaster, aslave);
 	if (junk_ptyfd == -1 && (fd = open(_PATH_TTY, O_RDWR|O_NOCTTY)) >= 0) {
 		close(fd);
 		junk_ptyfd = *amaster;
 		junk_ttyfd = *aslave;
+		junk_name = ttyname(junk_ttyfd);
 		debug("STREAMS bug workaround pty %d tty %d name %s",
-		    junk_ptyfd, junk_ttyfd, ttyname(junk_ttyfd));
-        } else
+		    junk_ptyfd, junk_ttyfd, junk_name ? junk_name : "<none>");
+	} else
 		return r;
 #endif
 

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list