Loading...
--- Libc/Libc-1725.40.4/stdlib/grantpt.c
+++ Libc/Libc-1353.100.2/stdlib/grantpt.c
@@ -23,15 +23,13 @@
 
 #include <os/assumes.h>
 #include <os/once_private.h>
-
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-
-#include <errno.h>
-#include <fcntl.h>
 #include <pthread.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
 
 /*
  * posix_openpt call for cloning pty implementation.
@@ -50,7 +48,7 @@
 /*
  * grantpt call for cloning pty implementation.
  *
- * Change UID and GID of replica pty associated with primary pty whose
+ * Change UID and GID of slave pty associated with master pty whose
  * fd is provided, to the real UID and real GID of the calling thread.
  */
 int
@@ -125,17 +123,21 @@
 		return -1;
 	}
 
-	if (strlcpy(buffer, ptsnamebuf, buflen) >= buflen) {
+	size_t len = strlen(ptsnamebuf) + 1;
+	if (buflen < len) {
 		errno = ERANGE;
 		return -1;
 	}
+
+	memcpy(buffer, ptsnamebuf, len);
+
 	return 0;
 }
 
 /*
  * unlockpt call for cloning pty implementation.
  *
- * Unlock the replica pty associated with the primary to which fd refers.
+ * Unlock the slave pty associated with the master to which fd refers.
  */
 int
 unlockpt(int fd)