]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
kr_ranked_rrarray_add: relax assertion
authorVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 2 Jan 2018 19:01:21 +0000 (20:01 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 2 Jan 2018 19:02:01 +0000 (20:02 +0100)
... after my changes to fetch_glue.  It really seems safe.

lib/utils.c

index 614984927d6d24bd962dd41dab9bc98f1053bdf2..31771b8bf0220ac8e2c57c166c4bea064da46897 100644 (file)
@@ -542,13 +542,16 @@ int kr_ranked_rrarray_add(ranked_rr_array_t *array, const knot_rrset_t *rr,
                        continue;
                }
                /* Found the entry to merge with.  Check consistency and merge. */
-               bool ok = stashed->rank == rank
-                       && !stashed->cached
-                       && stashed->to_wire == to_wire;
+               bool ok = stashed->rank == rank && !stashed->cached;
                if (!ok) {
                        assert(false);
                        return kr_error(EEXIST);
                }
+               /* It may happen that an RRset is first considered useful
+                * (to_wire = false, e.g. due to being part of glue),
+                * and later we may find we also want it in the answer. */
+               stashed->to_wire = stashed->to_wire || to_wire;
+
                return knot_rdataset_merge(&stashed->rr->rrs, &rr->rrs, pool);
        }