aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaine Stump <laine@laine.org>2012-09-19 18:45:58 -0400
committerLaine Stump <laine@laine.org>2012-09-19 21:43:02 -0400
commitdb8760ffe67cc2a4af62cf29af3985e4d20ec66e (patch)
treea499d31d9494881e41340f0dc0bc51aada90866d
parentvirsh: Move daemon to misc since its not a network (diff)
downloadlibvirt-db8760ffe67cc2a4af62cf29af3985e4d20ec66e.tar.gz
libvirt-db8760ffe67cc2a4af62cf29af3985e4d20ec66e.tar.bz2
libvirt-db8760ffe67cc2a4af62cf29af3985e4d20ec66e.zip
network: fix element size / length in memmove
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.
-rw-r--r--src/conf/network_conf.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index db398ae89..591eb0311 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -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));
}