diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2012-05-21 14:56:02 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2012-05-21 14:56:02 +0000 |
commit | 6cb222edcee9bdb43bb2ee5f01e6de5a4df976f2 (patch) | |
tree | 7515fc582af1e925a39d5ed8d471a8062c72d2a7 /winsup/cygwin/net.cc | |
parent | ece05938f2e2b52dd458e53644f0db6a10bdfd90 (diff) | |
download | cygnal-6cb222edcee9bdb43bb2ee5f01e6de5a4df976f2.tar.gz cygnal-6cb222edcee9bdb43bb2ee5f01e6de5a4df976f2.tar.bz2 cygnal-6cb222edcee9bdb43bb2ee5f01e6de5a4df976f2.zip |
* net.cc (cygwin_recvfrom): Don't shortcircuit if len == 0. Add comment
to explain why.
(cygwin_recv): Ditto.
(cygwin_recvmsg): Ditto.
Diffstat (limited to 'winsup/cygwin/net.cc')
-rw-r--r-- | winsup/cygwin/net.cc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index a0a83b55a..3106a8daf 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -712,7 +712,11 @@ cygwin_recvfrom (int fd, void *buf, size_t len, int flags, myfault efault; if (efault.faulted (EFAULT) || !fh) res = -1; - else if ((res = len) != 0) + else + /* Originally we shortcircuited here if res == 0. + Allow 0 bytes buffer. This is valid in POSIX and handled in + fhandler_socket::recv_internal. If we shortcircuit, we fail + to deliver valid error conditions and peer address. */ res = fh->recvfrom (buf, len, flags, from, fromlen); syscall_printf ("%R = recvfrom(%d, %p, %d, %x, %p, %p)", @@ -1465,7 +1469,11 @@ cygwin_recv (int fd, void *buf, size_t len, int flags) myfault efault; if (efault.faulted (EFAULT) || !fh) res = -1; - else if ((res = len) != 0) + else + /* Originally we shortcircuited here if res == 0. + Allow 0 bytes buffer. This is valid in POSIX and handled in + fhandler_socket::recv_internal. If we shortcircuit, we fail + to deliver valid error conditions. */ res = fh->recvfrom (buf, len, flags, NULL, NULL); syscall_printf ("%R = recv(%d, %p, %d, %x)", res, fd, buf, len, flags); @@ -2865,7 +2873,11 @@ cygwin_recvmsg (int fd, struct msghdr *msg, int flags) else { res = check_iovec_for_read (msg->msg_iov, msg->msg_iovlen); - if (res > 0) + /* Originally we shortcircuited here if res == 0. + Allow 0 bytes buffer. This is valid in POSIX and handled in + fhandler_socket::recv_internal. If we shortcircuit, we fail + to deliver valid error conditions and peer address. */ + if (res >= 0) res = fh->recvmsg (msg, flags); } |