[PATCH 1/2] leaseshelper: Skip entries missing expiry time on INIT action

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

 



Coverity pointed out that on other places we always check the return
value from virJSONValueObjectGetNumberLong() but not in the new addition
in leaseshelper. To solve the issue and also be more robust in case
somebody would corrupt the file, skip outputing of the lease entry in
case the expiry time is missing.
---
 src/network/leaseshelper.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c
index 96a1de2..9628cee 100644
--- a/src/network/leaseshelper.c
+++ b/src/network/leaseshelper.c
@@ -397,7 +397,10 @@ main(int argc, char **argv)
                 goto cleanup;
             }
             if (!strchr(ip_tmp, ':')) {
-                virJSONValueObjectGetNumberLong(lease_tmp, "expiry-time", &expirytime);
+                if (virJSONValueObjectGetNumberLong(lease_tmp, "expiry-time",
+                                                    &expirytime) < 0)
+                    continue;
+
                 printf("%lld %s %s %s %s\n",
                        expirytime,
                        virJSONValueObjectGetString(lease_tmp, "mac-address"),
@@ -418,7 +421,10 @@ main(int argc, char **argv)
                     goto cleanup;
                 }
                 if (strchr(ip_tmp, ':')) {
-                    virJSONValueObjectGetNumberLong(lease_tmp, "expiry-time", &expirytime);
+                    if (virJSONValueObjectGetNumberLong(lease_tmp, "expiry-time",
+                                                        &expirytime) < 0)
+                        continue;
+
                     printf("%lld %s %s %s %s\n",
                            expirytime,
                            virJSONValueObjectGetString(lease_tmp, "iaid"),
-- 
2.1.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]