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

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

 



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@xxxxxxxxxx>
> ---
>  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@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list

Attachment: signature.asc
Description: PGP 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]

  Powered by Linux