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

Martin Kletzander mkletzan at redhat.com
Mon Sep 15 08:36:47 UTC 2014


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 at redhat.com>
>---
> 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 at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140915/2e3d5d1b/attachment-0001.sig>


More information about the libvir-list mailing list