From: Paolo Bonzini <pbonzini@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: Laurent Vivier <lvivier@redhat.com>, Thomas Huth <thuth@redhat.com>
Subject: Re: [PATCH] tests/qtest/libqtest.c: Check for setsockopt() failure
Date: Tue, 3 Nov 2020 12:56:11 +0100 [thread overview]
Message-ID: <945d6166-317e-46cb-d7db-a39f28e31d49@redhat.com> (raw)
In-Reply-To: <20201103115112.19211-1-peter.maydell@linaro.org>
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
prev parent reply other threads:[~2020-11-03 11:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-03 11:51 [PATCH] tests/qtest/libqtest.c: Check for setsockopt() failure Peter Maydell
2020-11-03 11:56 ` Paolo Bonzini [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=945d6166-317e-46cb-d7db-a39f28e31d49@redhat.com \
--to=pbonzini@redhat.com \
--cc=lvivier@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).