Our unit test verifies that unlockpt() checks against an invalid argument. But gnulib's implementation does not always do this check.
2011-10-20 Bruno Haible <br...@clisp.org> unlockpt: Detect invalid argument. * lib/unlockpt.c: Include <fcntl.h>. (unlockpt): Check whether fd is valid, using fcntl(). * modules/unlockpt (Depends-on): Add fcntl-h. --- lib/unlockpt.c.orig Fri Oct 21 02:20:26 2011 +++ lib/unlockpt.c Fri Oct 21 02:18:27 2011 @@ -19,6 +19,7 @@ #include <stdlib.h> +#include <fcntl.h> #include <unistd.h> int @@ -36,6 +37,8 @@ #else /* Assume that the slave side of a pseudo-terminal is already unlocked by default. */ + if (fcntl (fd, F_GETFD) < 0) + return -1; return 0; #endif } --- modules/unlockpt.orig Fri Oct 21 02:20:26 2011 +++ modules/unlockpt Fri Oct 21 02:20:08 2011 @@ -9,6 +9,7 @@ Depends-on: stdlib extensions +fcntl-h [test $HAVE_UNLOCKPT = 0] ptsname [test $HAVE_UNLOCKPT = 0] configure.ac: -- In memoriam Eduard Brücklmeier <http://en.wikipedia.org/wiki/Eduard_Brücklmeier>