[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 01/15] qemu-char: fix tcp_get_fds
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL v2 01/15] qemu-char: fix tcp_get_fds |
Date: |
Mon, 24 Nov 2014 21:30:33 +0200 |
tcp_get_fds API discards fds if there's more than 1 of these.
It's tricky to fix this without API changes in the generic case.
However, this API is only used by tests ATM, and tests know how
many fds they expect.
So let's not waste cycles trying to fix this properly:
simply assume at most 16 fds (tests use at most 8 now).
assert if some test tries to get more.
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
qemu-char.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/qemu-char.c b/qemu-char.c
index 4a76f0f..a8b01da 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -88,6 +88,7 @@
#define READ_BUF_LEN 4096
#define READ_RETRIES 10
#define CHR_MAX_FILENAME_SIZE 256
+#define TCP_MAX_FDS 16
/***********************************************************/
/* Socket address helpers */
@@ -2668,6 +2669,8 @@ static int tcp_get_msgfds(CharDriverState *chr, int *fds,
int num)
TCPCharDriver *s = chr->opaque;
int to_copy = (s->read_msgfds_num < num) ? s->read_msgfds_num : num;
+ assert(num <= TCP_MAX_FDS);
+
if (to_copy) {
int i;
@@ -2762,7 +2765,7 @@ static ssize_t tcp_chr_recv(CharDriverState *chr, char
*buf, size_t len)
struct iovec iov[1];
union {
struct cmsghdr cmsg;
- char control[CMSG_SPACE(sizeof(int))];
+ char control[CMSG_SPACE(sizeof(int) * TCP_MAX_FDS)];
} msg_control;
int flags = 0;
ssize_t ret;
--
MST
- [Qemu-devel] [PULL v2 00/15] pc, pci, misc bugfixes, Michael S. Tsirkin, 2014/11/24
- [Qemu-devel] [PULL v2 01/15] qemu-char: fix tcp_get_fds,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL v2 02/15] pc: kvm: check if KVM has free memory slots to avoid abort(), Michael S. Tsirkin, 2014/11/24
- [Qemu-devel] [PULL v2 03/15] pc: make pc_dimm_plug() more readble, Michael S. Tsirkin, 2014/11/24
- [Qemu-devel] [PULL v2 04/15] pc: limit DIMM address and size to page aligned values, Michael S. Tsirkin, 2014/11/24
- [Qemu-devel] [PULL v2 05/15] memory: expose alignment used for allocating RAM as MemoryRegion API, Michael S. Tsirkin, 2014/11/24
- [Qemu-devel] [PULL v2 06/15] pc: align DIMM's address/size by backend's alignment value, Michael S. Tsirkin, 2014/11/24
- [Qemu-devel] [PULL v2 09/15] pc: count in 1Gb hugepage alignment when sizing hotplug-memory container, Michael S. Tsirkin, 2014/11/24
- [Qemu-devel] [PULL v2 11/15] acpi-build: mark RAM dirty on table update, Michael S. Tsirkin, 2014/11/24
- [Qemu-devel] [PULL v2 07/15] pc: pc-dimm: use backend alignment during address auto allocation, Michael S. Tsirkin, 2014/11/24
- [Qemu-devel] [PULL v2 12/15] target-i386: move generic memory hotplug methods to DSDTs, Michael S. Tsirkin, 2014/11/24
- [Qemu-devel] [PULL v2 13/15] pcie: fix typo in pcie_cap_deverr_init(), Michael S. Tsirkin, 2014/11/24