Don't pass -1 as the length to write() if read() fails

This commit is contained in:
Kevin Easton
2017-11-17 23:06:46 +11:00
parent 149b3206e0
commit 0abfa67aa8

View File

@@ -505,11 +505,13 @@ void reattach_tty(char *tty, char *password)
if (FD_ISSET(0, &rd_fd))
{
len = read(0, buffer, sizeof(buffer)-1);
if (len > 0)
write(s, buffer, len);
}
if (FD_ISSET(s, &rd_fd))
{
len = read(s, buffer, sizeof(buffer)-1);
if (len > 0)
write(1, buffer, len);
}
}