int zone_contents_add_rr(zone_contents_t *z, const knot_rrset_t *rr, zone_node_t **n)
{
- if (z == NULL || rr == NULL || n == NULL) {
+ if (rr == NULL || n == NULL) {
return KNOT_EINVAL;
}
+ if (z == NULL) {
+ return KNOT_EEMPTYZONE;
+ }
+
return insert_rr(z, rr, n);
}
int zone_contents_remove_rr(zone_contents_t *z, const knot_rrset_t *rr, zone_node_t **n)
{
- if (z == NULL || rr == NULL || n == NULL) {
+ if (rr == NULL || n == NULL) {
return KNOT_EINVAL;
}
+ if (z == NULL) {
+ return KNOT_EEMPTYZONE;
+ }
+
return remove_rr(z, rr, n, knot_rrset_is_nsec3rel(rr));
}
const zone_node_t **closest,
const zone_node_t **previous)
{
- if (!zone || !name || !match || !closest) {
+ if (name == NULL || match == NULL || closest == NULL) {
return KNOT_EINVAL;
}
+ if (zone == NULL) {
+ return KNOT_EEMPTYZONE;
+ }
+
if (knot_dname_in_bailiwick(name, zone->apex->owner) < 0) {
return KNOT_EOUTOFZONE;
}
const zone_node_t **nsec3_node,
const zone_node_t **nsec3_previous)
{
- if (zone == NULL || name == NULL || nsec3_node == NULL ||
- nsec3_previous == NULL) {
+ if (name == NULL || nsec3_node == NULL || nsec3_previous == NULL) {
return KNOT_EINVAL;
}
+ if (zone == NULL) {
+ return KNOT_EEMPTYZONE;
+ }
+
// check if the NSEC3 tree is not empty
if (zone_tree_is_empty(zone->nsec3_nodes)) {
return KNOT_ENSEC3CHAIN;
zone_tree_apply_cb_t function, void *data)
{
if (contents == NULL) {
- return KNOT_EINVAL;
+ return KNOT_EEMPTYZONE;
}
return zone_tree_apply(contents->nodes, function, data);
}
zone_tree_apply_cb_t function, void *data)
{
if (contents == NULL) {
- return KNOT_EINVAL;
+ return KNOT_EEMPTYZONE;
}
return zone_tree_apply(contents->nsec3_nodes, function, data);
}
int zone_contents_cow(const zone_contents_t *from, zone_contents_t **to)
{
- if (from == NULL || to == NULL) {
+ if (to == NULL) {
return KNOT_EINVAL;
}
+ if (from == NULL) {
+ return KNOT_EEMPTYZONE;
+ }
+
/* Copy to same destination as source. */
if (from == *to) {
return KNOT_EINVAL;
int zone_contents_load_nsec3param(zone_contents_t *contents)
{
- if (contents == NULL || contents->apex == NULL) {
+ if (contents == NULL) {
+ return KNOT_EEMPTYZONE;
+ }
+
+ if (contents->apex == NULL) {
return KNOT_EINVAL;
}
*
* \retval ZONE_NAME_FOUND if node with owner \a name was found.
* \retval ZONE_NAME_NOT_FOUND if it was not found.
+ * \retval KNOT_EEMPTYZONE
* \retval KNOT_EINVAL
* \retval KNOT_EOUTOFZONE
*/
*
* \retval ZONE_NAME_FOUND if the corresponding NSEC3 node was found.
* \retval ZONE_NAME_NOT_FOUND if it was not found.
+ * \retval KNOT_EEMPTYZONE
* \retval KNOT_EINVAL
* \retval KNOT_ENSEC3PAR
* \retval KNOT_ECRYPTO
* \param to Copy of the zone.
*
* \retval KNOT_EOK
+ * \retval KNOT_EEMPTYZONE
* \retval KNOT_EINVAL
* \retval KNOT_ENOMEM
*/
int zone_contents_digest(const zone_contents_t *contents, int algorithm,
uint8_t **out_digest, size_t *out_size)
{
- if (contents == NULL || out_digest == NULL || out_size == NULL) {
+ if (out_digest == NULL || out_size == NULL) {
return KNOT_EINVAL;
}
+ if (contents == NULL) {
+ return KNOT_EEMPTYZONE;
+ }
+
contents_digest_ctx_t ctx = {
.buf_size = DIGEST_BUF_MIN,
.buf = malloc(DIGEST_BUF_MIN),
int zone_contents_digest_verify(const zone_contents_t *contents)
{
if (contents == NULL) {
- return KNOT_EINVAL;
+ return KNOT_EEMPTYZONE;
}
knot_rdataset_t *zonemd = node_rdataset(contents->apex, KNOT_RRTYPE_ZONEMD);
*
* \param contents Zone contents ot be verified.
*
+ * \retval KNOT_EEMPTYZONE The zone is empty.
* \retval KNOT_ENOENT There is no ZONEMD in contents' apex.
* \retval KNOT_ENOTSUP None of present ZONEMD is supported (scheme+algrithm+SOAserial).
* \retval KNOT_ESEMCHECK Duplicate ZONEMD with identical scheme+algorithm pair.
int sem_checks_process(zone_contents_t *zone, semcheck_optional_t optional, sem_handler_t *handler,
time_t time)
{
- if (zone == NULL || handler == NULL) {
+ if (handler == NULL) {
return KNOT_EINVAL;
}
+ if (zone == NULL) {
+ return KNOT_EEMPTYZONE;
+ }
+
semchecks_data_t data = {
.handler = handler,
.zone = zone,
-/* Copyright (C) 2020 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/* Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
* \param handler Semantic error handler.
* \param time Check zone at given time (rrsig expiration).
*
- * \retval KNOT_EOK no error found
- * \retval KNOT_ESEMCHECK found semantic error
- * \retval KNOT_EINVAL or other error
+ * \retval KNOT_EOK no error found
+ * \retval KNOT_ESEMCHECK found semantic error
+ * \retval KNOT_EEMPTYZONE the zone is empty
+ * \retval KNOT_EINVAL another error
*/
int sem_checks_process(zone_contents_t *zone, semcheck_optional_t optional, sem_handler_t *handler,
time_t time);
int zone_contents_diff(const zone_contents_t *zone1, const zone_contents_t *zone2,
changeset_t *changeset, bool ignore_dnssec)
{
- if (zone1 == NULL || zone2 == NULL || changeset == NULL) {
+ if (changeset == NULL) {
return KNOT_EINVAL;
}
+ if (zone1 == NULL || zone2 == NULL) {
+ return KNOT_EEMPTYZONE;
+ }
+
int ret_soa = load_soas(zone1, zone2, changeset);
if (ret_soa != KNOT_EOK && ret_soa != KNOT_ENODIFF) {
return ret_soa;
int zone_dump_text(zone_contents_t *zone, FILE *file, bool comments)
{
- if (zone == NULL || file == NULL) {
+ if (file == NULL) {
return KNOT_EINVAL;
}
+ if (zone == NULL) {
+ return KNOT_EEMPTYZONE;
+ }
+
// Allocate auxiliary buffer for dumping operations.
char *buf = malloc(DUMP_BUF_LEN);
if (buf == NULL) {
-/* Copyright (C) 2020 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+/* Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
int zone_load_journal(conf_t *conf, zone_t *zone, zone_contents_t *contents)
{
- if (conf == NULL || zone == NULL || contents == NULL) {
+ if (conf == NULL || zone == NULL) {
return KNOT_EINVAL;
}
+ if (contents == NULL) {
+ return KNOT_EEMPTYZONE;
+ }
+
// Check if journal is used (later in zone_changes_load() and zone is not empty.
if (zone_contents_is_empty(contents)) {
return KNOT_EOK;
if (allow_empty_zone && journal_is_existing(j)) {
ret = journal_set_flushed(j);
} else {
- ret = KNOT_EINVAL;
+ ret = KNOT_EEMPTYZONE;
}
goto flush_journal_replan;
}
int zone_in_journal_store(conf_t *conf, zone_t *zone, zone_contents_t *new_contents)
{
- if (conf == NULL || zone == NULL || new_contents == NULL) {
+ if (conf == NULL || zone == NULL) {
return KNOT_EINVAL;
}
+ if (new_contents == NULL) {
+ return KNOT_EEMPTYZONE;
+ }
+
zone_journal_t j = { zone->journaldb, zone->name, conf };
int ret = journal_insert_zone(j, new_contents);
int zonefile_write(const char *path, zone_contents_t *zone)
{
- if (!zone || !path) {
+ if (path == NULL) {
return KNOT_EINVAL;
}
+ if (zone == NULL) {
+ return KNOT_EEMPTYZONE;
+ }
+
int ret = make_path(path, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP);
if (ret != KNOT_EOK) {
return ret;