[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 8/9] iov_send_recv(): Handle zero bytes case even if
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PATCH 8/9] iov_send_recv(): Handle zero bytes case even if OS does not |
Date: |
Wed, 15 Aug 2012 16:09:03 +0100 |
From: Peter Maydell <address@hidden>
POSIX allows sendmsg() and recvmsg() to fail EMSGSIZE if passed a zero
msg.msg_iovlen (in particular the MacOS X implementation will do this).
Handle the case where iov_send_recv() is passed a zero byte count
explicitly, to avoid accidentally depending on the OS to treat zero
msg_iovlen as a no-op.
Signed-off-by: Peter Maydell <address@hidden>
Acked-by: Michael Tokarev <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
iov.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/iov.c b/iov.c
index b333061..60705c7 100644
--- a/iov.c
+++ b/iov.c
@@ -146,6 +146,13 @@ ssize_t iov_send_recv(int sockfd, struct iovec *iov,
unsigned iov_cnt,
{
ssize_t ret;
unsigned si, ei; /* start and end indexes */
+ if (bytes == 0) {
+ /* Catch the do-nothing case early, as otherwise we will pass an
+ * empty iovec to sendmsg/recvmsg(), and not all implementations
+ * accept this.
+ */
+ return 0;
+ }
/* Find the start position, skipping `offset' bytes:
* first, skip all full-sized vector elements, */
--
1.7.10.4
- [Qemu-devel] [PULL 0/9 for-1.2] Trivial patches for 11 to 15 August 2012, Stefan Hajnoczi, 2012/08/15
- [Qemu-devel] [PATCH 1/9] Makefile: Avoid explicit list of directories in clean target, Stefan Hajnoczi, 2012/08/15
- [Qemu-devel] [PATCH 4/9] trace: Fix "Qemu" -> "QEMU", Stefan Hajnoczi, 2012/08/15
- [Qemu-devel] [PATCH 2/9] ehci: fix assertion typo, Stefan Hajnoczi, 2012/08/15
- [Qemu-devel] [PATCH 3/9] cputlb.c: Fix out of date comment, Stefan Hajnoczi, 2012/08/15
- [Qemu-devel] [PATCH 5/9] docs: Fix spelling (propery -> property), Stefan Hajnoczi, 2012/08/15
- [Qemu-devel] [PATCH 6/9] Spelling fix in comment (peripherans -> peripherals), Stefan Hajnoczi, 2012/08/15
- [Qemu-devel] [PATCH 7/9] framebuffer: Fix spelling in comment (leight -> height), Stefan Hajnoczi, 2012/08/15
- [Qemu-devel] [PATCH 8/9] iov_send_recv(): Handle zero bytes case even if OS does not,
Stefan Hajnoczi <=
- [Qemu-devel] [PATCH 9/9] ivshmem, qdev-monitor: fix order of qerror parameters, Stefan Hajnoczi, 2012/08/15
- Re: [Qemu-devel] [PULL 0/9 for-1.2] Trivial patches for 11 to 15 August 2012, Anthony Liguori, 2012/08/15