src/conf/network_conf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
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>
---
src/conf/network_conf.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index c23b0e4400..5cf419acf1 100644
--- a/src/conf/network_conf.c
+++ b/src/conf/network_conf.c
@@ -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));
--
2.45.2
On 8/6/24 09:01, Adam Julis wrote: > 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> > --- > src/conf/network_conf.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) Reviewed-by: Michal Privoznik <mprivozn@redhat.com> Michal
© 2016 - 2024 Red Hat, Inc.