]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
zone: add missing checks for empty zone to flush
authorDaniel Salzman <daniel.salzman@nic.cz>
Wed, 3 Dec 2025 14:19:10 +0000 (15:19 +0100)
committerDaniel Salzman <daniel.salzman@nic.cz>
Thu, 4 Dec 2025 08:40:16 +0000 (09:40 +0100)
src/knot/zone/skip.c
src/knot/zone/zone.c
tests-extra/tests/zone/skip/test.py

index 3593c361f7951a4d58772d91b377c7b61dbc610e..49b84ae60c38bd7effbcfc82e3e081750088c2fd 100644 (file)
@@ -98,6 +98,10 @@ int zone_skip_from_conf(zone_skip_t *skip, conf_val_t *val)
 
 int zonefile_write_skip(const char *path, struct zone_contents *zone, conf_t *conf)
 {
+       if (zone == NULL) {
+               return KNOT_EEMPTYZONE;
+       }
+
        conf_val_t skip_val = conf_zone_get(conf, C_ZONEFILE_SKIP, zone->apex->owner);
        zone_skip_t skip = { 0 };
        int ret = zone_skip_from_conf(&skip, &skip_val);
index 82b1ef3cb050b38cad22a4e5efc950cc5e929bef..dac0dac1f668057559f2cbcb64c50409c777b15d 100644 (file)
@@ -889,6 +889,10 @@ int zone_dump_to_dir(conf_t *conf, zone_t *zone, const char *dir)
                return KNOT_EINVAL;
        }
 
+       if (zone->contents == NULL) {
+               return KNOT_EEMPTYZONE;
+       }
+
        size_t dir_len = strlen(dir);
        if (dir_len == 0) {
                return KNOT_EINVAL;
index df3d9cb96ccf0c30bf46634e8f0dcdd1d61876fc..ab9819c78a3272b68b75e070aaefb409ee4fd9e7 100644 (file)
@@ -86,4 +86,12 @@ resp.check_count(0, "AAAA")
 resp = server.dig("zf.example.com.", "AAAA", dnssec=True)
 resp.check_count(1, "AAAA")
 
+server.ctl("-f zone-purge +expire example.com.")
+t.sleep(1)
+try:
+    server.ctl("zone-flush +outdir " + server.data_dir, wait=True)
+except:
+    pass # just checking that server does not crash, below:
+server.ctl("zone-status")
+
 t.end()