mirror of
https://gitlab.nic.cz/knot/knot-dns.git
synced 2026-05-28 04:02:31 -04:00
libknot/rrset: don't sanitize input pointer in knot_rrset_free
This commit is contained in:
parent
ae677275f4
commit
1a141beb41
26 changed files with 103 additions and 106 deletions
|
|
@ -929,7 +929,7 @@ static int zone_txn_set(zone_t *zone, ctl_args_t *args)
|
|||
}
|
||||
|
||||
ret = zone_update_add(zone->control_update, rrset);
|
||||
knot_rrset_free(&rrset, NULL);
|
||||
knot_rrset_free(rrset, NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -957,7 +957,7 @@ static int zone_txn_unset(zone_t *zone, ctl_args_t *args)
|
|||
}
|
||||
|
||||
ret = zone_update_remove(zone->control_update, rrset);
|
||||
knot_rrset_free(&rrset, NULL);
|
||||
knot_rrset_free(rrset, NULL);
|
||||
return ret;
|
||||
} else {
|
||||
uint8_t owner[KNOT_DNAME_MAXLEN];
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* 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
|
||||
|
|
@ -117,13 +117,13 @@ static int connect_nsec_nodes(zone_node_t *a, zone_node_t *b,
|
|||
knot_rrset_t *old_nsec_lc = knot_rrset_copy(&old_nsec, NULL);
|
||||
ret = knot_rrset_rr_to_canonical(old_nsec_lc);
|
||||
if (ret != KNOT_EOK) {
|
||||
knot_rrset_free(&old_nsec_lc, NULL);
|
||||
knot_rrset_free(old_nsec_lc, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool equal = knot_rrset_equal(&new_nsec, old_nsec_lc,
|
||||
KNOT_RRSET_COMPARE_WHOLE);
|
||||
knot_rrset_free(&old_nsec_lc, NULL);
|
||||
knot_rrset_free(old_nsec_lc, NULL);
|
||||
|
||||
if (equal) {
|
||||
// current NSEC is valid, do nothing
|
||||
|
|
|
|||
|
|
@ -458,7 +458,7 @@ static int connect_nsec3_nodes2(zone_node_t *a, zone_node_t *b,
|
|||
// connect the copied rrset
|
||||
int ret = connect_nsec3_base(&acopy->rrs, b->owner);
|
||||
if (ret != KNOT_EOK || knot_rrset_equal(&aorig, acopy, KNOT_RRSET_COMPARE_WHOLE)) {
|
||||
knot_rrset_free(&acopy, NULL);
|
||||
knot_rrset_free(acopy, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -471,7 +471,7 @@ static int connect_nsec3_nodes2(zone_node_t *a, zone_node_t *b,
|
|||
if (ret == KNOT_EOK) {
|
||||
ret = changeset_add_addition(data->changeset, acopy, CHANGESET_CHECK | CHANGESET_CHECK_CANCELOUT);
|
||||
}
|
||||
knot_rrset_free(&acopy, NULL);
|
||||
knot_rrset_free(acopy, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -272,12 +272,12 @@ static int add_nsec3param(const zone_contents_t *zone, changeset_t *changeset,
|
|||
|
||||
int r = set_nsec3param(rrset, params);
|
||||
if (r != KNOT_EOK) {
|
||||
knot_rrset_free(&rrset, NULL);
|
||||
knot_rrset_free(rrset, NULL);
|
||||
return r;
|
||||
}
|
||||
|
||||
r = changeset_add_addition(changeset, rrset, 0);
|
||||
knot_rrset_free(&rrset, NULL);
|
||||
knot_rrset_free(rrset, NULL);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1002,9 +1002,9 @@ int knot_zone_sign_update_dnskeys(zone_update_t *update,
|
|||
#undef CHECK_RET
|
||||
|
||||
cleanup:
|
||||
knot_rrset_free(&add_dnskeys, NULL);
|
||||
knot_rrset_free(&add_cdnskeys, NULL);
|
||||
knot_rrset_free(&add_cdss, NULL);
|
||||
knot_rrset_free(add_dnskeys, NULL);
|
||||
knot_rrset_free(add_cdnskeys, NULL);
|
||||
knot_rrset_free(add_cdss, NULL);
|
||||
changeset_clear(&ch);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@ static int axfr_consume(knot_pkt_t *pkt, struct refresh_data *data)
|
|||
// Process saved SOA if fallback from IXFR
|
||||
if (data->initial_soa_copy != NULL) {
|
||||
next = axfr_consume_rr(data->initial_soa_copy, data);
|
||||
knot_rrset_free(&data->initial_soa_copy, data->mm);
|
||||
knot_rrset_free(data->initial_soa_copy, data->mm);
|
||||
if (next != KNOT_STATE_CONSUME) {
|
||||
return next;
|
||||
}
|
||||
|
|
@ -400,7 +400,7 @@ static void ixfr_cleanup(struct refresh_data *data)
|
|||
return;
|
||||
}
|
||||
|
||||
knot_rrset_free(&data->ixfr.final_soa, data->mm);
|
||||
knot_rrset_free(data->ixfr.final_soa, data->mm);
|
||||
mm_free(data->mm, data->ixfr.proc);
|
||||
data->ixfr.proc = NULL;
|
||||
|
||||
|
|
@ -779,7 +779,7 @@ static int ixfr_consume(knot_pkt_t *pkt, struct refresh_data *data)
|
|||
// Process saved SOA if existing
|
||||
if (data->initial_soa_copy != NULL) {
|
||||
next = ixfr_consume_rr(data->initial_soa_copy, data);
|
||||
knot_rrset_free(&data->initial_soa_copy, data->mm);
|
||||
knot_rrset_free(data->initial_soa_copy, data->mm);
|
||||
if (next != KNOT_STATE_CONSUME) {
|
||||
return next;
|
||||
}
|
||||
|
|
@ -870,13 +870,13 @@ static int transfer_produce(knot_layer_t *layer, knot_pkt_t *pkt)
|
|||
uint32_t master_serial;
|
||||
int ret = zone_get_master_serial(data->zone, &master_serial);
|
||||
if (sending_soa == NULL || ret != KNOT_EOK) {
|
||||
knot_rrset_free(&sending_soa, data->mm);
|
||||
knot_rrset_free(sending_soa, data->mm);
|
||||
return KNOT_STATE_FAIL;
|
||||
}
|
||||
knot_soa_serial_set(&sending_soa->rrs, master_serial);
|
||||
knot_pkt_begin(pkt, KNOT_AUTHORITY);
|
||||
knot_pkt_put(pkt, KNOT_COMPR_HINT_QNAME, sending_soa, 0);
|
||||
knot_rrset_free(&sending_soa, data->mm);
|
||||
knot_rrset_free(sending_soa, data->mm);
|
||||
}
|
||||
|
||||
query_put_edns(pkt, &data->edns);
|
||||
|
|
|
|||
|
|
@ -199,14 +199,14 @@ static knot_rrset_t *synth_nsec(knot_pkt_t *pkt, knotd_qdata_t *qdata, knot_mm_t
|
|||
|
||||
knot_dname_t *next = online_nsec_next(nsec_owner, knotd_qdata_zone_name(qdata));
|
||||
if (!next) {
|
||||
knot_rrset_free(&nsec, mm);
|
||||
knot_rrset_free(nsec, mm);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dnssec_nsec_bitmap_t *bitmap = synth_bitmap(pkt, qdata, !is_deleg(pkt));
|
||||
if (!bitmap) {
|
||||
free(next);
|
||||
knot_rrset_free(&nsec, mm);
|
||||
knot_rrset_free(nsec, mm);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +220,7 @@ static knot_rrset_t *synth_nsec(knot_pkt_t *pkt, knotd_qdata_t *qdata, knot_mm_t
|
|||
dnssec_nsec_bitmap_free(bitmap);
|
||||
|
||||
if (knot_rrset_add_rdata(nsec, rdata, size, mm) != KNOT_EOK) {
|
||||
knot_rrset_free(&nsec, mm);
|
||||
knot_rrset_free(nsec, mm);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -259,7 +259,7 @@ static knot_rrset_t *sign_rrset(const knot_dname_t *owner,
|
|||
}
|
||||
|
||||
if (knot_rdataset_copy(©->rrs, &cover->rrs, NULL) != KNOT_EOK) {
|
||||
knot_rrset_free(©, NULL);
|
||||
knot_rrset_free(copy, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -268,7 +268,7 @@ static knot_rrset_t *sign_rrset(const knot_dname_t *owner,
|
|||
knot_rrset_t *rrsig = knot_rrset_new(owner, KNOT_RRTYPE_RRSIG, copy->rclass,
|
||||
copy->ttl, mm);
|
||||
if (!rrsig) {
|
||||
knot_rrset_free(©, NULL);
|
||||
knot_rrset_free(copy, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -281,13 +281,13 @@ static knot_rrset_t *sign_rrset(const knot_dname_t *owner,
|
|||
|
||||
int ret = knot_sign_rrset(rrsig, copy, kkey->key, kkey->ctx, &module_ctx->kctx, mm);
|
||||
if (ret != KNOT_EOK) {
|
||||
knot_rrset_free(©, NULL);
|
||||
knot_rrset_free(&rrsig, mm);
|
||||
knot_rrset_free(copy, NULL);
|
||||
knot_rrset_free(rrsig, mm);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
knot_rrset_free(©, NULL);
|
||||
knot_rrset_free(copy, NULL);
|
||||
|
||||
return rrsig;
|
||||
}
|
||||
|
|
@ -354,7 +354,7 @@ static knotd_in_state_t sign_section(knotd_in_state_t state, knot_pkt_t *pkt,
|
|||
|
||||
int r = knot_pkt_put(pkt, KNOT_COMPR_HINT_NONE, rrsig, KNOT_PF_FREE);
|
||||
if (r != KNOT_EOK) {
|
||||
knot_rrset_free(&rrsig, &pkt->mm);
|
||||
knot_rrset_free(rrsig, &pkt->mm);
|
||||
state = KNOTD_IN_STATE_ERROR;
|
||||
break;
|
||||
}
|
||||
|
|
@ -376,7 +376,7 @@ static knotd_in_state_t synth_authority(knotd_in_state_t state, knot_pkt_t *pkt,
|
|||
knot_rrset_t *nsec = synth_nsec(pkt, qdata, &pkt->mm);
|
||||
int r = knot_pkt_put(pkt, KNOT_COMPR_HINT_NONE, nsec, KNOT_PF_FREE);
|
||||
if (r != DNSSEC_EOK) {
|
||||
knot_rrset_free(&nsec, &pkt->mm);
|
||||
knot_rrset_free(nsec, &pkt->mm);
|
||||
return KNOTD_IN_STATE_ERROR;
|
||||
}
|
||||
}
|
||||
|
|
@ -413,7 +413,7 @@ static knot_rrset_t *synth_dnskey(knotd_qdata_t *qdata, const zone_keyset_t *key
|
|||
|
||||
int r = knot_rrset_add_rdata(dnskey, rdata.data, rdata.size, mm);
|
||||
if (r != KNOT_EOK) {
|
||||
knot_rrset_free(&dnskey, mm);
|
||||
knot_rrset_free(dnskey, mm);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -451,7 +451,7 @@ static knot_rrset_t *synth_cdnskey(knotd_qdata_t *qdata, online_sign_ctx_t *ctx,
|
|||
dnssec_binary_t rdata = { 0 };
|
||||
zone_key_t *key = ksk_for_cds(ctx);
|
||||
if (key == NULL) {
|
||||
knot_rrset_free(&dnskey, mm);
|
||||
knot_rrset_free(dnskey, mm);
|
||||
return NULL;
|
||||
}
|
||||
dnssec_key_get_rdata(key->key, &rdata);
|
||||
|
|
@ -459,7 +459,7 @@ static knot_rrset_t *synth_cdnskey(knotd_qdata_t *qdata, online_sign_ctx_t *ctx,
|
|||
|
||||
int ret = knot_rrset_add_rdata(dnskey, rdata.data, rdata.size, mm);
|
||||
if (ret != KNOT_EOK) {
|
||||
knot_rrset_free(&dnskey, mm);
|
||||
knot_rrset_free(dnskey, mm);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -479,7 +479,7 @@ static knot_rrset_t *synth_cds(knotd_qdata_t *qdata, online_sign_ctx_t *ctx,
|
|||
dnssec_binary_t rdata = { 0 };
|
||||
zone_key_t *key = ksk_for_cds(ctx);
|
||||
if (key == NULL) {
|
||||
knot_rrset_free(&ds, mm);
|
||||
knot_rrset_free(ds, mm);
|
||||
return NULL;
|
||||
}
|
||||
zone_key_calculate_ds(key, &rdata);
|
||||
|
|
@ -487,7 +487,7 @@ static knot_rrset_t *synth_cds(knotd_qdata_t *qdata, online_sign_ctx_t *ctx,
|
|||
|
||||
int ret = knot_rrset_add_rdata(ds, rdata.data, rdata.size, mm);
|
||||
if (ret != KNOT_EOK) {
|
||||
knot_rrset_free(&ds, mm);
|
||||
knot_rrset_free(ds, mm);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -573,7 +573,7 @@ static knotd_in_state_t synth_answer(knotd_in_state_t state, knot_pkt_t *pkt,
|
|||
|
||||
int r = knot_pkt_put(pkt, KNOT_COMPR_HINT_QNAME, dnskey, KNOT_PF_FREE);
|
||||
if (r != DNSSEC_EOK) {
|
||||
knot_rrset_free(&dnskey, &pkt->mm);
|
||||
knot_rrset_free(dnskey, &pkt->mm);
|
||||
return KNOTD_IN_STATE_ERROR;
|
||||
}
|
||||
state = KNOTD_IN_STATE_HIT;
|
||||
|
|
@ -587,7 +587,7 @@ static knotd_in_state_t synth_answer(knotd_in_state_t state, knot_pkt_t *pkt,
|
|||
|
||||
int r = knot_pkt_put(pkt, KNOT_COMPR_HINT_QNAME, dnskey, KNOT_PF_FREE);
|
||||
if (r != DNSSEC_EOK) {
|
||||
knot_rrset_free(&dnskey, &pkt->mm);
|
||||
knot_rrset_free(dnskey, &pkt->mm);
|
||||
return KNOTD_IN_STATE_ERROR;
|
||||
}
|
||||
state = KNOTD_IN_STATE_HIT;
|
||||
|
|
@ -601,7 +601,7 @@ static knotd_in_state_t synth_answer(knotd_in_state_t state, knot_pkt_t *pkt,
|
|||
|
||||
int r = knot_pkt_put(pkt, KNOT_COMPR_HINT_QNAME, ds, KNOT_PF_FREE);
|
||||
if (r != DNSSEC_EOK) {
|
||||
knot_rrset_free(&ds, &pkt->mm);
|
||||
knot_rrset_free(ds, &pkt->mm);
|
||||
return KNOTD_IN_STATE_ERROR;
|
||||
}
|
||||
state = KNOTD_IN_STATE_HIT;
|
||||
|
|
@ -615,7 +615,7 @@ static knotd_in_state_t synth_answer(knotd_in_state_t state, knot_pkt_t *pkt,
|
|||
|
||||
int r = knot_pkt_put(pkt, KNOT_COMPR_HINT_QNAME, nsec, KNOT_PF_FREE);
|
||||
if (r != DNSSEC_EOK) {
|
||||
knot_rrset_free(&nsec, &pkt->mm);
|
||||
knot_rrset_free(nsec, &pkt->mm);
|
||||
return KNOTD_IN_STATE_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* 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
|
||||
|
|
@ -333,7 +333,7 @@ static knot_rrset_t *synth_rr(char *addr_str, const synth_template_t *tpl, knot_
|
|||
}
|
||||
|
||||
if (ret != KNOT_EOK) {
|
||||
knot_rrset_free(&rr, &pkt->mm);
|
||||
knot_rrset_free(rr, &pkt->mm);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,14 +94,14 @@ static knotd_in_state_t whoami_query(knotd_in_state_t state, knot_pkt_t *pkt,
|
|||
/* Record data is the query source address. */
|
||||
int ret = knot_rrset_add_rdata(rrset, rdata, len_rdata, &pkt->mm);
|
||||
if (ret != KNOT_EOK) {
|
||||
knot_rrset_free(&rrset, &pkt->mm);
|
||||
knot_rrset_free(rrset, &pkt->mm);
|
||||
return KNOTD_IN_STATE_ERROR;
|
||||
}
|
||||
|
||||
/* Add the new RRset to the response packet. */
|
||||
ret = knot_pkt_put(pkt, KNOT_COMPR_HINT_QNAME, rrset, KNOT_PF_FREE);
|
||||
if (ret != KNOT_EOK) {
|
||||
knot_rrset_free(&rrset, &pkt->mm);
|
||||
knot_rrset_free(rrset, &pkt->mm);
|
||||
return KNOTD_IN_STATE_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* 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
|
||||
|
|
@ -31,7 +31,7 @@ static int handle_soa(knot_rrset_t **soa, const knot_rrset_t *rrset)
|
|||
assert(rrset);
|
||||
|
||||
if (*soa != NULL) {
|
||||
knot_rrset_free(soa, NULL);
|
||||
knot_rrset_free(*soa, NULL);
|
||||
}
|
||||
|
||||
*soa = knot_rrset_copy(rrset, NULL);
|
||||
|
|
@ -304,9 +304,9 @@ int changeset_add_addition(changeset_t *ch, const knot_rrset_t *rrset, changeset
|
|||
int ret = knot_rrset_empty(to_add) ? KNOT_EOK : add_rr_to_contents(ch->add, to_add);
|
||||
|
||||
if (flags & CHANGESET_CHECK) {
|
||||
knot_rrset_free((knot_rrset_t **)&rrset, NULL);
|
||||
knot_rrset_free((knot_rrset_t *)rrset, NULL);
|
||||
}
|
||||
knot_rrset_free(&rrset_cancelout, NULL);
|
||||
knot_rrset_free(rrset_cancelout, NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -341,9 +341,9 @@ int changeset_add_removal(changeset_t *ch, const knot_rrset_t *rrset, changeset_
|
|||
int ret = knot_rrset_empty(to_remove) ? KNOT_EOK : add_rr_to_contents(ch->remove, to_remove);
|
||||
|
||||
if (flags & CHANGESET_CHECK) {
|
||||
knot_rrset_free((knot_rrset_t **)&rrset, NULL);
|
||||
knot_rrset_free((knot_rrset_t *)rrset, NULL);
|
||||
}
|
||||
knot_rrset_free(&rrset_cancelout, NULL);
|
||||
knot_rrset_free(rrset_cancelout, NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -353,7 +353,7 @@ int changeset_remove_addition(changeset_t *ch, const knot_rrset_t *rrset)
|
|||
if (rrset->type == KNOT_RRTYPE_SOA) {
|
||||
/* Do not add SOAs into actual contents. */
|
||||
if (ch->soa_to != NULL) {
|
||||
knot_rrset_free(&ch->soa_to, NULL);
|
||||
knot_rrset_free(ch->soa_to, NULL);
|
||||
ch->soa_to = NULL;
|
||||
}
|
||||
return KNOT_EOK;
|
||||
|
|
@ -368,7 +368,7 @@ int changeset_remove_removal(changeset_t *ch, const knot_rrset_t *rrset)
|
|||
if (rrset->type == KNOT_RRTYPE_SOA) {
|
||||
/* Do not add SOAs into actual contents. */
|
||||
if (ch->soa_from != NULL) {
|
||||
knot_rrset_free(&ch->soa_from, NULL);
|
||||
knot_rrset_free(ch->soa_from, NULL);
|
||||
ch->soa_from = NULL;
|
||||
}
|
||||
return KNOT_EOK;
|
||||
|
|
@ -417,7 +417,7 @@ int changeset_merge(changeset_t *ch1, const changeset_t *ch2, int flags)
|
|||
if (soa_copy == NULL && ch2->soa_to) {
|
||||
return KNOT_ENOMEM;
|
||||
}
|
||||
knot_rrset_free(&ch1->soa_to, NULL);
|
||||
knot_rrset_free(ch1->soa_to, NULL);
|
||||
ch1->soa_to = soa_copy;
|
||||
|
||||
return KNOT_EOK;
|
||||
|
|
@ -466,7 +466,7 @@ static int preapply_fix_rrset(const knot_rrset_t *apply, bool adding, void *data
|
|||
}
|
||||
}
|
||||
|
||||
knot_rrset_free(&fixrrset, ctx->mm);
|
||||
knot_rrset_free(fixrrset, ctx->mm);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -539,7 +539,7 @@ int changeset_to_contents(changeset_t *ch, zone_contents_t **out)
|
|||
|
||||
*out = ch->add;
|
||||
int ret = add_rr_to_contents(*out, ch->soa_to);
|
||||
knot_rrset_free(&ch->soa_to, NULL);
|
||||
knot_rrset_free(ch->soa_to, NULL);
|
||||
if (ret != KNOT_EOK) {
|
||||
zone_contents_deep_free(out);
|
||||
}
|
||||
|
|
@ -578,8 +578,8 @@ void changeset_from_contents_free(changeset_t *ch)
|
|||
update_free_zone(&ch->add);
|
||||
|
||||
zone_contents_deep_free(&ch->remove);
|
||||
knot_rrset_free(&ch->soa_from, NULL);
|
||||
knot_rrset_free(&ch->soa_to, NULL);
|
||||
knot_rrset_free(ch->soa_from, NULL);
|
||||
knot_rrset_free(ch->soa_to, NULL);
|
||||
free(ch->data);
|
||||
free(ch);
|
||||
}
|
||||
|
|
@ -618,8 +618,10 @@ void changeset_clear(changeset_t *ch)
|
|||
zone_contents_deep_free(&ch->add);
|
||||
zone_contents_deep_free(&ch->remove);
|
||||
|
||||
knot_rrset_free(&ch->soa_from, NULL);
|
||||
knot_rrset_free(&ch->soa_to, NULL);
|
||||
knot_rrset_free(ch->soa_from, NULL);
|
||||
knot_rrset_free(ch->soa_to, NULL);
|
||||
ch->soa_from = NULL;
|
||||
ch->soa_to = NULL;
|
||||
|
||||
// Delete binary data
|
||||
free(ch->data);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* 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
|
||||
|
|
@ -33,7 +33,7 @@ static void rrset_list_clear(list_t *l)
|
|||
WALK_LIST_DELSAFE(n, nxt, *l) {
|
||||
ptrnode_t *ptr_n = (ptrnode_t *)n;
|
||||
knot_rrset_t *rrset = (knot_rrset_t *)ptr_n->d;
|
||||
knot_rrset_free(&rrset, NULL);
|
||||
knot_rrset_free(rrset, NULL);
|
||||
free(n);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -381,7 +381,7 @@ int zone_update_remove(zone_update_t *update, const knot_rrset_t *rrset)
|
|||
zone_node_t *n = NULL;
|
||||
knot_rrset_t *rrs_copy = knot_rrset_copy(rrset, &update->mm);
|
||||
int ret = zone_contents_remove_rr(update->new_cont, rrs_copy, &n);
|
||||
knot_rrset_free(&rrs_copy, &update->mm);
|
||||
knot_rrset_free(rrs_copy, &update->mm);
|
||||
return ret;
|
||||
} else {
|
||||
return KNOT_EINVAL;
|
||||
|
|
@ -525,7 +525,7 @@ static int set_new_soa(zone_update_t *update, unsigned serial_policy)
|
|||
|
||||
int ret = zone_update_remove(update, soa_cpy);
|
||||
if (ret != KNOT_EOK) {
|
||||
knot_rrset_free(&soa_cpy, NULL);
|
||||
knot_rrset_free(soa_cpy, NULL);
|
||||
}
|
||||
|
||||
uint32_t old_serial = knot_soa_serial(&soa_cpy->rrs);
|
||||
|
|
@ -539,7 +539,7 @@ static int set_new_soa(zone_update_t *update, unsigned serial_policy)
|
|||
knot_soa_serial_set(&soa_cpy->rrs, new_serial);
|
||||
|
||||
ret = zone_update_add(update, soa_cpy);
|
||||
knot_rrset_free(&soa_cpy, NULL);
|
||||
knot_rrset_free(soa_cpy, NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* 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
|
||||
|
|
@ -68,7 +68,7 @@ static int load_soas(const zone_contents_t *zone1, const zone_contents_t *zone2,
|
|||
}
|
||||
changeset->soa_to = knot_rrset_copy(&soa_rrset2, NULL);
|
||||
if (changeset->soa_to == NULL) {
|
||||
knot_rrset_free(&changeset->soa_from, NULL);
|
||||
knot_rrset_free(changeset->soa_from, NULL);
|
||||
return KNOT_ENOMEM;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ knot_rrset_t *knot_rrset_copy(const knot_rrset_t *src, knot_mm_t *mm)
|
|||
|
||||
int ret = knot_rdataset_copy(&rrset->rrs, &src->rrs, mm);
|
||||
if (ret != KNOT_EOK) {
|
||||
knot_rrset_free(&rrset, mm);
|
||||
knot_rrset_free(rrset, mm);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -68,16 +68,14 @@ knot_rrset_t *knot_rrset_copy(const knot_rrset_t *src, knot_mm_t *mm)
|
|||
}
|
||||
|
||||
_public_
|
||||
void knot_rrset_free(knot_rrset_t **rrset, knot_mm_t *mm)
|
||||
void knot_rrset_free(knot_rrset_t *rrset, knot_mm_t *mm)
|
||||
{
|
||||
if (rrset == NULL || *rrset == NULL) {
|
||||
if (rrset == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
knot_rrset_clear(*rrset, mm);
|
||||
|
||||
mm_free(mm, *rrset);
|
||||
*rrset = NULL;
|
||||
knot_rrset_clear(rrset, mm);
|
||||
mm_free(mm, rrset);
|
||||
}
|
||||
|
||||
_public_
|
||||
|
|
|
|||
|
|
@ -115,13 +115,11 @@ knot_rrset_t *knot_rrset_copy(const knot_rrset_t *src, knot_mm_t *mm);
|
|||
|
||||
/*!
|
||||
* \brief Destroys the RRSet structure and all its substructures.
|
||||
)
|
||||
* Also sets the given pointer to NULL.
|
||||
*
|
||||
* \param rrset RRset to be destroyed.
|
||||
* \param mm Memory context.
|
||||
*/
|
||||
void knot_rrset_free(knot_rrset_t **rrset, knot_mm_t *mm);
|
||||
void knot_rrset_free(knot_rrset_t *rrset, knot_mm_t *mm);
|
||||
|
||||
/*!
|
||||
* \brief Frees structures inside RRSet, but not the RRSet itself.
|
||||
|
|
|
|||
|
|
@ -383,7 +383,7 @@ int knot_tsig_sign(uint8_t *msg, size_t *msg_len, size_t msg_max_len,
|
|||
request_mac, request_mac_len,
|
||||
digest_tmp, &digest_tmp_len, tmp_tsig, key);
|
||||
if (ret != KNOT_EOK) {
|
||||
knot_rrset_free(&tmp_tsig, NULL);
|
||||
knot_rrset_free(tmp_tsig, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -395,13 +395,13 @@ int knot_tsig_sign(uint8_t *msg, size_t *msg_len, size_t msg_max_len,
|
|||
msg_max_len - *msg_len, NULL);
|
||||
if (ret < 0) {
|
||||
*digest_len = 0;
|
||||
knot_rrset_free(&tmp_tsig, NULL);
|
||||
knot_rrset_free(tmp_tsig, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t tsig_wire_len = ret;
|
||||
|
||||
knot_rrset_free(&tmp_tsig, NULL);
|
||||
knot_rrset_free(tmp_tsig, NULL);
|
||||
|
||||
*msg_len += tsig_wire_len;
|
||||
|
||||
|
|
@ -445,7 +445,7 @@ int knot_tsig_sign_next(uint8_t *msg, size_t *msg_len, size_t msg_max_len,
|
|||
size_t wire_len = prev_digest_len + to_sign_len + KNOT_TSIG_TIMERS_LENGTH + 2;
|
||||
uint8_t *wire = malloc(wire_len);
|
||||
if (!wire) {
|
||||
knot_rrset_free(&tmp_tsig, NULL);
|
||||
knot_rrset_free(tmp_tsig, NULL);
|
||||
return KNOT_ENOMEM;
|
||||
}
|
||||
memset(wire, 0, wire_len);
|
||||
|
|
@ -462,13 +462,13 @@ int knot_tsig_sign_next(uint8_t *msg, size_t *msg_len, size_t msg_max_len,
|
|||
int ret = compute_digest(wire, wire_len, digest_tmp, &digest_tmp_len, key);
|
||||
free(wire);
|
||||
if (ret != KNOT_EOK) {
|
||||
knot_rrset_free(&tmp_tsig, NULL);
|
||||
knot_rrset_free(tmp_tsig, NULL);
|
||||
*digest_len = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (digest_tmp_len > *digest_len) {
|
||||
knot_rrset_free(&tmp_tsig, NULL);
|
||||
knot_rrset_free(tmp_tsig, NULL);
|
||||
*digest_len = 0;
|
||||
return KNOT_ESPACE;
|
||||
}
|
||||
|
|
@ -485,14 +485,14 @@ int knot_tsig_sign_next(uint8_t *msg, size_t *msg_len, size_t msg_max_len,
|
|||
ret = knot_rrset_to_wire(tmp_tsig, msg + *msg_len,
|
||||
msg_max_len - *msg_len, NULL);
|
||||
if (ret < 0) {
|
||||
knot_rrset_free(&tmp_tsig, NULL);
|
||||
knot_rrset_free(tmp_tsig, NULL);
|
||||
*digest_len = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t tsig_wire_size = ret;
|
||||
|
||||
knot_rrset_free(&tmp_tsig, NULL);
|
||||
knot_rrset_free(tmp_tsig, NULL);
|
||||
|
||||
*msg_len += tsig_wire_size;
|
||||
uint16_t arcount = knot_wire_get_arcount(msg);
|
||||
|
|
@ -659,7 +659,7 @@ int knot_tsig_add(uint8_t *msg, size_t *msg_len, size_t msg_max_len,
|
|||
int ret = knot_tsig_append(msg, msg_len, msg_max_len, tmp_tsig);
|
||||
|
||||
/* key_name already referenced in RRSet, no need to free separately. */
|
||||
knot_rrset_free(&tmp_tsig, NULL);
|
||||
knot_rrset_free(tmp_tsig, NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* 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
|
||||
|
|
@ -316,7 +316,7 @@ static void print_section_question(const knot_dname_t *owner,
|
|||
|
||||
printf("%s\n", buf);
|
||||
|
||||
knot_rrset_free(&question, NULL);
|
||||
knot_rrset_free(question, NULL);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -451,7 +451,7 @@ static knot_pkt_t *create_query_packet(const query_t *query)
|
|||
// Fill in blank SOA rdata to rrset.
|
||||
ret = knot_rrset_add_rdata(soa, wire, sizeof(wire), &packet->mm);
|
||||
if (ret != KNOT_EOK) {
|
||||
knot_rrset_free(&soa, &packet->mm);
|
||||
knot_rrset_free(soa, &packet->mm);
|
||||
knot_pkt_free(packet);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -461,7 +461,7 @@ static knot_pkt_t *create_query_packet(const query_t *query)
|
|||
|
||||
ret = knot_pkt_put(packet, KNOT_COMPR_HINT_NONE, soa, KNOT_PF_FREE);
|
||||
if (ret != KNOT_EOK) {
|
||||
knot_rrset_free(&soa, &packet->mm);
|
||||
knot_rrset_free(soa, &packet->mm);
|
||||
knot_pkt_free(packet);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -353,12 +353,12 @@ static int rr_list_append(zs_scanner_t *s, list_t *target_list, knot_mm_t *mm)
|
|||
if (ret != KNOT_EOK) {
|
||||
DBG("%s: failed to set rrset from wire (%s)\n",
|
||||
__func__, knot_strerror(ret));
|
||||
knot_rrset_free(&rr, NULL);
|
||||
knot_rrset_free(rr, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (ptrlist_add(target_list, rr, mm) == NULL) {
|
||||
knot_rrset_free(&rr, NULL);
|
||||
knot_rrset_free(rr, NULL);
|
||||
return KNOT_ENOMEM;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ static void rr_list_free(list_t *list, knot_mm_t *mm)
|
|||
ptrnode_t *node = NULL;
|
||||
WALK_LIST(node, *list) {
|
||||
knot_rrset_t *rrset = (knot_rrset_t *)node->d;
|
||||
knot_rrset_free(&rrset, NULL);
|
||||
knot_rrset_free(rrset, NULL);
|
||||
}
|
||||
ptrlist_free(list, mm);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* Free extra data. */
|
||||
for (unsigned i = 0; i < NAMECOUNT; ++i) {
|
||||
knot_rrset_free(&rrsets[i], NULL);
|
||||
knot_rrset_free(rrsets[i], NULL);
|
||||
}
|
||||
free(tsig_key.secret.data);
|
||||
mp_delete((struct mempool *)mm.ctx);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ static bool check_rrset(const knot_rrset_t *rrset, const knot_dname_t *owner,
|
|||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
plan(19);
|
||||
plan_lazy();
|
||||
|
||||
// Test new
|
||||
knot_dname_t *dummy_owner = knot_dname_from_str_alloc("test.");
|
||||
|
|
@ -110,9 +110,8 @@ int main(int argc, char *argv[])
|
|||
ok(check_rrset(rrset, NULL, 0, KNOT_CLASS_IN, 0), "rrset: init empty.");
|
||||
|
||||
// "Test" freeing
|
||||
knot_rrset_free(&rrset, NULL);
|
||||
knot_rrset_free(©, NULL);
|
||||
ok(rrset == NULL && copy == NULL, "rrset: free.");
|
||||
knot_rrset_free(rrset, NULL);
|
||||
knot_rrset_free(copy, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,9 +180,9 @@ int main(int argc, char *argv[])
|
|||
ok(changeset_empty(ch2), "changeset: clear list");
|
||||
free(ch2);
|
||||
|
||||
knot_rrset_free(&apex_txt_rr, NULL);
|
||||
knot_rrset_free(&apex_spf_rr, NULL);
|
||||
knot_rrset_free(&other_rr, NULL);
|
||||
knot_rrset_free(apex_txt_rr, NULL);
|
||||
knot_rrset_free(apex_spf_rr, NULL);
|
||||
knot_rrset_free(other_rr, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,13 +154,13 @@ static void changeset_set_soa_serials(changeset_t *ch, uint32_t from, uint32_t t
|
|||
knot_rrset_t soa;
|
||||
|
||||
init_soa(&soa, from, apex);
|
||||
knot_rrset_free(&ch->soa_from, NULL);
|
||||
knot_rrset_free(ch->soa_from, NULL);
|
||||
ch->soa_from = knot_rrset_copy(&soa, NULL);
|
||||
assert(ch->soa_from);
|
||||
knot_rrset_clear(&soa, NULL);
|
||||
|
||||
init_soa(&soa, to, apex);
|
||||
knot_rrset_free(&ch->soa_to, NULL);
|
||||
knot_rrset_free(ch->soa_to, NULL);
|
||||
ch->soa_to = knot_rrset_copy(&soa, NULL);
|
||||
assert(ch->soa_to);
|
||||
knot_rrset_clear(&soa, NULL);
|
||||
|
|
@ -518,9 +518,9 @@ static knot_rrset_t * tm_rrs(const knot_dname_t * apex, int x)
|
|||
static knot_rrset_t * rrsC = NULL;
|
||||
|
||||
if (apex == NULL) {
|
||||
knot_rrset_free(&rrsA, NULL);
|
||||
knot_rrset_free(&rrsB, NULL);
|
||||
knot_rrset_free(&rrsC, NULL);
|
||||
knot_rrset_free(rrsA, NULL);
|
||||
knot_rrset_free(rrsB, NULL);
|
||||
knot_rrset_free(rrsC, NULL);
|
||||
rrsA = rrsB = rrsC = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ int main(int argc, char *argv[])
|
|||
ok(n_rrset && knot_rrset_equal(n_rrset, dummy_rrset, KNOT_RRSET_COMPARE_WHOLE),
|
||||
"Node: create existing RRSet.");
|
||||
|
||||
knot_rrset_free(&n_rrset, NULL);
|
||||
knot_rrset_free(n_rrset, NULL);
|
||||
|
||||
n_rrset = node_create_rrset(node, KNOT_RRTYPE_SOA);
|
||||
ok(n_rrset == NULL, "Node: create non-existing RRSet.");
|
||||
|
|
@ -118,7 +118,7 @@ int main(int argc, char *argv[])
|
|||
ok(ret == KNOT_ETTL && node->rrset_count == 1,
|
||||
"Node: add RRSet, TTL mismatch.");
|
||||
|
||||
knot_rrset_free(&dummy_rrset, NULL);
|
||||
knot_rrset_free(dummy_rrset, NULL);
|
||||
|
||||
// Test bool functions
|
||||
ok(node_rrtype_exists(node, KNOT_RRTYPE_TXT), "Node: type exists.");
|
||||
|
|
@ -131,7 +131,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
ok(node_rrtype_is_signed(node, KNOT_RRTYPE_TXT), "Node: type is signed.");
|
||||
|
||||
knot_rrset_free(&dummy_rrset, NULL);
|
||||
knot_rrset_free(dummy_rrset, NULL);
|
||||
|
||||
// Test remove RRset
|
||||
node_remove_rdataset(node, KNOT_RRTYPE_AAAA);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* 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
|
||||
|
|
@ -49,7 +49,7 @@ static inline void create_root_zone(server_t *server, knot_mm_t *mm)
|
|||
7200, mm);
|
||||
knot_rrset_add_rdata(soa, SOA_RDATA, SOA_RDLEN, mm);
|
||||
node_add_rrset(root->contents->apex, soa, NULL);
|
||||
knot_rrset_free(&soa, mm);
|
||||
knot_rrset_free(soa, mm);
|
||||
|
||||
/* Bake the zone. */
|
||||
zone_contents_adjust_full(root->contents);
|
||||
|
|
|
|||
Loading…
Reference in a new issue