summaryrefslogtreecommitdiffstats
path: root/tests/qtest
diff options
context:
space:
mode:
authorPeter Maydell2020-11-03 12:51:12 +0100
committerPaolo Bonzini2020-11-03 15:42:53 +0100
commit1d72d9c4874f61c38df9a473e2fd4de869ba0b11 (patch)
tree2d3f4309409f69ac784a22643a6f5af0dd5dab4b /tests/qtest
parentmeson: vhost-user-gpu/virtiofsd: use absolute path (diff)
downloadqemu-1d72d9c4874f61c38df9a473e2fd4de869ba0b11.tar.gz
qemu-1d72d9c4874f61c38df9a473e2fd4de869ba0b11.tar.xz
qemu-1d72d9c4874f61c38df9a473e2fd4de869ba0b11.zip
tests/qtest/libqtest.c: Check for setsockopt() failure
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> Message-Id: <20201103115112.19211-1-peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tests/qtest')
-rw-r--r--tests/qtest/libqtest.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index 99deff47ef..be0fb430dd 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);