summaryrefslogtreecommitdiff
path: root/dns/dnrd
diff options
context:
space:
mode:
authorEdwin Groothuis <edwin@FreeBSD.org>2004-01-03 05:42:42 +0000
committerEdwin Groothuis <edwin@FreeBSD.org>2004-01-03 05:42:42 +0000
commitc90d26d28be378f475403b46a97ec57b659c35a4 (patch)
treeb0d3520716f948f20bfa41ae842b6ac6def52125 /dns/dnrd
parento Though this port does not support packaging, but fixed pkg-plist (diff)
dns/dnrd: recv_addr init wrong and 512 byte udp packets dropped
There are a few bugs in dnrd that should probably be fixed by the author but could be made to work on bsd: 1. Initialization in common.h of recv_addr is broken, causing at least the '-a' switch not to work. Instead of assuming positions of fields in the struct across platforms I thought it safer to do a standard initialization in main(). 2. The buffer overflow code in udp.c:dnsrecv() is off by one, rejecting messages where the size exactly fills the available buffer. I also changed to the calls to dnsrecv to pass 512 as the max size instead of the buffers that seem to be padded by 4 bytes for a reason I don't understand. This causes a calling named to resend packets. Eventually one seems to get through but response times can be painfully slow. PR: ports/41128 Submitted by: Michael C. Adler <mad1@tapil.com>
Notes
Notes: svn path=/head/; revision=97158
Diffstat (limited to 'dns/dnrd')
-rw-r--r--dns/dnrd/Makefile11
-rw-r--r--dns/dnrd/files/patch-main.c19
-rw-r--r--dns/dnrd/files/patch-udp.c29
3 files changed, 51 insertions, 8 deletions
diff --git a/dns/dnrd/Makefile b/dns/dnrd/Makefile
index fae1faf62c38..2080ced9f402 100644
--- a/dns/dnrd/Makefile
+++ b/dns/dnrd/Makefile
@@ -7,6 +7,7 @@
PORTNAME= dnrd
PORTVERSION= 2.10
+PORTREVISION= 1
CATEGORIES= dns
MASTER_SITES= http://users.zoominternet.net/~garsh/dnrd/archive/ \
http://www.netsw.org/net/ip/infoservice/dns/dnrd/
@@ -17,15 +18,17 @@ COMMENT= A proxy DNS daemon
WRKSRC= ${WRKDIR}/${DISTNAME}/src
USE_GMAKE= yes
-USE_REINPLACE= yes
+USE_REINPLACE= yes
MAN8= dnrd.8
post-patch:
.for F in main.c master.c
- @(cd ${WRKSRC} && ${SED} -e 's,%%PREFIX%%,${PREFIX},g' $F > foo && \
- ${MV} foo $F)
+ ${REINPLACE_CMD} -e 's,%%PREFIX%%,${PREFIX},g' ${WRKSRC}/$F
.endfor
- ${REINPLACE_CMD} -e "s@cc@${CC}@g; s@-lc_r@${PTHREAD_LIBS}@g" ${WRKSRC}/Makefile
+ ${REINPLACE_CMD} \
+ -e "s,cc,${CC},g" \
+ -e "s,-lc_r,${PTHREAD_LIBS},g" \
+ ${WRKSRC}/Makefile
.include <bsd.port.mk>
diff --git a/dns/dnrd/files/patch-main.c b/dns/dnrd/files/patch-main.c
index 09f5612abf43..e5a2f673f3e5 100644
--- a/dns/dnrd/files/patch-main.c
+++ b/dns/dnrd/files/patch-main.c
@@ -1,5 +1,5 @@
---- main.c.orig Thu Jan 4 14:40:42 2001
-+++ main.c Sat Jan 6 15:06:31 2001
+--- main.c.orig Fri Jan 5 01:40:42 2001
++++ main.c Sat Jan 3 16:39:25 2004
@@ -18,6 +18,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
@@ -16,7 +16,18 @@
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/stat.h>
-@@ -170,20 +170,20 @@
+@@ -82,6 +82,10 @@
+ /*
+ * Parse the command line.
+ */
++ memset(&recv_addr, 0, sizeof(recv_addr));
++ recv_addr.sin_family = AF_INET;
++ recv_addr.sin_port = htons(53);
++
+ parse_args(argc, argv);
+
+ openlog(progname, LOG_PID, LOG_DAEMON);
+@@ -170,20 +174,20 @@
* Change our root and current working directories to /etc/dnrd.
* Also, so some sanity checking on that directory first.
*/
@@ -42,7 +53,7 @@
cleanexit(-1);
}
-@@ -198,31 +198,31 @@
+@@ -198,31 +202,31 @@
if (rslt) continue;
if (S_ISDIR(st.st_mode)) {
diff --git a/dns/dnrd/files/patch-udp.c b/dns/dnrd/files/patch-udp.c
new file mode 100644
index 000000000000..df1a41db4f30
--- /dev/null
+++ b/dns/dnrd/files/patch-udp.c
@@ -0,0 +1,29 @@
+--- udp.c.orig Sat Jan 3 16:39:53 2004
++++ udp.c Sat Jan 3 16:40:36 2004
+@@ -74,7 +74,7 @@
+
+ /* Read in the message */
+ addr_len = sizeof(struct sockaddr_in);
+- len = recvfrom(isock, msg, sizeof(msg), 0,
++ len = recvfrom(isock, msg, maxsize, 0,
+ (struct sockaddr *)&from_addr, &addr_len);
+ if (len < 0) {
+ log_debug("recvfrom error %s", strerror(errno));
+@@ -172,7 +172,7 @@
+ inet_ntoa(dns_srv[k].addr.sin_addr));
+ return (-1);
+ }
+- else if (rc == len) {
++ else if (rc > len) {
+ log_msg(LOG_NOTICE, "packet too large: %s",
+ inet_ntoa(dns_srv[k].addr.sin_addr));
+ return (0);
+@@ -202,7 +202,7 @@
+ struct sockaddr_in from_addr;
+ unsigned addr_len;
+
+- len = dnsrecv(srvidx, msg, sizeof(msg));
++ len = dnsrecv(srvidx, msg, maxsize);
+ if (opt_debug) {
+ char buf[80];
+ sprintf_cname(&msg[12], buf, 80);