]> Savannah Git Hosting - gnulib.git/commitdiff
unlockpt: Detect invalid argument.
authorBruno Haible <bruno@clisp.org>
Fri, 21 Oct 2011 00:22:04 +0000 (02:22 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 21 Oct 2011 00:25:15 +0000 (02:25 +0200)
* lib/unlockpt.c: Include <fcntl.h>.
(unlockpt): Check whether fd is valid, using fcntl().
* modules/unlockpt (Depends-on): Add fcntl-h.

ChangeLog
lib/unlockpt.c
modules/unlockpt

index 0f0b5a39fef7e2eb91c833a7c7bb0172318bf304..c670c9c17b42202772f163a09650bf3bf4b361e4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-10-20  Bruno Haible  <bruno@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.
+
 2011-10-20  Bruno Haible  <bruno@clisp.org>
 
        openpty: Avoid compilation error on AIX 6.1.
index e03b31f35430f58ce096bb4c61d021a011748a81..678548705755e36b72314174b821df403a0c2553 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <stdlib.h>
 
+#include <fcntl.h>
 #include <unistd.h>
 
 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
 }
index cca3f168b8a33570e10a5a4781851111ef18370a..c91796425dc1ed67b12a9b68c3a7589a104802fb 100644 (file)
@@ -9,6 +9,7 @@ m4/unlockpt.m4
 Depends-on:
 stdlib
 extensions
+fcntl-h         [test $HAVE_UNLOCKPT = 0]
 ptsname         [test $HAVE_UNLOCKPT = 0]
 
 configure.ac: