Commit Diff
Diff:
4df81add2610e6f790d8b6e3bee1a56060b6c894
51d4b969a71d3d1c3ecf5619b4e4b9f507e3b2a6
Commit:
51d4b969a71d3d1c3ecf5619b4e4b9f507e3b2a6
Tree:
561de9d046adbc13832d6be9006416705ff00828
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Fri Feb 15 18:47:43 2019 UTC
Message:
make sure we get the count for additional_rrsig() right, this should work now
blob - b95076ce3131f586d39f4987eb616e2f5ec8808d
blob + 237501d5a68744948a4d8435e07335702f327029
--- additional.c
+++ additional.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: additional.c,v 1.19 2019/02/15 15:11:34 pjp Exp $
+ * $Id: additional.c,v 1.20 2019/02/15 18:47:43 pjp Exp $
*/
#include "ddd-include.h"
@@ -410,9 +410,10 @@ additional_rrsig(char *name, int namelen, int inttype,
struct rrset *rrset = NULL;
struct rr *rrp = NULL;
int tmplen, rroffset;
+ int rrsig_count = 0;
if ((rrset = find_rr(rbt, DNS_TYPE_RRSIG)) == NULL)
- goto out;
+ return 0;
rroffset = offset;
@@ -432,10 +433,14 @@ additional_rrsig(char *name, int namelen, int inttype,
return 0;
}
+ rrsig_count = 0;
TAILQ_FOREACH(rrp, &rrset->rr_head, entries) {
if (inttype != ((struct rrsig *)rrp->rdata)->type_covered)
continue;
+ if (rrsig_count++ != count)
+ continue;
+
answer = (struct answer *)&reply[offset];
answer->type = htons(DNS_TYPE_RRSIG);
answer->class = htons(DNS_CLASS_IN);
@@ -463,11 +468,14 @@ additional_rrsig(char *name, int namelen, int inttype,
memcpy(&reply[offset], ((struct rrsig *)rrp->rdata)->signature, ((struct rrsig *)rrp->rdata)->signature_len);
offset += ((struct rrsig *)rrp->rdata)->signature_len;
+
+ break;
}
+ if (rrp == NULL)
+ return 0;
answer->rdlength = htons((offset - rroffset) + 18);
-out:
return (offset);
}
blob - 6b2f1786502797d5aabd6d584201785c202f784b
blob + 2d2e3e8c0b3481092b7b6631f6df7947834b2479
--- reply.c
+++ reply.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: reply.c,v 1.65 2019/02/15 15:11:34 pjp Exp $
+ * $Id: reply.c,v 1.66 2019/02/15 18:47:43 pjp Exp $
*/
#include "ddd-include.h"
@@ -1091,7 +1091,7 @@ reply_dnskey(struct sreply *sreply, ddDB *db)
char *reply = sreply->replybuf;
struct dns_header *odh;
u_int16_t outlen = 0;
- int a_count;
+ int dnskey_count;
struct answer {
char name[2];
@@ -1120,9 +1120,10 @@ reply_dnskey(struct sreply *sreply, ddDB *db)
int istcp = sreply->istcp;
int replysize = 512;
int retlen = -1;
+ int rrsig_count = 0;
u_int16_t rollback;
- if ((rrset = find_rr(rbt, DNS_TYPE_A)) == NULL)
+ if ((rrset = find_rr(rbt, DNS_TYPE_DNSKEY)) == NULL)
return -1;
if (istcp) {
@@ -1164,7 +1165,7 @@ reply_dnskey(struct sreply *sreply, ddDB *db)
answer = (struct answer *)(&reply[0] + sizeof(struct dns_header) +
q->hdr->namelen + 4);
- a_count = 0;
+ dnskey_count = 0;
TAILQ_FOREACH(rrp, &rrset->rr_head, entries) {
if ((outlen + sizeof(struct answer) +
@@ -1202,12 +1203,12 @@ reply_dnskey(struct sreply *sreply, ddDB *db)
outlen += ((struct dnskey *)rrp->rdata)->publickey_len;
- a_count++;
+ dnskey_count++;
/* set new offset for answer */
answer = (struct answer *)&reply[outlen];
}
- odh->answer = htons(a_count);
+ odh->answer = htons(dnskey_count);
/* Add RRSIG reply_dnskey */
if (dnssec && q->dnssecok) {
@@ -1217,10 +1218,15 @@ reply_dnskey(struct sreply *sreply, ddDB *db)
if ((rrset2 = find_rr(rbt, DNS_TYPE_RRSIG)) == NULL)
goto out;
+
+ rrsig_count = 0;
TAILQ_FOREACH(rrp, &rrset2->rr_head, entries) {
+ if (((struct rrsig *)rrp->rdata)->type_covered != DNS_TYPE_DNSKEY)
+ continue;
+
origlen = outlen;
- tmplen = additional_rrsig(q->hdr->name, q->hdr->namelen, DNS_TYPE_DNSKEY, rbt, reply, replysize, outlen, 0);
+ tmplen = additional_rrsig(q->hdr->name, q->hdr->namelen, DNS_TYPE_DNSKEY, rbt, reply, replysize, outlen, rrsig_count);
if (tmplen == 0) {
NTOHS(odh->query);
@@ -1235,8 +1241,9 @@ reply_dnskey(struct sreply *sreply, ddDB *db)
outlen = tmplen;
+ rrsig_count++;
if (outlen > origlen)
- odh->answer = htons(a_count + 1);
+ odh->answer = htons(dnskey_count + rrsig_count);
}
}
@@ -4988,27 +4995,22 @@ create_anyreply(struct sreply *sreply, char *reply, in
}
if ((rrset = find_rr(rbt, DNS_TYPE_RRSIG)) != NULL) {
-
+ int dnskey_count = 0;
+
rrsig_count = 0;
+ dnskey_count = 0;
TAILQ_FOREACH(rrp, &rrset->rr_head, entries) {
- rrsig_count++;
- if (((struct rrsig *)rrp->rdata)->type_covered == DNS_TYPE_DNSKEY) {
- tmplen = additional_rrsig(q->hdr->name, q->hdr->namelen,
- DNS_TYPE_DNSKEY, rbt, reply, rlen, offset, i);
+ tmplen = additional_rrsig(q->hdr->name, q->hdr->namelen,
+ ((struct rrsig *)rrp->rdata)->type_covered, rbt, reply, rlen, offset, ((struct rrsig *)rrp->rdata)->type_covered == DNS_TYPE_DNSKEY ? dnskey_count : 0);
- if (tmplen == 0)
- goto truncate;
+ if (tmplen == 0)
+ goto truncate;
- offset = tmplen;
- } else {
- tmplen = additional_rrsig(q->hdr->name, q->hdr->namelen,
- ((struct rrsig *)rrp->rdata)->type_covered, rbt, reply, rlen, offset, 0);
-
- if (tmplen == 0)
- goto truncate;
+ offset = tmplen;
+ if (((struct rrsig *)rrp->rdata)->type_covered == DNS_TYPE_DNSKEY)
+ dnskey_count++;
- offset = tmplen;
- }
+ rrsig_count++;
}
NTOHS(odh->answer);
@@ -5067,10 +5069,11 @@ create_anyreply(struct sreply *sreply, char *reply, in
dnskey_count++;
- NTOHS(odh->answer);
- odh->answer += 1;
- HTONS(odh->answer);
}
+
+ NTOHS(odh->answer);
+ odh->answer += dnskey_count;
+ HTONS(odh->answer);
}
if ((rrset = find_rr(rbt, DNS_TYPE_DS)) != NULL) {
ds_count = 0;
@@ -5465,6 +5468,7 @@ create_anyreply(struct sreply *sreply, char *reply, in
}
answer->rdlength = htons(&reply[offset] - answer->rdata);
+ mx_count++;
}
NTOHS(odh->answer);
repomaster@centroid.eu