mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
network: fix crashing "modify" option for hostname
The original condition caused (after adding modify option) possibly access to not allocated memory. For consistency added new check for multiple same records. Resolves: https://gitlab.com/libvirt/libvirt/-/issues/654 Signed-off-by: Adam Julis <ajulis@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
959ecee474
commit
f3e670ee6b
@ -3167,7 +3167,7 @@ virNetworkDefUpdateDNSHost(virNetworkDef *def,
|
||||
|
||||
/* when adding we want to only check duplicates of address since having
|
||||
* multiple addresses with the same hostname is a legitimate configuration */
|
||||
if (!isAdd) {
|
||||
if (command == VIR_NETWORK_UPDATE_COMMAND_DELETE) {
|
||||
for (j = 0; j < host.nnames && !foundThisTime; j++) {
|
||||
for (k = 0; k < dns->hosts[i].nnames && !foundThisTime; k++) {
|
||||
if (STREQ(host.names[j], dns->hosts[i].names[k]))
|
||||
@ -3224,6 +3224,13 @@ virNetworkDefUpdateDNSHost(virNetworkDef *def,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (foundCt > 1) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
_("multiple matching DNS HOST records were found in network %1$s"),
|
||||
def->name);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
virNetworkDNSHostDefClear(&dns->hosts[foundIdxModify]);
|
||||
|
||||
memcpy(&dns->hosts[foundIdxModify], &host, sizeof(virNetworkDNSHostDef));
|
||||
|
Loading…
Reference in New Issue
Block a user