]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
network: fix element size / length in memmove
authorLaine Stump <laine@laine.org>
Wed, 19 Sep 2012 22:45:58 +0000 (18:45 -0400)
committerLaine Stump <laine@laine.org>
Thu, 20 Sep 2012 01:43:02 +0000 (21:43 -0400)
The memmove to move elements in the dhcp hosts array when inserting
and deleting items was mistakenly basing the length of the copy on the
size of a virNetworkDHCPHostDefPtr rather than virNetworkDHCPHostDef,
with the expected disastrous results.

The memmove to delete an entry commits two errors - along with the
size of each element being wrong, it also omits some required
parentheses.

src/conf/network_conf.c

index db398ae89eb2f2b986f4fe7194c29b067582e52b..591eb0311151dff7387d8471c63f27905c9ac569 100644 (file)
@@ -2449,7 +2449,7 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def,
         } else { /* implied (command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST) */
 
             memmove(ipdef->hosts + 1, ipdef->hosts,
-                    sizeof(ipdef->hosts) * ipdef->nhosts);
+                    sizeof(*ipdef->hosts) * ipdef->nhosts);
             ipdef->hosts[0] = host;
             ipdef->nhosts++;
             memset(&host, 0, sizeof(host));
@@ -2481,7 +2481,7 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def,
         /* remove it */
         virNetworkDHCPHostDefClear(&ipdef->hosts[ii]);
         memmove(ipdef->hosts + ii, ipdef->hosts + ii + 1,
-                sizeof(ipdef->hosts) * ipdef->nhosts - ii - 1);
+                sizeof(*ipdef->hosts) * (ipdef->nhosts - ii - 1));
         ipdef->nhosts--;
         ignore_value(VIR_REALLOC_N(ipdef->hosts, ipdef->nhosts));
     }