Commit Diff
Diff:
391531e4684cbc10e11d96955caf42a27c31e138
b7d74d0818db8b5b6337e2e2c1be204097b7f494
Commit:
b7d74d0818db8b5b6337e2e2c1be204097b7f494
Tree:
8eda303b5076aa2bdde8bef8e944205d10fe5dc2
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Tue Dec 10 12:44:10 2019 UTC
Message:
The repaired fcntl in delphinusdnsd.c which I even wrote would change behaviour caused fallout. When the descriptor gets passed to the AXFR engine, make sure that it is not NONBLOCK'ing. Just set it back, as answers became erroneous. This was tested on OpenBSD/amd64 and FreeBSD/arm RPI-B with drill and dig.
blob - 60ccf5144347f69a20141392a9aae3e3e3f57b6f
blob + 0e6bf57aaa6205a0abce2752ad8ab48bbc9c7f6d
--- axfr.c
+++ axfr.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: axfr.c,v 1.38 2019/12/09 18:14:24 pjp Exp $
+ * $Id: axfr.c,v 1.39 2019/12/10 12:44:10 pjp Exp $
*/
#include <sys/types.h>
@@ -43,6 +43,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <fcntl.h>
#include <syslog.h>
#include <errno.h>
#include <signal.h>
@@ -313,6 +314,7 @@ axfrloop(int *afd, int sockcount, char **ident, ddDB *
int is_ipv6, axfr_acl;
int notifyfd[2];
int packetlen;
+ int tcpflags;
socklen_t fromlen;
char buf[512];
@@ -557,6 +559,23 @@ axfrloop(int *afd, int sockcount, char **ident, ddDB *
memcpy(packet, imsg.data, packetlen);
so = imsg.fd;
+ if ((tcpflags = fcntl(so, F_GETFL, 0)) < 0) {
+ dolog(LOG_INFO, "can't query fcntl flags\n");
+ close(so);
+ free(packet);
+ break;
+ }
+
+ /* turn off nonblocking */
+ tcpflags &= ~O_NONBLOCK;
+
+ if (fcntl(so, F_SETFL, tcpflags) < 0) {
+ dolog(LOG_INFO, "can't turn off non-blocking\n");
+ close(so);
+ free(packet);
+ break;
+ }
+
memset((char *)&from, 0, sizeof(from));
fromlen = sizeof(struct sockaddr_storage);
if (getpeername(so, (struct sockaddr *)&from, &fromlen) < 0) {
repomaster@centroid.eu