summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/fopen.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2008-04-22 17:03:32 +0000
committerjhb <jhb@FreeBSD.org>2008-04-22 17:03:32 +0000
commita3eb935764e3431a6128e1a633a0ef4d8175c38e (patch)
tree586fe0e0153621aa12a531ce79638001553805ed /lib/libc/stdio/fopen.c
parentf40924813a4155b33666320812fb47c3c554f600 (diff)
downloadFreeBSD-src-a3eb935764e3431a6128e1a633a0ef4d8175c38e.zip
FreeBSD-src-a3eb935764e3431a6128e1a633a0ef4d8175c38e.tar.gz
Fix a leak in the recent fixes for file descriptors > SHRT_MAX. In the
case of a file descriptor we can't handle, clear the FILE structure's flags so it can be reused. MFC after: 1 week Reported by: otto @ OpenBSD
Diffstat (limited to 'lib/libc/stdio/fopen.c')
-rw-r--r--lib/libc/stdio/fopen.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/libc/stdio/fopen.c b/lib/libc/stdio/fopen.c
index 14ec9bc..6fe536a 100644
--- a/lib/libc/stdio/fopen.c
+++ b/lib/libc/stdio/fopen.c
@@ -73,6 +73,7 @@ fopen(file, mode)
* open.
*/
if (f > SHRT_MAX) {
+ fp->_flags = 0; /* release */
_close(f);
errno = EMFILE;
return (NULL);
OpenPOWER on IntegriCloud