[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 03/24] qemu-char: check socket is actually connected
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH 03/24] qemu-char: check socket is actually connected |
Date: |
Tue, 21 Jun 2016 12:02:31 +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 84f49ac..06eaba3 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2761,14 +2761,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.7.4
- [Qemu-devel] [PATCH 00/24] vhost-user reconnect fixes, marcandre . lureau, 2016/06/21
- [Qemu-devel] [PATCH 02/24] vhost-user: minor simplification, marcandre . lureau, 2016/06/21
- [Qemu-devel] [PATCH 03/24] qemu-char: check socket is actually connected,
marcandre . lureau <=
- [Qemu-devel] [PATCH 01/24] misc: indentation, marcandre . lureau, 2016/06/21
- [Qemu-devel] [PATCH 04/24] vhost-user: check qemu_chr_fe_set_msgfds() return value, marcandre . lureau, 2016/06/21
- [Qemu-devel] [PATCH 07/24] vhost: use error_report() instead of fprintf(stderr, ...), marcandre . lureau, 2016/06/21
- [Qemu-devel] [PATCH 08/24] vhost-user: return a read error, marcandre . lureau, 2016/06/21
[Qemu-devel] [PATCH 09/24] vhost: make vhost_log_put() idempotent, marcandre . lureau, 2016/06/21
[Qemu-devel] [PATCH 05/24] vhost: change some assert() for error_report() or silent fail, marcandre . lureau, 2016/06/21