diff options
author | Christopher Faylor <me@cgf.cx> | 2001-11-15 03:25:52 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2001-11-15 03:25:52 +0000 |
commit | e2b3dc25804ce3688ac69a7249323e90ae82305e (patch) | |
tree | 0588c2572c4379a84a5c356639f8d6d85984753c /winsup/cygwin/syscalls.cc | |
parent | d590035529cb51a0c1981ae9aff69e92d8755d6e (diff) | |
download | cygnal-e2b3dc25804ce3688ac69a7249323e90ae82305e.tar.gz cygnal-e2b3dc25804ce3688ac69a7249323e90ae82305e.tar.bz2 cygnal-e2b3dc25804ce3688ac69a7249323e90ae82305e.zip |
* exceptions.cc: Add stdlib.h include for alloca declaration.
* poll.cc: Ditto.
* termios.cc: Ditto.
* syscalls.cc (_write): Only allow zero length when fd is valid.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r-- | winsup/cygwin/syscalls.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 848e0e44f..d0896169b 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -355,12 +355,6 @@ _read (int fd, void *ptr, size_t len) extern "C" ssize_t _write (int fd, const void *ptr, size_t len) { - if (len == 0) - return 0; - - if (__check_invalid_read_ptr_errno (ptr, len)) - return -1; - int res = -1; sigframe thisframe (mainthread); @@ -368,6 +362,16 @@ _write (int fd, const void *ptr, size_t len) if (cfd < 0) goto done; + /* No further action required for len == 0 */ + if (len == 0) + { + res = 0; + goto done; + } + + if (len && __check_invalid_read_ptr_errno (ptr, len)) + goto done; + /* Could block, so let user know we at least got here. */ if (fd == 1 || fd == 2) paranoid_printf ("write (%d, %p, %d)", fd, ptr, len); |