OSDN Git Service

* syscalls.cc (_read): Change error to EBADF if attempt to write to a
authorcgf <cgf>
Sun, 12 May 2002 04:43:29 +0000 (04:43 +0000)
committercgf <cgf>
Sun, 12 May 2002 04:43:29 +0000 (04:43 +0000)
non-writable fd.

winsup/cygwin/ChangeLog
winsup/cygwin/syscalls.cc

index 09ba326..b7940bc 100644 (file)
@@ -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
index 0be393a..46ea12f 100644 (file)
@@ -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);