From: Bruno Haible Date: Fri, 21 Oct 2011 00:22:04 +0000 (+0200) Subject: unlockpt: Detect invalid argument. X-Git-Tag: v0.1~1547 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=90bc75734efe584bf3dcdc65e5689123ea78ce11;p=thirdparty%2Fgnulib.git unlockpt: Detect invalid argument. * lib/unlockpt.c: Include . (unlockpt): Check whether fd is valid, using fcntl(). * modules/unlockpt (Depends-on): Add fcntl-h. --- diff --git a/ChangeLog b/ChangeLog index 0f0b5a39fe..c670c9c17b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-10-20 Bruno Haible + + unlockpt: Detect invalid argument. + * lib/unlockpt.c: Include . + (unlockpt): Check whether fd is valid, using fcntl(). + * modules/unlockpt (Depends-on): Add fcntl-h. + 2011-10-20 Bruno Haible openpty: Avoid compilation error on AIX 6.1. diff --git a/lib/unlockpt.c b/lib/unlockpt.c index e03b31f354..6785487057 100644 --- a/lib/unlockpt.c +++ b/lib/unlockpt.c @@ -19,6 +19,7 @@ #include +#include #include int @@ -36,6 +37,8 @@ unlockpt (int fd) #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 } diff --git a/modules/unlockpt b/modules/unlockpt index cca3f168b8..c91796425d 100644 --- a/modules/unlockpt +++ b/modules/unlockpt @@ -9,6 +9,7 @@ m4/unlockpt.m4 Depends-on: stdlib extensions +fcntl-h [test $HAVE_UNLOCKPT = 0] ptsname [test $HAVE_UNLOCKPT = 0] configure.ac: