]> xenbits.xensource.com Git - libvirt.git/commitdiff
bhyve: fix crash in bhyveBuildNetArgStr
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Fri, 13 Jun 2014 16:14:53 +0000 (20:14 +0400)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Fri, 13 Jun 2014 16:44:36 +0000 (20:44 +0400)
bhyveBuildNetArgStr() calls virNetDevTapCreateInBridgePort() and
passes tapfd = NULL, but tapfdSize = 1. That is wrong, because
if virNetDevTapCreateInBridgePort() crashes after successfully
creating a TAP device, it'll jump to 'error' label, that
loops over tapfd and calls VIR_FORCE_CLOSE:

   for (i = 0; i < tapfdSize && tapfd[i] >= 0; i++)

In that case we get a segfault.

As the bhyve code doesn't use tapfd, pass NULL and set tapfdSize to 0.

src/bhyve/bhyve_command.c

index d3b3f69998fe2ae04003c9433e2ea6f1a2b3908b..f1862fead2fa0d18107eef63c99781b424856ac0 100644 (file)
@@ -46,7 +46,6 @@ bhyveBuildNetArgStr(const virDomainDef *def,
 {
     char macaddr[VIR_MAC_STRING_BUFLEN];
     char *realifname = NULL;
-    int *tapfd = NULL;
     char *brname = NULL;
     int actualType = virDomainNetGetActualType(net);
 
@@ -72,7 +71,7 @@ bhyveBuildNetArgStr(const virDomainDef *def,
 
     if (!dryRun) {
         if (virNetDevTapCreateInBridgePort(brname, &net->ifname, &net->mac,
-                                           def->uuid, tapfd, 1,
+                                           def->uuid, NULL, 0,
                                            virDomainNetGetActualVirtPortProfile(net),
                                            virDomainNetGetActualVlan(net),
                                            VIR_NETDEV_TAP_CREATE_IFUP | VIR_NETDEV_TAP_CREATE_PERSIST) < 0) {