Commit ae677275 authored by Daniel Salzman's avatar Daniel Salzman

libknot/dname: don't sanitize input pointer in knot_dname_free

parent 5740c900
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -249,7 +249,7 @@ void kasp_zone_clear(knot_kasp_zone_t *zone)
if (zone == NULL) {
return;
}
knot_dname_free(&zone->dname, NULL);
knot_dname_free(zone->dname, NULL);
for (size_t i = 0; i < zone->num_keys; i++) {
dnssec_key_free(zone->keys[i].key);
free(zone->keys[i].id);
......
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -264,13 +264,13 @@ static int create_nsec3_rrset(knot_rrset_t *rrset,
int ret = nsec3_fill_rdata(rdata, rdata_size, params, rr_types,
next_hashed);
if (ret != KNOT_EOK) {
knot_dname_free(&owner_copy, NULL);
knot_dname_free(owner_copy, NULL);
return ret;
}
ret = knot_rrset_add_rdata(rrset, rdata, rdata_size, NULL);
if (ret != KNOT_EOK) {
knot_dname_free(&owner_copy, NULL);
knot_dname_free(owner_copy, NULL);
return ret;
}
......
......@@ -836,8 +836,8 @@ static int free_helper_trie_node(trie_val_t *val, void *d)
WALK_LIST_FREE(*(info->type_list));
}
free(info->type_list);
knot_dname_free(&info->dname, NULL);
knot_dname_free(&info->hashed_dname, NULL);
knot_dname_free(info->dname, NULL);
knot_dname_free(info->hashed_dname, NULL);
free(info);
return KNOT_EOK;
}
......
......@@ -69,7 +69,7 @@ static int deserialize_rrset(wire_ctx_t *wire, knot_rrset_t *rrset, long *phase)
size_t size = knot_dname_size(wire->position);
knot_dname_t *owner = knot_dname_copy(wire->position, NULL);
if (owner == NULL || wire_ctx_available(wire) < size + 3 * sizeof(uint16_t)) {
knot_dname_free(&owner, NULL);
knot_dname_free(owner, NULL);
return KNOT_EMALF;
}
wire_ctx_skip(wire, size);
......@@ -78,7 +78,7 @@ static int deserialize_rrset(wire_ctx_t *wire, knot_rrset_t *rrset, long *phase)
uint16_t rrcount = wire_ctx_read_u16(wire);
(*phase) = rrcount;
if (wire->error != KNOT_EOK) {
knot_dname_free(&owner, NULL);
knot_dname_free(owner, NULL);
return wire->error;
}
knot_rrset_init(rrset, owner, type, rclass, 0);
......
......@@ -216,7 +216,7 @@ static knot_rrset_t *synth_nsec(knot_pkt_t *pkt, knotd_qdata_t *qdata, knot_mm_t
int written = knot_dname_to_wire(rdata, next, size);
dnssec_nsec_bitmap_write(bitmap, rdata + written);
knot_dname_free(&next, NULL);
knot_dname_free(next, NULL);
dnssec_nsec_bitmap_free(bitmap);
if (knot_rrset_add_rdata(nsec, rdata, size, mm) != KNOT_EOK) {
......
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -105,7 +105,7 @@ static int create_txt_rrset(knot_rrset_t *rrset, const knot_dname_t *owner,
int ret = knot_rrset_add_rdata(rrset, rdata, response_len + 1, mm);
if (ret != KNOT_EOK) {
knot_dname_free(&rrset->owner, mm);
knot_dname_free(rrset->owner, mm);
return ret;
}
......
......@@ -76,7 +76,7 @@ static int dname_cname_synth(const knot_rrset_t *dname_rr,
size_t labels = knot_dname_labels(dname_wire, NULL);
knot_dname_t *cname = knot_dname_replace_suffix(qname, labels, dname_tgt, mm);
if (cname == NULL) {
knot_dname_free(&owner_copy, mm);
knot_dname_free(owner_copy, mm);
return KNOT_ENOMEM;
}
......@@ -84,11 +84,11 @@ static int dname_cname_synth(const knot_rrset_t *dname_rr,
size_t cname_size = knot_dname_size(cname);
uint8_t cname_rdata[cname_size];
memcpy(cname_rdata, cname, cname_size);
knot_dname_free(&cname, mm);
knot_dname_free(cname, mm);
int ret = knot_rrset_add_rdata(cname_rrset, cname_rdata, cname_size, mm);
if (ret != KNOT_EOK) {
knot_dname_free(&owner_copy, mm);
knot_dname_free(owner_copy, mm);
return ret;
}
......
......@@ -803,7 +803,7 @@ int process_query_put_rr(knot_pkt_t *pkt, knotd_qdata_t *qdata,
knot_rrset_init(&to_add, qname_cpy, rr->type, rr->rclass, rr->ttl);
ret = knot_rdataset_copy(&to_add.rrs, &rr->rrs, &pkt->mm);
if (ret != KNOT_EOK) {
knot_dname_free(&qname_cpy, &pkt->mm);
knot_dname_free(qname_cpy, &pkt->mm);
return ret;
}
to_add.additional = rr->additional;
......
......@@ -130,7 +130,7 @@ void node_free(zone_node_t **node, knot_mm_t *mm)
mm_free(mm, (*node)->rrs);
}
knot_dname_free(&(*node)->owner, mm);
knot_dname_free((*node)->owner, mm);
mm_free(mm, *node);
*node = NULL;
......
......@@ -194,7 +194,7 @@ zone_t* zone_new(const knot_dname_t *name)
// Journal
zone->journal = journal_new();
if (zone->journal == NULL) {
knot_dname_free(&zone->name, NULL);
knot_dname_free(zone->name, NULL);
free(zone);
return NULL;
}
......@@ -242,7 +242,7 @@ void zone_free(zone_t **zone_ptr)
zone_events_deinit(zone);
knot_dname_free(&zone->name, NULL);
knot_dname_free(zone->name, NULL);
journal_free(&zone->journal);
......
......@@ -660,14 +660,13 @@ knot_dname_t *knot_dname_replace_suffix(const knot_dname_t *name, unsigned label
}
_public_
void knot_dname_free(knot_dname_t **name, knot_mm_t *mm)
void knot_dname_free(knot_dname_t *name, knot_mm_t *mm)
{
if (name == NULL || *name == NULL) {
if (name == NULL) {
return;
}
mm_free(mm, *name);
*name = NULL;
mm_free(mm, name);
}
_public_
......
......@@ -275,16 +275,10 @@ knot_dname_t *knot_dname_replace_suffix(const knot_dname_t *name, unsigned label
/*!
* \brief Destroys the given domain name.
*
* Frees also the data within the struct. This is somewhat different behaviour
* than that of RDATA and RRSet structures which do not deallocate their
* contents.
*
* Sets the given pointer to NULL.
*
* \param name Domain name to be destroyed.
* \param mm Memory context.
*/
void knot_dname_free(knot_dname_t **name, knot_mm_t *mm);
void knot_dname_free(knot_dname_t *name, knot_mm_t *mm);
/*!
* \brief Compares two domain names by labels (case sensitive).
......
......@@ -689,7 +689,7 @@ static int parse_header(const uint8_t *pkt_wire, size_t *pos, size_t pkt_size,
}
if (pkt_size - *pos < RR_HEADER_SIZE) {
knot_dname_free(&owner, mm);
knot_dname_free(owner, mm);
return KNOT_EMALF;
}
......@@ -704,12 +704,12 @@ static int parse_header(const uint8_t *pkt_wire, size_t *pos, size_t pkt_size,
*pos = wire_ctx_offset(&wire);
if (wire.error != KNOT_EOK) {
knot_dname_free(&owner, mm);
knot_dname_free(owner, mm);
return wire.error;
}
if (wire_ctx_available(&wire) < *rdlen) {
knot_dname_free(&owner, mm);
knot_dname_free(owner, mm);
return KNOT_EMALF;
}
......
......@@ -36,7 +36,7 @@ knot_rrset_t *knot_rrset_new(const knot_dname_t *owner, uint16_t type,
knot_rrset_t *ret = mm_alloc(mm, sizeof(knot_rrset_t));
if (ret == NULL) {
knot_dname_free(&owner_cpy, mm);
knot_dname_free(owner_cpy, mm);
return NULL;
}
......@@ -88,7 +88,8 @@ void knot_rrset_clear(knot_rrset_t *rrset, knot_mm_t *mm)
}
knot_rdataset_clear(&rrset->rrs, mm);
knot_dname_free(&rrset->owner, mm);
knot_dname_free(rrset->owner, mm);
rrset->owner = NULL;
}
_public_
......
/* Copyright (C) 2015 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -31,7 +31,7 @@ void knot_tsig_key_deinit(knot_tsig_key_t *key)
return;
}
knot_dname_free(&key->name, NULL);
knot_dname_free(key->name, NULL);
memset(key->secret.data, 0, key->secret.size);
dnssec_binary_free(&key->secret);
......@@ -68,7 +68,7 @@ int knot_tsig_key_init(knot_tsig_key_t *key, const char *algorithm_name,
dnssec_binary_t secret = { 0 };
int result = dnssec_binary_from_base64(&b64secret, &secret);
if (result != KNOT_EOK) {
knot_dname_free(&dname, NULL);
knot_dname_free(dname, NULL);
return result;
}
......
......@@ -420,7 +420,7 @@ static knot_pkt_t *create_query_packet(const query_t *query)
int ret = knot_pkt_put_question(packet, qname, query->class_num,
query->type_num);
if (ret != KNOT_EOK) {
knot_dname_free(&qname, NULL);
knot_dname_free(qname, NULL);
knot_pkt_free(packet);
return NULL;
}
......@@ -442,7 +442,7 @@ static knot_pkt_t *create_query_packet(const query_t *query)
query->class_num,
0,
&packet->mm);
knot_dname_free(&qname, NULL);
knot_dname_free(qname, NULL);
if (soa == NULL) {
knot_pkt_free(packet);
return NULL;
......@@ -468,7 +468,7 @@ static knot_pkt_t *create_query_packet(const query_t *query)
free(soa);
} else {
knot_dname_free(&qname, NULL);
knot_dname_free(qname, NULL);
}
// Begin additional section
......
......@@ -183,7 +183,7 @@ int keymgr_generate_key(kdnssec_ctx_t *ctx, int argc, char *argv[])
knot_dname_t *unused = NULL;
ret = kasp_db_get_policy_last(*ctx->kasp_db, addtopolicy, &unused,
&last_policy_last);
knot_dname_free(&unused, NULL);
knot_dname_free(unused, NULL);
if (ret != KNOT_EOK && ret != KNOT_ENOENT) {
return ret;
}
......
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -151,7 +151,7 @@ static bool dname_isvalid(const char *lp)
if (dn == NULL) {
return false;
}
knot_dname_free(&dn, NULL);
knot_dname_free(dn, NULL);
return true;
}
......@@ -197,7 +197,7 @@ static int parse_partial_rr(zs_scanner_t *s, const char *lp, unsigned flags)
s->r_owner_length = knot_dname_size(owner);
memcpy(s->r_owner, owner, s->r_owner_length);
knot_dname_free(&owner, NULL);
knot_dname_free(owner, NULL);
/* Append origin if not FQDN. */
if (!fqdn) {
......@@ -396,7 +396,7 @@ static int build_query(knsupdate_params_t *params)
knot_dname_t *qname = knot_dname_from_str_alloc(params->zone);
int ret = knot_pkt_put_question(query, qname, params->class_num,
params->type_num);
knot_dname_free(&qname, NULL);
knot_dname_free(qname, NULL);
if (ret != KNOT_EOK) {
return ret;
}
......
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -122,7 +122,7 @@ int main(int argc, char *argv[])
knot_dname_t *dname = knot_dname_from_str_alloc(zonename);
free(zonename);
int ret = zone_check(filename, dname, stdout, (time_t)check_time);
knot_dname_free(&dname, NULL);
knot_dname_free(dname, NULL);
log_close();
......
......@@ -74,7 +74,7 @@ static void test_str(const char *in_str, const char *in_bin, size_t bin_len) {
/* dname_to_str_alloc */
s2 = knot_dname_to_str_alloc(d2);
knot_dname_free(&d2, NULL);
knot_dname_free(d2, NULL);
ok(s2 != NULL, "dname_to_str_alloc: %s", s1);
if (s2 == NULL) {
skip_block(3, "dname_to_str_alloc: %s", s1);
......@@ -99,7 +99,7 @@ static void test_str(const char *in_str, const char *in_bin, size_t bin_len) {
/* dname compare */
ok(d2 && memcmp(d2, in_bin, bin_len) == 0, "dname compare: %s", s2);
knot_dname_free(&d2, NULL);
knot_dname_free(d2, NULL);
free(s2);
}
......@@ -490,26 +490,26 @@ int main(int argc, char *argv[])
t = "ab.cd.ef";
d = knot_dname_from_str_alloc(t);
ok(!knot_dname_is_sub(d, d2), "dname_subdomain: equal name");
knot_dname_free(&d, NULL);
knot_dname_free(d, NULL);
/* true subdomain */
t = "0.ab.cd.ef";
d = knot_dname_from_str_alloc(t);
ok(knot_dname_is_sub(d, d2), "dname_subdomain: true subdomain");
knot_dname_free(&d, NULL);
knot_dname_free(d, NULL);
/* not subdomain */
t = "cd.ef";
d = knot_dname_from_str_alloc(t);
ok(!knot_dname_is_sub(d, d2), "dname_subdomain: not subdomain");
knot_dname_free(&d, NULL);
knot_dname_free(d, NULL);
/* root subdomain */
t = ".";
d = knot_dname_from_str_alloc(t);
ok(knot_dname_is_sub(d2, d), "dname_subdomain: root subdomain");
knot_dname_free(&d, NULL);
knot_dname_free(&d2, NULL);
knot_dname_free(d, NULL);
knot_dname_free(d2, NULL);
/* DNAME PARSE CHECKS */
......@@ -520,7 +520,7 @@ int main(int argc, char *argv[])
d = knot_dname_parse((const uint8_t *)t, &pos, len, NULL);
ok(d != NULL, "dname_parse: valid name");
ok(pos == len, "dname_parse: valid name (parsed length)");
knot_dname_free(&d, NULL);
knot_dname_free(d, NULL);
/* parse from wire (invalid) */
t = "\x08""dddd";
......@@ -539,29 +539,29 @@ int main(int argc, char *argv[])
t = "ab.cd.fe";
d2 = knot_dname_from_str_alloc(t);
ok(!knot_dname_is_equal(d, d2), "dname_is_equal: same label count");
knot_dname_free(&d2, NULL);
knot_dname_free(d2, NULL);
t = "ab.cd";
d2 = knot_dname_from_str_alloc(t);
ok(!knot_dname_is_equal(d, d2), "dname_is_equal: len(d1) < len(d2)");
knot_dname_free(&d2, NULL);
knot_dname_free(d2, NULL);
t = "ab.cd.ef.gh";
d2 = knot_dname_from_str_alloc(t);
ok(!knot_dname_is_equal(d, d2), "dname_is_equal: len(d1) > len(d2)");
knot_dname_free(&d2, NULL);
knot_dname_free(d2, NULL);
t = "ab.cd.efe";
d2 = knot_dname_from_str_alloc(t);
ok(!knot_dname_is_equal(d, d2), "dname_is_equal: last label longer");
knot_dname_free(&d2, NULL);
knot_dname_free(d2, NULL);
t = "ab.cd.e";
d2 = knot_dname_from_str_alloc(t);
ok(!knot_dname_is_equal(d, d2), "dname_is_equal: last label shorter");
knot_dname_free(&d2, NULL);
knot_dname_free(d2, NULL);
knot_dname_free(&d, NULL);
knot_dname_free(d, NULL);
/* DNAME CONVERSION TO LOOK-UP FORMAT CHECK */
......
......@@ -824,7 +824,7 @@ static void test_chain(void)
is_int(KNOT_EOK, ret, "%s: dname %s, parse, return", __func__, t->msg);
ok(knot_dname_is_equal(dname, t->dname), "%s: dname %s, parse, value",
__func__, t->msg);
knot_dname_free(&dname, NULL);
knot_dname_free(dname, NULL);
}
// Error tests.
......
......@@ -131,7 +131,7 @@ int main(int argc, char *argv[])
/* Write ANSWER section. */
rrsets[0] = knot_rrset_new(dnames[0], KNOT_RRTYPE_A, KNOT_CLASS_IN, TTL, NULL);
knot_dname_free(&dnames[0], NULL);
knot_dname_free(dnames[0], NULL);
knot_rrset_add_rdata(rrsets[0], RDVAL(0), RDLEN(0), NULL);
ret = knot_pkt_put(out, KNOT_COMPR_HINT_QNAME, rrsets[0], 0);
is_int(KNOT_EOK, ret, "pkt: write ANSWER");
......@@ -144,7 +144,7 @@ int main(int argc, char *argv[])
ret = KNOT_EOK;
for (unsigned i = 1; i < NAMECOUNT; ++i) {
rrsets[i] = knot_rrset_new(dnames[i], KNOT_RRTYPE_NS, KNOT_CLASS_IN, TTL, NULL);
knot_dname_free(&dnames[i], NULL);
knot_dname_free(dnames[i], NULL);
knot_rrset_add_rdata(rrsets[i], RDVAL(i), RDLEN(i), NULL);
ret |= knot_pkt_put(out, KNOT_COMPR_HINT_NONE, rrsets[i], 0);
}
......
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -51,11 +51,11 @@ int main(int argc, char *argv[])
"rrset: set fields during create.");
// Test init
knot_dname_free(&dummy_owner, NULL);
knot_dname_free(dummy_owner, NULL);
dummy_owner = knot_dname_from_str_alloc("test2.");
assert(dummy_owner);
knot_dname_free(&rrset->owner, NULL);
knot_dname_free(rrset->owner, NULL);
knot_rrset_init(rrset, dummy_owner, KNOT_RRTYPE_A, KNOT_CLASS_CH, 7200);
ok(check_rrset(rrset, dummy_owner, KNOT_RRTYPE_A, KNOT_CLASS_CH, 7200),
"rrset: init.");
......@@ -87,7 +87,8 @@ int main(int argc, char *argv[])
ok(knot_rrset_equal(rrset, copy, KNOT_RRSET_COMPARE_WHOLE),
"rrset: cmp headers - rdata");
knot_dname_free(&rrset->owner, NULL);
knot_dname_free(rrset->owner, NULL);
rrset->owner = NULL;
ok(!knot_rrset_equal(rrset, copy, KNOT_RRSET_COMPARE_HEADER),
"rrset: cmp NULL owner");
......
......@@ -36,7 +36,7 @@ static void _test_nsec_next(const char *msg,
knot_dname_t *next = online_nsec_next(input, apex);
ok(next != NULL && knot_dname_is_equal(next, expected),
"nsec_next, %s", msg);
knot_dname_free(&next, NULL);
knot_dname_free(next, NULL);
}
/*!
......
......@@ -102,7 +102,7 @@ int main(int argc, char *argv[])
knot_dname_t *qname = knot_dname_from_str_alloc("beef.");
int ret = knot_pkt_put_question(query, qname, KNOT_CLASS_IN, KNOT_RRTYPE_A);
knot_dname_free(&qname, NULL);
knot_dname_free(qname, NULL);
if (ret != KNOT_EOK) {
knot_pkt_free(query);
return KNOT_ERROR; /* Fatal */
......@@ -159,7 +159,7 @@ int main(int argc, char *argv[])
ok(rd.passed, "rrl: hashtable is ~ consistent");
#endif
knot_dname_free(&zone, NULL);
knot_dname_free(zone, NULL);
knot_pkt_free(query);
rrl_destroy(rrl);
dnssec_crypto_cleanup();
......
/* Copyright (C) 2011 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -183,10 +183,10 @@ static void test_acl_allowed(void)
ok(ret == true, "IPv6 address from range, no key, action match");
conf_free(conf());
knot_dname_free(&zone_name, NULL);
knot_dname_free(&key1_name, NULL);
knot_dname_free(&key2_name, NULL);
knot_dname_free(&key3_name, NULL);
knot_dname_free(zone_name, NULL);
knot_dname_free(key1_name, NULL);
knot_dname_free(key2_name, NULL);
knot_dname_free(key3_name, NULL);
}
int main(int argc, char *argv[])
......
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -34,7 +34,7 @@ int main(int argc, char *argv[])
knot_dname_t *d = knot_dname_from_str_alloc("test.");
assert(d);
changeset_t *ch = changeset_new(d);
knot_dname_free(&d, NULL);
knot_dname_free(d, NULL);
ok(ch != NULL, "changeset: new");
if (!ch) {
return 1;
......@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
is_int(KNOT_EOK, ret, "changeset: add multiple");
// Add another node.
knot_dname_free(&d, NULL);
knot_dname_free(d, NULL);
d = knot_dname_from_str_alloc("here.come.more.non.terminals.test");
assert(d);
knot_rrset_t *other_rr = knot_rrset_new(d, KNOT_RRTYPE_TXT, KNOT_CLASS_IN, 3600, NULL);
......@@ -121,21 +121,21 @@ int main(int argc, char *argv[])
ok(size == 3, "changeset: iter all");
// Create new changeset.
knot_dname_free(&d, NULL);
knot_dname_free(d, NULL);
d = knot_dname_from_str_alloc("test.");
assert(d);
changeset_t *ch2 = changeset_new(d);
knot_dname_free(&d, NULL);
knot_dname_free(d, NULL);
assert(ch2);
// Add something to add section.
knot_dname_free(&apex_txt_rr->owner, NULL);
knot_dname_free(apex_txt_rr->owner, NULL);
apex_txt_rr->owner = knot_dname_from_str_alloc("something.test.");
assert(apex_txt_rr->owner);
ret = changeset_add_addition(ch2, apex_txt_rr, CHANGESET_CHECK);
assert(ret == KNOT_EOK);
// Add something to remove section.
knot_dname_free(&apex_txt_rr->owner, NULL);
knot_dname_free(apex_txt_rr->owner, NULL);
apex_txt_rr->owner =
knot_dname_from_str_alloc("and.now.for.something.completely.different.test.");
assert(apex_txt_rr->owner);
......@@ -148,7 +148,7 @@ int main(int argc, char *argv[])
// Test preapply fix.
zone_contents_t *z = zone_contents_new((const knot_dname_t *)"\x04""test");
knot_dname_free(&apex_txt_rr->owner, NULL);
knot_dname_free(apex_txt_rr->owner, NULL);
apex_txt_rr->owner = knot_dname_from_str_alloc("something.test.");
assert(apex_txt_rr->owner);
zone_node_t *znode = NULL;
......
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -36,7 +36,7 @@ static void check_name(const char *zone, const char *name, const char *ref)
free(file);
}
knot_dname_free(&z, NULL);
knot_dname_free(z, NULL);
}
static void check_name_err(const char *zone, const char *name)
......@@ -45,7 +45,7 @@ static void check_name_err(const char *zone, const char *name)
ok(get_filename(NULL, NULL, z, name) == NULL, "Invalid name %s", name);
knot_dname_free(&z, NULL);
knot_dname_free(z, NULL);
}
static void test_get_filename(void)
......@@ -189,11 +189,11 @@ static void test_conf_zonefile(void)
}
conf_free(conf());
knot_dname_free(&zone_arpa, NULL);
knot_dname_free(&zone_root, NULL);
knot_dname_free(&zone_1label, NULL);
knot_dname_free(&zone_3label, NULL);
knot_dname_free(&zone_unknown, NULL);
knot_dname_free(zone_arpa, NULL);
knot_dname_free(zone_root, NULL);
knot_dname_free(zone_1label, NULL);
knot_dname_free(zone_3label, NULL);
knot_dname_free(zone_unknown, NULL);
}
int main(int argc, char *argv[])
......
......@@ -447,9 +447,9 @@ static void test_conf_io_set(void)
ok(val.code == KNOT_EOK, "check entry");
ok(strcmp(conf_str(&val), "xyz") == 0, "check entry value");
knot_dname_free(&zone1, NULL);
knot_dname_free(&zone2, NULL);
knot_dname_free(&zone3, NULL);
knot_dname_free(zone1, NULL);
knot_dname_free(zone2, NULL);
knot_dname_free(zone3, NULL);
ok(conf_io_commit(false) == KNOT_EOK, "commit txn");
......@@ -633,9 +633,9 @@ static void test_conf_io_unset(void)
val = conf_zone_get_txn(conf(), conf()->io.txn, C_COMMENT, zone2);
ok(val.code == KNOT_YP_EINVAL_ID, "check entry");
knot_dname_free(&zone1, NULL);
knot_dname_free(&zone2, NULL);
knot_dname_free(&zone3, NULL);
knot_dname_free(zone1, NULL);
knot_dname_free(zone2, NULL);
knot_dname_free(zone3, NULL);
conf_io_abort(false);
}
......@@ -763,7 +763,7 @@ static void test_conf_io_get(void)
"zone[zone3.].comment = \"xyz\"";
ok(strcmp(ref, out) == 0, "compare result");
knot_dname_free(&zone1, NULL);
knot_dname_free(zone1, NULL);
conf_io_abort(false);
}
......
......@@ -149,7 +149,7 @@ int main(int argc, char *argv[])
node_free(&node, NULL);
ok(node == NULL, "Node: free.");
knot_dname_free(&dummy_owner, NULL);
knot_dname_free(dummy_owner, NULL);
return 0;
}
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -46,8 +46,9 @@ static void ztree_init_data(void)
static void ztree_free_data(void)
{
for (unsigned i = 0; i < NCOUNT; ++i)
knot_dname_free(NAME + i, NULL);
for (unsigned i = 0; i < NCOUNT; ++i) {
knot_dname_free(NAME[i], NULL);
}
}
static int ztree_iter_data(zone_node_t **node, void *data)
......@@ -103,7 +104,7 @@ int main(int argc, char *argv[])
zone_node_t *prev = NULL;
knot_dname_t *tmp_dn = knot_dname_from_str_alloc("z.ac.");
zone_tree_get_less_or_equal(t, tmp_dn, &node, &prev);
knot_dname_free(&tmp_dn, NULL);
knot_dname_free(tmp_dn, NULL);
ok(prev == NODE + 1, "ztree: ordered lookup");
/* 5. ordered traversal */
......
/* Copyright (C) 2017 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
/* Copyright (C) 2018 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
......@@ -129,7 +129,7 @@ void test_full(zone_t *zone, zs_scanner_t *sc)
ret = zone_update_remove_node(&update, rem_node_name);
node = (zone_node_t *) zone_update_get_node(&update, rem_node_name);
ok(ret == KNOT_EOK && !node, "full zone update: node removal");
knot_dname_free(&rem_node_name, NULL);
knot_dname_free(rem_node_name, NULL);
/* Test iteration */
zone_update_iter_t it;
......@@ -234,7 +234,7 @@ void test_incremental(zone_t *zone, zs_scanner_t *sc)
synth_node = zone_update_get_node(&update, rem_node_name);
ok(ret == KNOT_EOK && !synth_node,
"incremental zone update: node removal");
knot_dname_free(&rem_node_name, NULL);
knot_dname_free(rem_node_name, NULL);