[PATCH 2/4] rpc: Fix possible crash when MDNSAddEntry fails

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

 



If virNetServerMDNSAddEntry() fails when adding a service to a server,
it doesn't decrease the number of services.  Hence access to their
members segfaults (e.g. when free()-ing the sruct).

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/rpc/virnetserver.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 091a1dc0bc8f..2af878977a1b 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -974,8 +974,10 @@ int virNetServerAddService(virNetServerPtr srv,

         if (!virNetServerMDNSAddEntry(srv->mdnsGroup,
                                       mdnsEntryName,
-                                      port))
+                                      port)) {
+            srv->nservices--;
             goto error;
+        }
     }

     srv->services[srv->nservices-1] = svc;
-- 
2.4.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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]