]> xenbits.xensource.com Git - people/dariof/libvirt.git/commitdiff
domain_conf: fix possible memory leak
authorMartin Kletzander <mkletzan@redhat.com>
Tue, 19 Jun 2012 10:08:49 +0000 (12:08 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Tue, 19 Jun 2012 16:20:03 +0000 (18:20 +0200)
Until now, it was possible to crash libvirtd when defining domain with
channel device with missing source element.

When creating new virDomainChrDef, target.port is set to -1, but
unfortunately it is an union with addresses that virDomainChrDefFree
tries to free in case the deviceType is channel. Having the port set
to -1 is intended, however the cleanest way to get around the problems
with the crash seems to be renumbering the VIR_DOMAIN_CHR_CHANNEL_
target types to cover new NONE type (with value 0) being the default
(no target type yet).

src/conf/domain_conf.c
src/conf/domain_conf.h

index 5ea264f715241194ba70b88b81a9d1f12c071df7..ef6077ee28a6da64711b6742ac2a918cd1bc76fd 100644 (file)
@@ -307,6 +307,7 @@ VIR_ENUM_IMPL(virDomainNetInterfaceLinkState, VIR_DOMAIN_NET_INTERFACE_LINK_STAT
 
 VIR_ENUM_IMPL(virDomainChrChannelTarget,
               VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST,
+              "none",
               "guestfwd",
               "virtio")
 
index 86c1e630938b0ad40527933b4529395a1bd8050f..44280bae8ee75fc9f87510e5e8805ac61abcb9e3 100644 (file)
@@ -855,7 +855,8 @@ enum virDomainChrDeviceType {
 };
 
 enum virDomainChrChannelTargetType {
-    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD = 0,
+    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_NONE = 0,
+    VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD,
     VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO,
 
     VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_LAST,