Skip to content
Snippets Groups Projects
Verified Commit 08419bec authored by Petr Špaček's avatar Petr Špaček
Browse files

gc: fix kr_gc_key_consistent to work with root zone NSECs

parent 6a80c70e
No related branches found
No related tags found
1 merge request!817cache garbage collector
......@@ -77,11 +77,19 @@ const uint16_t *kr_gc_key_consistent(knot_db_val_t key)
{
const static uint16_t NSEC1 = KNOT_RRTYPE_NSEC;
const static uint16_t NSEC3 = KNOT_RRTYPE_NSEC3;
// find the first double zero in the key; CACHE_KEY_DEF
const uint8_t *kd = key.data;
ssize_t i;
for (i = 2; !(kd[i - 1] == 0 && kd[i - 2] == 0); ++i) {
if (i >= key.len) return NULL;
/* CACHE_KEY_DEF */
if (key.len >= 2 && kd[0] == '\0') {
/* Beware: root zone is special and starts with
* a single \0 followed by type sign */
i = 1;
} else {
/* find the first double zero in the key */
for (i = 2; !kd[i - 1] == 0 || !kd[i - 2] == 0; ++i) {
if (i >= key.len)
return NULL;
}
}
// the next character can be used for classification
switch (kd[i]) {
......
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