qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] tests/qtest/libqtest.c: Check for setsockopt() failure


From: Paolo Bonzini
Subject: Re: [PATCH] tests/qtest/libqtest.c: Check for setsockopt() failure
Date: Tue, 3 Nov 2020 12:56:11 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1

On 03/11/20 12:51, Peter Maydell wrote:
> In socket_accept() we use setsockopt() to set SO_RCVTIMEO,
> but we don't check the return value for failure. Do so.
> 
> Fixes: Coverity CID 1432321
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  tests/qtest/libqtest.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
> index 99deff47efc..be0fb430ddd 100644
> --- a/tests/qtest/libqtest.c
> +++ b/tests/qtest/libqtest.c
> @@ -110,8 +110,13 @@ static int socket_accept(int sock)
>      struct timeval timeout = { .tv_sec = SOCKET_TIMEOUT,
>                                 .tv_usec = 0 };
>  
> -    setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (void *)&timeout,
> -               sizeof(timeout));
> +    if (qemu_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
> +                        (void *)&timeout, sizeof(timeout))) {
> +        fprintf(stderr, "%s failed to set SO_RCVTIMEO: %s\n",
> +                __func__, strerror(errno));
> +        close(sock);
> +        return -1;
> +    }
>  
>      do {
>          addrlen = sizeof(addr);
> 


Queued, thanks.

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]