Commit Diff
Diff:
7ea8ecf1b32ff8733e5746267330210a5d8fc794
ab101f1fd2fc16c8666855329e26c97149f46e58
Commit:
ab101f1fd2fc16c8666855329e26c97149f46e58
Tree:
fdbef0549067a6fdd44e512615070ea00a8002ea
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Fri Jul 3 17:14:03 2020 UTC
Message:
edns0 size can never be more than MAX_IMSGSIZE, due to limitations with the imsg framework, which we like to channel packets with. replace a few magic numbers with defines
blob - 17acc8e6f2a844669ee582f144097a2499781b5a
blob + 9faaf07fd88ac4f7b734638628f2e9e7fa589c4e
--- forward.c
+++ forward.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: forward.c,v 1.7 2020/07/03 16:16:27 pjp Exp $
+ * $Id: forward.c,v 1.8 2020/07/03 17:14:03 pjp Exp $
*/
#include <sys/types.h>
@@ -591,6 +591,8 @@ sendit(struct forwardqueue *fwq, struct sforward *sfor
}
q->edns0len = sforward->edns0len;
+ if (q->edns0len > (MAX_IMSGSIZE - FWDPQHEADER))
+ q->edns0len = (MAX_IMSGSIZE - FWDPQHEADER);
if (fwq->istcp == 1) {
p = &buf[2];
@@ -1323,21 +1325,15 @@ fwdparseloop(struct imsgbuf *ibuf)
exit(1);
}
#endif
- fwdpq = (struct fwdpq *)calloc(1, 65535);
+
+
+ fwdpq = (struct fwdpq *)calloc(1, MAX_IMSGSIZE);
if (fwdpq == NULL) {
dolog(LOG_INFO, "calloc: %s\n", strerror(errno));
ddd_shutdown();
exit(1);
}
-#if 0
- packet = calloc(1, 16384);
- if (packet == NULL) {
- dolog(LOG_ERR, "calloc: %m");
- ddd_shutdown();
- exit(1);
- }
-#endif
packet = &fwdpq->buf[0];
for (;;) {
@@ -1370,7 +1366,7 @@ fwdparseloop(struct imsgbuf *ibuf)
case IMSG_PARSE_MESSAGE:
/* XXX magic numbers */
- if (datalen > 16384) {
+ if (datalen > MAX_IMSGSIZE) {
fwdpq->rc = PARSE_RETURN_NAK;
imsg_compose(ibuf, IMSG_PARSEREPLY_MESSAGE, 0, 0, -1, fwdpq, sizeof(struct fwdpq));
msgbuf_write(&ibuf->w);
repomaster@centroid.eu