提交 3e5d48ef 编写于 作者: D Daniel P. Berrange

Fix potential crash in libvirtd with active streams

If a client disconnects while it has a stream active, there is
a race condition which could see libvirtd crash. This is because
the client struct may be freed before the last stream event has
triggered. This is trivially solved by holding an extra reference
on the client for the stream callbak

* daemon/stream.c: Acquire reference on client when adding the
  stream callback
上级 c2ddd536
......@@ -104,6 +104,15 @@ daemonStreamMessageFinished(virNetMessagePtr msg,
daemonStreamUpdateEvents(stream);
}
static void
daemonStreamEventFreeFunc(void *opaque)
{
virNetServerClientPtr client = opaque;
virNetServerClientFree(client);
}
/*
* Callback that gets invoked when a stream becomes writable/readable
*/
......@@ -361,9 +370,11 @@ int daemonAddClientStream(virNetServerClientPtr client,
}
if (virStreamEventAddCallback(stream->st, 0,
daemonStreamEvent, client, NULL) < 0)
daemonStreamEvent, client,
daemonStreamEventFreeFunc) < 0)
return -1;
virNetServerClientRef(client);
if ((stream->filterID = virNetServerClientAddFilter(client,
daemonStreamFilter,
stream)) < 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册