Commit 9af52bf5 authored by Daniel Salzman's avatar Daniel Salzman

knot: don't sanitize input pointer in zone_contents_free

parent 610d4b81
...@@ -206,7 +206,7 @@ int changeset_init(changeset_t *ch, const knot_dname_t *apex) ...@@ -206,7 +206,7 @@ int changeset_init(changeset_t *ch, const knot_dname_t *apex)
} }
ch->remove = zone_contents_new(apex); ch->remove = zone_contents_new(apex);
if (ch->remove == NULL) { if (ch->remove == NULL) {
zone_contents_free(&ch->add); zone_contents_free(ch->add);
return KNOT_ENOMEM; return KNOT_ENOMEM;
} }
......
...@@ -52,7 +52,7 @@ static int init_incremental(zone_update_t *update, zone_t *zone) ...@@ -52,7 +52,7 @@ static int init_incremental(zone_update_t *update, zone_t *zone)
update->change.soa_from = update->change.soa_from =
node_create_rrset(zone->contents->apex, KNOT_RRTYPE_SOA); node_create_rrset(zone->contents->apex, KNOT_RRTYPE_SOA);
if (update->change.soa_from == NULL) { if (update->change.soa_from == NULL) {
zone_contents_free(&update->new_cont); zone_contents_free(update->new_cont);
changeset_clear(&update->change); changeset_clear(&update->change);
return KNOT_ENOMEM; return KNOT_ENOMEM;
} }
......
...@@ -1090,20 +1090,19 @@ int zone_contents_shallow_copy(const zone_contents_t *from, zone_contents_t **to ...@@ -1090,20 +1090,19 @@ int zone_contents_shallow_copy(const zone_contents_t *from, zone_contents_t **to
return KNOT_EOK; return KNOT_EOK;
} }
void zone_contents_free(zone_contents_t **contents) void zone_contents_free(zone_contents_t *contents)
{ {
if (contents == NULL || *contents == NULL) { if (contents == NULL) {
return; return;
} }
// free the zone tree, but only the structure // free the zone tree, but only the structure
zone_tree_free(&(*contents)->nodes); zone_tree_free(&contents->nodes);
zone_tree_free(&(*contents)->nsec3_nodes); zone_tree_free(&contents->nsec3_nodes);
dnssec_nsec3_params_free(&(*contents)->nsec3_params); dnssec_nsec3_params_free(&contents->nsec3_params);
free(*contents); free(contents);
*contents = NULL;
} }
void zone_contents_deep_free(zone_contents_t **contents) void zone_contents_deep_free(zone_contents_t **contents)
...@@ -1122,7 +1121,8 @@ void zone_contents_deep_free(zone_contents_t **contents) ...@@ -1122,7 +1121,8 @@ void zone_contents_deep_free(zone_contents_t **contents)
destroy_node_rrsets_from_tree, NULL); destroy_node_rrsets_from_tree, NULL);
} }
zone_contents_free(contents); zone_contents_free(*contents);
*contents = NULL;
} }
uint32_t zone_contents_serial(const zone_contents_t *zone) uint32_t zone_contents_serial(const zone_contents_t *zone)
......
/* 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 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 it under the terms of the GNU General Public License as published by
...@@ -232,7 +232,7 @@ int zone_contents_shallow_copy(const zone_contents_t *from, zone_contents_t **to ...@@ -232,7 +232,7 @@ int zone_contents_shallow_copy(const zone_contents_t *from, zone_contents_t **to
* *
* \param contents Zone contents to free. * \param contents Zone contents to free.
*/ */
void zone_contents_free(zone_contents_t **contents); void zone_contents_free(zone_contents_t *contents);
/*! /*!
* \brief Deallocate node RRSets inside the trees, then call zone_contents_free. * \brief Deallocate node RRSets inside the trees, then call zone_contents_free.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment