]> xenbits.xensource.com Git - libvirt.git/commitdiff
leaseshelper: Skip entries missing expiry time on INIT action
authorPeter Krempa <pkrempa@redhat.com>
Wed, 3 Dec 2014 17:24:38 +0000 (18:24 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 3 Dec 2014 17:47:09 +0000 (18:47 +0100)
Coverity pointed out that in 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 outputting of the lease entry in
case the expiry time is missing.

src/network/leaseshelper.c

index 96a1de215a1b8a934f10afc2df8d91e2bacd610a..9628cee801528afb4d7cc3302e08ddbd934bbf16 100644 (file)
@@ -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"),