Commit 4b883adc authored by Mark Andrews's avatar Mark Andrews

report non-empty sections on opcode tests

parent 6329cbe7
Pipeline #1248 passed with stages
in 1 minute and 22 seconds
......@@ -1439,6 +1439,9 @@ process(struct workitem *item, unsigned char *buf, int buflen) {
/* process message body */
cp = buf + 12;
eom = buf + buflen;
if (opts[item->test].opcode != 0 && qrcount != 0) {
addtag(item, "non-empty-question-section"), ok = 0;
} else {
for (i = 0; i < qrcount; i++) {
n = dn_expand(buf, eom, cp, name, sizeof(name));
if (n < 0 || (eom - cp) < n)
......@@ -1476,7 +1479,8 @@ process(struct workitem *item, unsigned char *buf, int buflen) {
return;
}
if ((item->type == ns_t_a || item->type == ns_t_aaaa) &&
if ((item->type == ns_t_a ||
item->type == ns_t_aaaa) &&
(strcasecmp(item->summary->ns, name) != 0 ||
type != item->type)) {
if (item->tcpfd != -1) {
......@@ -1527,6 +1531,7 @@ process(struct workitem *item, unsigned char *buf, int buflen) {
rcode == ns_r_nxdomain && ancount == 0)
item->summary->nxdomain = 1;
}
}
if (tc && item->tcpfd == -1 &&
(item->summary->type || !opts[item->test].ignore)) {
......@@ -1536,6 +1541,9 @@ process(struct workitem *item, unsigned char *buf, int buflen) {
return;
}
if (opts[item->test].opcode != 0 && ancount != 0) {
addtag(item, "non-empty-answer-section"), ok = 0;
} else {
for (i = 0; i < ancount; i++) {
n = dn_expand(buf, eom, cp, name, sizeof(name));
if (n < 0 || (eom - cp) < n)
......@@ -1554,7 +1562,8 @@ process(struct workitem *item, unsigned char *buf, int buflen) {
if ((eom - cp) < rdlen)
goto err;
/* Don't follow CNAME for A and AAAA lookups. */
if ((item->type == ns_t_a || item->type == ns_t_aaaa) &&
if ((item->type == ns_t_a ||
item->type == ns_t_aaaa) &&
type == ns_t_cname &&
strcasecmp(item->summary->ns, name) == 0) {
if (item->type == ns_t_a)
......@@ -1572,9 +1581,10 @@ process(struct workitem *item, unsigned char *buf, int buflen) {
{
if (rdlen != 4)
goto err;
inet_ntop(AF_INET, cp, addrbuf, sizeof(addrbuf));
check(item->summary->zone, item->summary->ns, addrbuf,
item->summary);
inet_ntop(AF_INET, cp,
addrbuf, sizeof(addrbuf));
check(item->summary->zone, item->summary->ns,
addrbuf, item->summary);
item->summary->done = 1;
}
if (item->type == ns_t_aaaa && type == ns_t_aaaa &&
......@@ -1582,9 +1592,10 @@ process(struct workitem *item, unsigned char *buf, int buflen) {
{
if (rdlen != 16)
goto err;
inet_ntop(AF_INET6, cp, addrbuf, sizeof(addrbuf));
check(item->summary->zone, item->summary->ns, addrbuf,
item->summary);
inet_ntop(AF_INET6, cp,
addrbuf, sizeof(addrbuf));
check(item->summary->zone, item->summary->ns,
addrbuf, item->summary);
item->summary->done = 1;
}
if (item->type == ns_t_ns && type == ns_t_ns &&
......@@ -1596,13 +1607,14 @@ process(struct workitem *item, unsigned char *buf, int buflen) {
goto err;
item->summary->done = 1;
/*
* Cross link A/AAAA lookups so that we can generate
* a single NXDOMAIN / no address report.
* Cross link A/AAAA lookups so that we can
* generate a single NXDOMAIN / no address
* report.
*/
summarya = lookupa(item->summary->zone, ns,
item->summary);
summaryaaaa = lookupaaaa(item->summary->zone, ns,
item->summary);
summaryaaaa = lookupaaaa(item->summary->zone,
ns, item->summary);
if (summarya && summaryaaaa) {
summarya->xlink = summaryaaaa;
summaryaaaa->xlink = summarya;
......@@ -1625,7 +1637,11 @@ process(struct workitem *item, unsigned char *buf, int buflen) {
printf("AN: %s./%u/%u/%u/%u\n",
name, type, class, ttl, rdlen);
}
}
if (opts[item->test].opcode != 0 && aucount != 0) {
addtag(item, "non-empty-authority-section"), ok = 0;
} else {
for (i = 0; i < aucount; i++) {
n = dn_expand(buf, eom, cp, name, sizeof(name));
if (n < 0 || (eom - cp) < n)
......@@ -1648,7 +1664,11 @@ process(struct workitem *item, unsigned char *buf, int buflen) {
printf("AU: %s./%u/%u/%u/%u\n",
name, type, class, ttl, rdlen);
}
}
if (opts[item->test].opcode != 0 && adcount != 0) {
addtag(item, "non-empty-authority-section"), ok = 0;
} else {
for (i = 0; i < adcount; i++) {
n = dn_expand(buf, eom, cp, name, sizeof(name));
if (n < 0 || (eom - cp) < n)
......@@ -1685,7 +1705,8 @@ process(struct workitem *item, unsigned char *buf, int buflen) {
if (code == 9 && optlen == 4)
seenexpire = 1;
/* Server Cookie. */
if (code == 10 && optlen >= 16 && optlen <= 40)
if (code == 10 &&
optlen >= 16 && optlen <= 40)
seencookie = 1;
if (code == 100)
seenecho = 1;
......@@ -1700,6 +1721,7 @@ process(struct workitem *item, unsigned char *buf, int buflen) {
printf("AD: %s./%u/%u/%u/%u\n",
name, type, class, ttl, rdlen);
}
}
if (cp != eom)
goto err;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment