Re: [PATCH 8/8] daemon: Resolve Coverity FORWARD_NULL

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

 



On Sat, Sep 13, 2014 at 09:27:45AM -0400, John Ferlan wrote:
Coverity complains that the comparison:

 if (nfds && nfds > ((int)!!sock_path + (int)!!sock_path_ro))

could mean 'sock_path' is NULL. Later in virNetSocketNewListenUNIX
there's a direct dereference of path in the error path:

 if (path[0] != '@')

A bit of sleuthing proves that upon entry to daemonSetupNetworking
there is no way for 'sock_path' to be NULL since daemonUnixSocketPaths
will set up 'sock_file' (although it may not set up 'sock_file_ro')
in all 3 paths.

So to keep Coverity quiet - add an sa_assert prior to the call.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
daemon/libvirtd.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 05ee50e..028145e 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -502,6 +502,7 @@ static int daemonSetupNetworking(virNetServerPtr srv,
            return -1;
    }

+    sa_assert(sock_path);
    if (nfds && nfds > ((int)!!sock_path + (int)!!sock_path_ro)) {

Well, if sock_path cannot be NULL, then why not change it to:

if (nfds > (1 + !!sock_path_ro)) {

or something like that?

Martin

        VIR_ERROR(_("Too many (%u) FDs passed from caller"), nfds);
        return -1;
--
1.9.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

Attachment: signature.asc
Description: Digital signature

--
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]