summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorAlexey Izbyshev <izbyshev@ispras.ru>2023-02-24 23:48:55 +0300
committerRich Felker <dalias@aerifal.cx>2023-02-27 10:03:34 -0500
commitbec42ef393c0ad64e699a901ab0746d16bfde251 (patch)
treed1eb9b19c3b43167c3b835ec1b2140cf0c03f265 /src/network
parent9b132e556774c744f9052581d2d8d0fab417e97c (diff)
downloadmusl-bec42ef393c0ad64e699a901ab0746d16bfde251.tar.gz
dns: handle early eof in tcp fallback
A zero returned from recvmsg is currently treated as if some data were received, so if a DNS server closes its TCP socket before sending the full answer, __res_msend_rc will spin until the timeout elapses because POLLIN event will be reported on each poll. Fix this by treating an early EOF as an error.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/res_msend.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/network/res_msend.c b/src/network/res_msend.c
index fef7e3a2..2643be22 100644
--- a/src/network/res_msend.c
+++ b/src/network/res_msend.c
@@ -287,7 +287,7 @@ int __res_msend_rc(int nqueries, const unsigned char *const *queries,
};
step_mh(&mh, apos[i]);
r = recvmsg(pfd[i].fd, &mh, 0);
- if (r < 0) goto out;
+ if (r <= 0) goto out;
apos[i] += r;
if (apos[i] < 2) continue;
int alen = alen_buf[i][0]*256 + alen_buf[i][1];