qtest: Be paranoid about accept() addrlen argument
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 <eblake@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
This commit is contained in:
parent
a7d915f388
commit
535b45631a
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user