diff --git a/lib/generic/lru.h b/lib/generic/lru.h index d4125f7e8a1266575ab48e9f6a8c3a3a666a6666..1b38708aed867ce621806f6e8cdb6e6774ea3fef 100644 --- a/lib/generic/lru.h +++ b/lib/generic/lru.h @@ -110,6 +110,9 @@ struct { \ /** @internal Slot data getter */ static inline void *lru_slot_get(struct lru_hash_base *lru, const char *key, uint32_t len, size_t offset) { + if (!lru || !key || len == 0) { + return NULL; + } uint32_t id = hash(key, len) % lru->size; struct lru_slot *slot = (struct lru_slot *)(lru->slots + (id * lru->stride)); if (lru_slot_match(slot, key, len)) { @@ -121,6 +124,9 @@ static inline void *lru_slot_get(struct lru_hash_base *lru, const char *key, uin /** @internal Slot data setter */ static inline void *lru_slot_set(struct lru_hash_base *lru, const char *key, uint32_t len, size_t offset) { + if (!lru || !key || len == 0) { + return NULL; + } uint32_t id = hash(key, len) % lru->size; struct lru_slot *slot = (struct lru_slot *)(lru->slots + (id * lru->stride)); if (!lru_slot_match(slot, key, len)) { diff --git a/lib/zonecut.c b/lib/zonecut.c index 143336fef3162b35c0e992eaec04d422d404026c..d779b482d305bdf9fddb89372df13bedd4259496 100644 --- a/lib/zonecut.c +++ b/lib/zonecut.c @@ -253,8 +253,10 @@ int kr_zonecut_find_cached(struct kr_context *ctx, struct kr_zonecut *cut, const } /* Start at QNAME parent. */ - name = knot_wire_next_label(name, NULL); - while (txn && name) { + if (name[0] != '\0') { + name = knot_wire_next_label(name, NULL); + } + while (txn) { if (fetch_ns(ctx, cut, name, txn, timestamp) == 0) { update_cut_name(cut, name); return kr_ok();