From: Vladimír Čunát Date: Tue, 24 Oct 2017 09:36:21 +0000 (+0200) Subject: skip zero-containing names X-Git-Tag: v2.0.0~6^2~83 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd3edf09a665836c243c0f8a195a244aebbffbc5;p=thirdparty%2Fknot-resolver.git skip zero-containing names --- 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 {