Skip to content
Snippets Groups Projects
Commit 122e0638 authored by Jan Kadlec's avatar Jan Kadlec
Browse files

Fixes for root zone.

 - Left chop of root returns NULL
 - If the node inserted to zone is owned by root, no chain up to the origin
   is made.

Closes #1548
parent 3785d936
No related branches found
No related tags found
No related merge requests found
......@@ -741,6 +741,18 @@ int knot_dname_is_fqdn(const knot_dname_t *dname)
knot_dname_t *knot_dname_left_chop(const knot_dname_t *dname)
{
if (dname == NULL ||
/* Root domain. */
((knot_dname_label_count(dname) == 0) &&
(knot_dname_is_fqdn(dname)))) {
return NULL;
}
if (dname->label_count <= 1) {
/* Nothing to chop. */
return NULL;
}
knot_dname_t *parent = knot_dname_new();
if (parent == NULL) {
return NULL;
......@@ -763,6 +775,7 @@ knot_dname_t *knot_dname_left_chop(const knot_dname_t *dname)
}
memcpy(parent->name, &dname->name[dname->name[0] + 1], parent->size);
short first_label_length = dname->labels[1];
......
......@@ -1030,6 +1030,13 @@ int knot_zone_contents_add_node(knot_zone_contents_t *zone,
knot_dname_t *chopped =
knot_dname_left_chop(knot_node_owner(node));
if(chopped == NULL) {
/* Root domain and root domain only. */
assert(node->owner && node->owner->labels &&
node->owner->labels[0] == 0);
return KNOT_EOK;
}
if (knot_dname_compare(knot_node_owner(zone->apex), chopped) == 0) {
dbg_zone("Zone apex is the parent.\n");
knot_node_set_parent(node, zone->apex);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment