From fd3edf09a665836c243c0f8a195a244aebbffbc5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Tue, 24 Oct 2017 11:36:21 +0200 Subject: [PATCH] skip zero-containing names --- lib/cache.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/cache.c b/lib/cache.c index eb1c75284..81f4785d4 100644 --- a/lib/cache.c +++ b/lib/cache.c @@ -534,8 +534,16 @@ int pkt_append(knot_pkt_t *pkt, const struct answer_rrset *rrset, uint8_t rank) - - +/** Check that no label contains a zero character. + * + * We refuse to work with those, as LF and our cache keys might become ambiguous. + * Assuming uncompressed name, as usual. + * CACHE_KEY_DEF + */ +static bool check_dname_for_lf(const knot_dname_t *n) +{ + return knot_dname_size(n) == strlen((const char *)n) + 1; +} /** TODO */ @@ -612,6 +620,9 @@ int cache_lmdb_peek(kr_layer_t *ctx, knot_pkt_t *pkt) struct key k_storage, *k = &k_storage; + if (!check_dname_for_lf(qry->sname)) { + return ctx->state; + } int ret = kr_dname_lf(k->buf, qry->sname, NULL); if (ret) { return KR_STATE_FAIL; @@ -971,6 +982,13 @@ static int stash_rrset(const ranked_rr_array_t *arr, int arr_i, uint32_t min_ttl assert(false); return KR_STATE_FAIL; } + if (!check_dname_for_lf(rr->owner)) { + WITH_VERBOSE { + VERBOSE_MSG(qry, "=> skipping zero-containing name "); + kr_dname_print(rr->owner, "", "\n"); + } + return kr_ok(); + } WITH_VERBOSE { -- 2.47.2