diff --git a/contrib/telnet/telnetd/sys_term.c b/contrib/telnet/telnetd/sys_term.c
index 02a7b7c89af5..781e0d14c5e2 100644
--- a/contrib/telnet/telnetd/sys_term.c
+++ b/contrib/telnet/telnetd/sys_term.c
@@ -414,7 +414,8 @@ getpty(int *ptynum __unused)
 	if (pn == NULL)
 		return (-1);
 	
-	strcpy(line, pn);
+	if (strlcpy(line, pn, sizeof line) >= sizeof line)
+		return (-1);
 
 	return (p);
 }