From 535b45631ad7176e10dab89d55443b5a096500b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Thu, 17 Apr 2014 19:21:12 +0200 Subject: [PATCH] qtest: Be paranoid about accept() addrlen argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit POSIX specifies that address_len shall on output specify the length of the stored address; it does not however specify whether it may get updated on failure as well to, e.g., zero. In case EINTR occurs, re-initialize the variable to the desired value. Reviewed-by: Eric Blake Signed-off-by: Andreas Färber --- tests/libqtest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 4b90d9112a..71468ac9c7 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -89,8 +89,8 @@ static int socket_accept(int sock) setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (void *)&timeout, sizeof(timeout)); - addrlen = sizeof(addr); do { + addrlen = sizeof(addr); ret = accept(sock, (struct sockaddr *)&addr, &addrlen); } while (ret == -1 && errno == EINTR); if (ret == -1) {