network: NULL check for "modify" DNS-txt records

The "modify" command allowed to replace an existing record, now
checks for the NULL string in the new value and throw error if
found.

Resolves: https://gitlab.com/libvirt/libvirt/-/issues/655
Signed-off-by: Adam Julis <ajulis@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Adam Julis 2024-08-06 09:01:24 +02:00 committed by Michal Privoznik
parent 0caacf47d7
commit 959ecee474

View File

@ -3385,6 +3385,13 @@ virNetworkDefUpdateDNSTxt(virNetworkDef *def,
goto cleanup;
}
if (!txt.value) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("missing value of modifying DNS TXT record in network %1$s"),
def->name);
goto cleanup;
}
VIR_FREE(dns->txts[foundIdx].value);
dns->txts[foundIdx].value = g_steal_pointer(&txt.value);