Skip to content

Commit

Permalink
Fix empty labels parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Mar 21, 2019
1 parent 4a943fa commit 192009c
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions rbldnsd_aclkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,26 +241,31 @@ int ds_aclkey_query(const struct dataset *ds, struct dnsqinfo *qi,
cur_lab += *cur_lab + 1;
}

key.ldn = cur_lab + 1;
key.len = *cur_lab;

k = kh_get(acl_key_hash, ds->ds_dsd->auth_keys, key);

if (k == kh_end(ds->ds_dsd->auth_keys)) {
if (*cur_lab == 0) {
rr = ds->ds_dsd->def_rr;
}
else {
struct acl_val *val = &kh_value(ds->ds_dsd->auth_keys, k);

rr = val->rr;
val->requests ++;

/* Also modify qi */
qi->qi_dnlab --;
qi->qi_dnlen0 -= key.len + 1;
add_flags |= NSQUERY_KEY;
/* Zero terminated when parsing */
qi->qi_additional = (void *)(kh_key(ds->ds_dsd->auth_keys, k).ldn);
key.ldn = cur_lab + 1;
key.len = *cur_lab;

k = kh_get(acl_key_hash, ds->ds_dsd->auth_keys, key);

if (k == kh_end(ds->ds_dsd->auth_keys)) {
rr = ds->ds_dsd->def_rr;
}
else {
struct acl_val *val = &kh_value(ds->ds_dsd->auth_keys, k);

rr = val->rr;
val->requests++;

/* Also modify qi */
qi->qi_dnlab--;
qi->qi_dnlen0 -= key.len + 1;
add_flags |= NSQUERY_KEY;
/* Zero terminated when parsing */
qi->qi_additional = (void *) (kh_key(ds->ds_dsd->auth_keys, k).ldn);
}
}
}

Expand All @@ -270,6 +275,7 @@ int ds_aclkey_query(const struct dataset *ds, struct dnsqinfo *qi,
case RR_REFUSE: return add_flags|NSQUERY_REFUSE;
case RR_EMPTY: return add_flags|NSQUERY_EMPTY;
case RR_PASS: return add_flags;
default: break; /* Passthrough */
}

/* Substitute zone value and handle it further in check_query_overwrites */
Expand Down

0 comments on commit 192009c

Please sign in to comment.