[libvirt] [PATCH 0/2] leaseshelper: Coverity/whitespace fixes

Peter Krempa (2): leaseshelper: Skip entries missing expiry time on INIT action leaseshelper: Fix incorrect alignment of a switch case src/network/leaseshelper.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) -- 2.1.0

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

On 12/03/2014 10:29 AM, Peter Krempa wrote:
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
s/outputing/outputting/
case the expiry time is missing. --- src/network/leaseshelper.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 12/03/14 18:47, Eric Blake wrote:
On 12/03/2014 10:29 AM, Peter Krempa wrote:
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
s/outputing/outputting/
case the expiry time is missing. --- src/network/leaseshelper.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
ACK.
Thanks; I've fixed the typo (and s/on/in/ in first line) and pushed the patches. Peter

Introduced in ca6dbdd047d1ed691ccbae72556d85722a5f7a36 --- src/network/leaseshelper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c index 9628cee..2d528f7 100644 --- a/src/network/leaseshelper.c +++ b/src/network/leaseshelper.c @@ -235,7 +235,7 @@ main(int argc, char **argv) } switch ((enum virLeaseActionFlags) action) { - case VIR_LEASE_ACTION_ADD: + case VIR_LEASE_ACTION_ADD: case VIR_LEASE_ACTION_OLD: if (!mac) break; -- 2.1.0

On 12/03/2014 10:29 AM, Peter Krempa wrote:
Introduced in ca6dbdd047d1ed691ccbae72556d85722a5f7a36 --- src/network/leaseshelper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ACK; trivial.
diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c index 9628cee..2d528f7 100644 --- a/src/network/leaseshelper.c +++ b/src/network/leaseshelper.c @@ -235,7 +235,7 @@ main(int argc, char **argv) }
switch ((enum virLeaseActionFlags) action) { - case VIR_LEASE_ACTION_ADD: + case VIR_LEASE_ACTION_ADD: case VIR_LEASE_ACTION_OLD: if (!mac) break;
-- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Peter Krempa