mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-25 07:07:52 +01:00
Fix: check r < 0 before checking errno
Signed-off-by: David Goulet <dgoulet@ev0ke.net>
This commit is contained in:
parent
51f793e37e
commit
2c41f12048
1 changed files with 2 additions and 2 deletions
|
@ -174,7 +174,7 @@ pipe_drain(int fd)
|
|||
do {
|
||||
r = read_ni(fd, buf, sizeof(buf));
|
||||
} while (r > 0);
|
||||
if (errno != EAGAIN)
|
||||
if (r < 0 && errno != EAGAIN)
|
||||
return -1;
|
||||
/* A value of r = 0 means EOF on the fd so successfully drained. */
|
||||
return 0;
|
||||
|
@ -198,7 +198,7 @@ sock_drain(tor_socket_t fd)
|
|||
do {
|
||||
r = recv_ni(fd, buf, sizeof(buf), 0);
|
||||
} while (r > 0);
|
||||
if (!ERRNO_IS_EAGAIN(tor_socket_errno(fd)))
|
||||
if (r < 0 && !ERRNO_IS_EAGAIN(tor_socket_errno(fd)))
|
||||
return -1;
|
||||
/* A value of r = 0 means EOF on the fd so successfully drained. */
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue