From 3be8c1f0028a0e2c5b646a4ea7cf600512eab9ab Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 3 Dec 2014 18:24:38 +0100 Subject: [PATCH] leaseshelper: Skip entries missing expiry time on INIT action 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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c index 96a1de215a..9628cee801 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"), -- GitLab