]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/rules: fixup combining of kr_rule_local_unblock() docs-jezek-bugfix-myhn26/deployments/7885 jezek-bugfix
authorVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 3 Nov 2025 11:53:02 +0000 (12:53 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 3 Nov 2025 17:13:32 +0000 (18:13 +0100)
When the same name got unblocked multiple times,
we'd add it with a wrong tag-set
(and forgot to delete the original, but that's just optimization really).

lib/rules/api.c

index 1701733b07bf2bacabb3dc1e6b34e6653ca148b6..a20916d94cac31ae3e010a50418a14b09ab61f2c 100644 (file)
@@ -1144,8 +1144,12 @@ int kr_rule_local_unblock(const knot_dname_t *apex, kr_rule_tags_t tags)
                if (kr_fails_assert(val.len == val_len))
                        return kr_error(EINVAL);
                kr_rule_tags_t tags_old;
-               memcpy(&tags_old, val.data, sizeof(tags_old));
+               uint8_t *data = val.data + sizeof(ztype);
+               memcpy(&tags_old, data, sizeof(tags_old));
                tags = kr_rule_tags_combine(tags, tags_old);
+               // ATM ruledb does not overwrite, so we `remove` before `write`.
+               ret = ruledb_op(remove, &key, 1);
+               kr_assert(ret == 1);
        }
 
        // Construct the data to write