diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-03-08 11:17:27 +0000 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-03-08 13:21:58 +0000 |
commit | 618954a6b0adc3e0eacda799b88f020c801a0106 (patch) | |
tree | 214a639b1b6e5ee2dfe221c41c4dbb148411e776 /examples | |
parent | 35d5be22b1c09c3a99b445f65453601ec25b9f60 (diff) | |
download | libguestfs-618954a6b0adc3e0eacda799b88f020c801a0106.tar.gz libguestfs-618954a6b0adc3e0eacda799b88f020c801a0106.tar.xz libguestfs-618954a6b0adc3e0eacda799b88f020c801a0106.zip |
Check return values of guestfs_inspect_get_{type,distro} (found by Coverity).
Error: NULL_RETURNS:
/builddir/build/BUILD/libguestfs-1.16.5/examples/virt-dhcp-address.c:129: var_assigned: Assigning: "guest_distro" = null return value from "guestfs_inspect_get_distro".
/builddir/build/BUILD/libguestfs-1.16.5/examples/virt-dhcp-address.c:131: dereference: Dereferencing a pointer that might be null "guest_distro" when calling "__coverity_strcmp".
[...]
/builddir/build/BUILD/libguestfs-1.16.5/examples/virt-dhcp-address.c:126: var_assigned: Assigning: "guest_type" = null return value from "guestfs_inspect_get_type".
/builddir/build/BUILD/libguestfs-1.16.5/examples/virt-dhcp-address.c:128: dereference: Dereferencing a pointer that might be null "guest_type" when calling "__coverity_strcmp".
Diffstat (limited to 'examples')
-rw-r--r-- | examples/virt-dhcp-address.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/examples/virt-dhcp-address.c b/examples/virt-dhcp-address.c index 5b68313a..3534f0bc 100644 --- a/examples/virt-dhcp-address.c +++ b/examples/virt-dhcp-address.c @@ -124,9 +124,13 @@ print_dhcp_address (guestfs_h *g, char *root) /* Depending on the guest type, try to get the DHCP address. */ guest_type = guestfs_inspect_get_type (g, root); + if (guest_type == NULL) + exit (EXIT_FAILURE); if (strcmp (guest_type, "linux") == 0) { guest_distro = guestfs_inspect_get_distro (g, root); + if (guest_distro == NULL) + exit (EXIT_FAILURE); if (strcmp (guest_distro, "fedora") == 0 || strcmp (guest_distro, "rhel") == 0 || |