aboutsummaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-05-12 04:43:29 +0000
committerChristopher Faylor <me@cgf.cx>2002-05-12 04:43:29 +0000
commitb4f8d31f3bd25dce1e3ab50de7ed7aa757e0ed80 (patch)
tree1251df4a56ddeb2e685910e654c660479c94ddc0 /winsup
parent48897dfeb90a2c09949c7e9679c3edfbe92a5eec (diff)
downloadnewlib-b4f8d31f3bd25dce1e3ab50de7ed7aa757e0ed80.zip
newlib-b4f8d31f3bd25dce1e3ab50de7ed7aa757e0ed80.tar.gz
newlib-b4f8d31f3bd25dce1e3ab50de7ed7aa757e0ed80.tar.bz2
* syscalls.cc (_read): Change error to EBADF if attempt to write to a
non-writable fd.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/syscalls.cc8
2 files changed, 13 insertions, 0 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 09ba326..b7940bc 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,8 @@
+2002-05-12 Christopher Faylor <cgf@redhat.com>
+
+ * syscalls.cc (_read): Change error to EBADF if attempt to write to a
+ non-writable fd.
+
2002-05-11 Christopher Faylor <cgf@redhat.com>
* fhandler.h (executable_states): For now, make dont_care_if_executable
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 0be393a..46ea12f 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -340,6 +340,14 @@ _read (int fd, void *ptr, size_t len)
}
out:
+
+ if (res && get_errno () == EACCES &&
+ !(cfd->get_flags () & (O_RDONLY | O_RDWR)))
+ {
+ set_errno (EBADF);
+ break;
+ }
+
if (res >= 0 || get_errno () != EINTR || !thisframe.call_signal_handler ())
break;
set_errno (e);