mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 04:55:18 +00:00
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.
This commit is contained in:
parent
6a1b0e37af
commit
db8760ffe6
@ -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));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user