|
From: | Keith Reynolds |
Subject: | openpty bug in inetutils-1.3.2-19 (STREAMSPTY/CYGWIN) |
Date: | Wed, 18 Sep 2002 17:59:09 -0700 |
The openpty() function in libinetutils opens /dev/ptmx if STREAMSPTY or __CYGWIN__ are defined. It incorrectly checks the return value from open to see if it's greater than 0; since 0 is a perfectly valid file descriptor value, it should check for greater than or equal to 0. I ran into this when using it from a Windows-compiled binary under cygwin; such processes don't have stdin/stdout/stderr open for them, so openpty() was getting fd 0 for /dev/ptmx.
A simple context diff is below.
Keith Reynolds
Senior Software Engineer
F5 Networks
http://www.f5.com
--- openpty.c- 2002-09-18 17:48:20.000000000 -0700
+++ openpty.c 2002-09-18 17:44:25.000000000 -0700
@@ -69,7 +69,7 @@
char *ptsname();
master = open("/dev/ptmx", O_RDWR);
- if (master > 0) {
+ if (master >= 0) {
grantpt(master);
unlockpt(master);
strcpy(line, ptsname(master));
[Prev in Thread] | Current Thread | [Next in Thread] |