[libvirt] [PATCH 4/4] tests: Avoid possible error in testExecRestart

Peter Krempa pkrempa at redhat.com
Tue Jul 23 14:07:12 UTC 2019


On Tue, Jul 23, 2019 at 09:58:11 -0400, John Ferlan wrote:
> If the dup2 fails, then we aren't going to get the correct result.
> 
> Found by Coverity
> 
> Signed-off-by: John Ferlan <jferlan at redhat.com>
> ---
>  tests/virnetdaemontest.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/virnetdaemontest.c b/tests/virnetdaemontest.c
> index eae630a8f1..d0e9f241e3 100644
> --- a/tests/virnetdaemontest.c
> +++ b/tests/virnetdaemontest.c
> @@ -287,10 +287,11 @@ static int testExecRestart(const void *opaque)
>       * fds 100->103 for something else, which is probably
>       * fairly reasonable in general
>       */
> -    dup2(fdserver[0], 100);
> -    dup2(fdserver[1], 101);
> -    dup2(fdclient[0], 102);
> -    dup2(fdclient[1], 103);
> +    if (dup2(fdserver[0], 100) < 0 ||
> +        dup2(fdserver[1], 101) < 0 ||
> +        dup2(fdclient[0], 102) < 0 ||
> +        dup2(fdclient[1], 103) < 0)
> +        goto cleanup;

This will not print any debug message if we hit this.

>  
>      if (virAsprintf(&infile, "%s/virnetdaemondata/input-data-%s.json",
>                      abs_srcdir, data->jsonfile) < 0)
> -- 
> 2.20.1
> 
> --
> 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: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190723/55cb8bfb/attachment-0001.sig>


More information about the libvir-list mailing list