Loading...
--- Libc/Libc-498/stdlib/grantpt.c
+++ Libc/Libc-1244.1.7/stdlib/grantpt.c
@@ -62,11 +62,15 @@
char *
ptsname(int fd)
{
- static char ptsnamebuf[ 128]; /* ioctl knows length */
+ static char *ptsnamebuf = NULL;
int error;
char *retval = NULL;
struct stat sbuf;
+ if (ptsnamebuf == NULL) {
+ ptsnamebuf = malloc(128); // defined by TIOCPTYGNAME
+ }
+
error = ioctl(fd, TIOCPTYGNAME, ptsnamebuf);
if (!error) {
/*
@@ -75,8 +79,9 @@
* POSIX: Handle device rename test case, which is expected
* to fail if the pty has been renamed.
*/
- if (stat(ptsnamebuf, &sbuf) == 0)
+ if (stat(ptsnamebuf, &sbuf) == 0) {
retval = ptsnamebuf;
+ }
}
return (retval);