libc/stdio: Fail fdopen() on an execute-only fd.
authorjilles <jilles@FreeBSD.org>
Mon, 21 Apr 2014 17:40:23 +0000 (17:40 +0000)
committerjilles <jilles@FreeBSD.org>
Mon, 21 Apr 2014 17:40:23 +0000 (17:40 +0000)
commita3c80349e7d6aa6322ba05792d53942ade57df9d
tree64121b0b1142a6b56d9bed6961f9161daa1d30d3
parent08414b8dda2e9ba3198516394f5edec20853f9f5
libc/stdio: Fail fdopen() on an execute-only fd.

An execute-only fd (opened with O_EXEC) allows neither read() nor write()
and is therefore incompatible with all stdio modes. Therefore, the [EINVAL]
error applies.

Also adjust the similar check in freopen() with a NULL path, even though
this checks an fd which is already from a FILE.
lib/libc/stdio/fdopen.c
lib/libc/stdio/freopen.c
tools/regression/lib/libc/stdio/Makefile
tools/regression/lib/libc/stdio/test-fdopen.c [new file with mode: 0644]
tools/regression/lib/libc/stdio/test-fdopen.t [new file with mode: 0644]
tools/regression/lib/libc/stdio/test-freopen.c [new file with mode: 0644]
tools/regression/lib/libc/stdio/test-freopen.t [new file with mode: 0644]