Skip to content

Commit 5e14b69

Browse files
committed
- Fix expired zones to give SERVFAIL, also when parent zone loaded.
git-svn-id: file:///svn/nsd/trunk@4189 a26ef69c-88ff-0310-839f-98b793d9c207
1 parent 05b39d0 commit 5e14b69

File tree

7 files changed

+24
-10
lines changed

7 files changed

+24
-10
lines changed

axfr.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ query_axfr(struct nsd *nsd, struct query *query)
5151
&closest_encloser);
5252

5353
qdomain = closest_encloser;
54-
query->axfr_zone = domain_find_zone(closest_encloser);
54+
query->axfr_zone = domain_find_zone(nsd->db, closest_encloser);
5555

5656
if (!exact
5757
|| query->axfr_zone == NULL
58-
|| query->axfr_zone->apex != qdomain)
58+
|| query->axfr_zone->apex != qdomain
59+
|| query->axfr_zone->soa_rrset == NULL)
5960
{
6061
/* No SOA no transfer */
6162
RCODE_SET(query->packet, RCODE_NOTAUTH);

difffile.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ check_for_bad_serial(namedb_type* db, const char* zone_str, uint32_t old_serial)
11851185
zone_type* zone = 0;
11861186
domain = domain_table_find(db->domains, zone_name);
11871187
if(domain)
1188-
zone = domain_find_zone(domain);
1188+
zone = domain_find_zone(db, domain);
11891189
if(zone && zone->apex == domain && zone->soa_rrset && old_serial)
11901190
{
11911191
uint32_t memserial;

doc/ChangeLog

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
30 January 2014: Wouter
2+
- Fix expired zones to give SERVFAIL, also when parent zone loaded.
3+
14
27 January 2014: Wouter
25
- tag 4.0.1.
36
- trunk is 4.0.2 in development.

namedb.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -508,14 +508,17 @@ domain_find_any_rrset(domain_type* domain, zone_type* zone)
508508
}
509509

510510
zone_type *
511-
domain_find_zone(domain_type* domain)
511+
domain_find_zone(namedb_type* db, domain_type* domain)
512512
{
513513
rrset_type* rrset;
514514
while (domain) {
515-
for (rrset = domain->rrsets; rrset; rrset = rrset->next) {
516-
if (rrset_rrtype(rrset) == TYPE_SOA) {
517-
return rrset->zone;
515+
if(domain->is_apex) {
516+
for (rrset = domain->rrsets; rrset; rrset = rrset->next) {
517+
if (rrset_rrtype(rrset) == TYPE_SOA) {
518+
return rrset->zone;
519+
}
518520
}
521+
return namedb_find_zone(db, domain_dname(domain));
519522
}
520523
domain = domain->parent;
521524
}

namedb.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ typedef struct rr rr_type;
3232
typedef struct domain_table domain_table_type;
3333
typedef struct domain domain_type;
3434
typedef struct zone zone_type;
35+
typedef struct namedb namedb_type;
3536

3637
struct domain_table
3738
{
@@ -236,7 +237,7 @@ void domain_add_rrset(domain_type* domain, rrset_type* rrset);
236237
rrset_type* domain_find_rrset(domain_type* domain, zone_type* zone, uint16_t type);
237238
rrset_type* domain_find_any_rrset(domain_type* domain, zone_type* zone);
238239

239-
zone_type* domain_find_zone(domain_type* domain);
240+
zone_type* domain_find_zone(namedb_type* db, domain_type* domain);
240241
zone_type* domain_find_parent_zone(zone_type* zone);
241242

242243
domain_type* domain_find_ns_rrsets(domain_type* domain, zone_type* zone, rrset_type **ns);
@@ -281,7 +282,6 @@ static inline const char* domain_to_string(domain_type* domain)
281282
*/
282283
uint16_t rr_rrsig_type_covered(rr_type* rr);
283284

284-
typedef struct namedb namedb_type;
285285
struct namedb
286286
{
287287
region_type* region;

query.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -1137,12 +1137,19 @@ answer_lookup_zone(struct nsd *nsd, struct query *q, answer_type *answer,
11371137
size_t domain_number, int exact, domain_type *closest_match,
11381138
domain_type *closest_encloser, const dname_type *qname)
11391139
{
1140-
q->zone = domain_find_zone(closest_encloser);
1140+
q->zone = domain_find_zone(nsd->db, closest_encloser);
11411141
if (!q->zone) {
1142+
/* no zone for this */
11421143
if(q->cname_count == 0)
11431144
RCODE_SET(q->packet, RCODE_REFUSE);
11441145
return;
11451146
}
1147+
if(!q->zone->apex || !q->zone->soa_rrset) {
1148+
/* zone is configured but not loaded */
1149+
if(q->cname_count == 0)
1150+
RCODE_SET(q->packet, RCODE_SERVFAIL);
1151+
return;
1152+
}
11461153

11471154
/*
11481155
* See RFC 4035 (DNSSEC protocol) section 3.1.4.1 Responding

tpkg/zone_expire_parent.tpkg

1.61 KB
Binary file not shown.

0 commit comments

Comments
 (0)