[PATCH] network: fix crashing "modify" option for hostname

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux