[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
unlockpt and EBADF
From: |
Bruno Haible |
Subject: |
unlockpt and EBADF |
Date: |
Fri, 21 Oct 2011 02:25:51 +0200 |
User-agent: |
KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; ) |
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 <address@hidden>
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>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- unlockpt and EBADF,
Bruno Haible <=