[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 14/28] qemu-char: check socket is actually connec
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH v3 14/28] qemu-char: check socket is actually connected |
Date: |
Wed, 6 Jul 2016 20:47:07 +0200 |
From: Marc-André Lureau <address@hidden>
Calling qemu_chr_fe_set_msgfds() on unconnected socket can lead to crash
if s->ioc is NULL.
Signed-off-by: Marc-André Lureau <address@hidden>
---
qemu-char.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/qemu-char.c b/qemu-char.c
index 0698b98..c4fa779 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2760,14 +2760,16 @@ static int tcp_set_msgfds(CharDriverState *chr, int
*fds, int num)
{
TCPCharDriver *s = chr->opaque;
- if (!qio_channel_has_feature(s->ioc,
- QIO_CHANNEL_FEATURE_FD_PASS)) {
- return -1;
- }
/* clear old pending fd array */
g_free(s->write_msgfds);
s->write_msgfds = NULL;
+ if (!s->connected ||
+ !qio_channel_has_feature(s->ioc,
+ QIO_CHANNEL_FEATURE_FD_PASS)) {
+ return -1;
+ }
+
if (num) {
s->write_msgfds = g_new(int, num);
memcpy(s->write_msgfds, fds, num * sizeof(int));
--
2.9.0
- Re: [Qemu-devel] [PATCH v3 10/28] vhost: change some assert() for error_report() or silent fail, (continued)
[Qemu-devel] [PATCH v3 11/28] vhost: use error_report() instead of fprintf(stderr, ...), marcandre . lureau, 2016/07/06
[Qemu-devel] [PATCH v3 12/28] vhost-user: check qemu_chr_fe_set_msgfds() return value, marcandre . lureau, 2016/07/06
[Qemu-devel] [PATCH v3 13/28] vhost-user: check vhost_user_{read, write}() return value, marcandre . lureau, 2016/07/06
[Qemu-devel] [PATCH v3 14/28] qemu-char: check socket is actually connected,
marcandre . lureau <=
[Qemu-devel] [PATCH v3 15/28] vhost-user: keep vhost_net after a disconnection, marcandre . lureau, 2016/07/06
[Qemu-devel] [PATCH v3 16/28] Revert "vhost-net: do not crash if backend is not present", marcandre . lureau, 2016/07/06
[Qemu-devel] [PATCH v3 17/28] get_vhost_net() should be != null after vhost_user_init, marcandre . lureau, 2016/07/06
[Qemu-devel] [PATCH v3 18/28] vhost-net: success if backend has no ops->vhost_migration_done, marcandre . lureau, 2016/07/06
[Qemu-devel] [PATCH v3 19/28] vhost: add assert() to check runtime behaviour, marcandre . lureau, 2016/07/06
[Qemu-devel] [PATCH v3 20/28] char: add chr_wait_connected callback, marcandre . lureau, 2016/07/06
[Qemu-devel] [PATCH v3 21/28] char: add and use tcp_chr_wait_connected, marcandre . lureau, 2016/07/06
[Qemu-devel] [PATCH v3 22/28] vhost-user: wait until backend init is completed, marcandre . lureau, 2016/07/06