Commit Diff
Diff:
f60513d62db728d489741251fcfb902e3c4624b4
579f6873c39e47bf96113ec9b04ce20996915631
Commit:
579f6873c39e47bf96113ec9b04ce20996915631
Tree:
9a18c3b3343f5ac4b6230141b83113e675f5be47
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Fri Jul 3 09:04:07 2020 UTC
Message:
usually when we get a TCP packet and read the first 2 bytes of it, as in, a DNS TCP packet leads with the length of the packet then the rest is supposed to follow and shouldn't have errors in a perfect setting. But check the return status anyhow. Another commit will take care of timeouts...
blob - 2baaf14567800ff6aa96ab9e6c9fc40a65892d32
blob + 5544c5bb0b4ef35b85eccf64ea476ab863fa0727
--- forward.c
+++ forward.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: forward.c,v 1.4 2020/07/03 06:49:57 pjp Exp $
+ * $Id: forward.c,v 1.5 2020/07/03 09:04:07 pjp Exp $
*/
#include <sys/types.h>
@@ -246,17 +246,20 @@ forwardloop(ddDB *db, struct cfg *cfg, struct imsgbuf
if (FD_ISSET(fwq1->so, &rset)) {
if (fwq1->istcp) {
len = recv(fwq1->so, buf, 2, MSG_WAITALL);
- if (len < 0) {
+ if (len <= 0)
goto drop;
- }
+
need = ntohs(unpack16(buf));
len = recv(fwq1->so, buf, need, MSG_WAITALL);
+ if (len <= 0)
+ goto drop;
+
returnit(cfg, fwq1, buf, len);
} else {
len = recv(fwq1->so, buf, 0xffff, 0);
- if (len < 0) {
+ if (len < 0)
goto drop;
- }
+
returnit(cfg, fwq1, buf, len);
}
repomaster@centroid.eu