[PATCH] virNetServerNewPostExecRestart: Initialize @max_anonymous_clients

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

 



Coverity spotted a use of possibly undefined variable. If a server is
restarting as an result of update, the JSON file that keeps current
value of some variables will not contain the new variables. This is
the case of @max_anonymous_clients too. We are correctly querying if
there's "max_anonymous_clients" in the JSON, however, we are not
setting a sane default if there's none.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/rpc/virnetserver.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index dfa3565..33a0346 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -494,12 +494,15 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
                        _("Missing max_clients data in JSON document"));
         goto error;
     }
-    if (virJSONValueObjectHasKey(object, "max_anonymous_clients") &&
-        virJSONValueObjectGetNumberUint(object, "max_anonymous_clients",
-                                        &max_anonymous_clients) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Malformed max_anonymous_clients data in JSON document"));
-        goto error;
+    if (virJSONValueObjectHasKey(object, "max_anonymous_clients")) {
+        if (virJSONValueObjectGetNumberUint(object, "max_anonymous_clients",
+                                            &max_anonymous_clients) < 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("Malformed max_anonymous_clients data in JSON document"));
+            goto error;
+        }
+    } else {
+        max_anonymous_clients = max_clients;
     }
     if (virJSONValueObjectGetNumberUint(object, "keepaliveInterval", &keepaliveInterval) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-- 
1.9.0

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