sshpty.c.patch   [plain text]


--- sshpty.c.orig	2006-01-24 23:45:13.000000000 -0800
+++ sshpty.c	2006-01-24 23:50:08.000000000 -0800
@@ -41,17 +41,18 @@
 pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
 {
 	/* openpty(3) exists in OSF/1 and some other os'es */
-	char *name;
+	/*
+	 * ttyname() may fail due to different sshd code paths.  However,
+	 * we can just get the tty name from openpty() and avoid ttyname().
+	 */
+	char name[64];
 	int i;
 
-	i = openpty(ptyfd, ttyfd, NULL, NULL, NULL);
+	i = openpty(ptyfd, ttyfd, name, NULL, NULL);
 	if (i < 0) {
 		error("openpty: %.100s", strerror(errno));
 		return 0;
 	}
-	name = ttyname(*ttyfd);
-	if (!name)
-		fatal("openpty returns device for which ttyname fails.");
 
 	strlcpy(namebuf, name, namebuflen);	/* possible truncation */
 	return 1;