Skip to content

Commit

Permalink
qtest: Be paranoid about accept() addrlen argument
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Andreas Färber <[email protected]>
  • Loading branch information
afaerber committed May 5, 2014
1 parent a7d915f commit 535b456
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/libqtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 535b456

Please sign in to comment.