Skip to content
Snippets Groups Projects
Commit 73a7a995 authored by Jan Včelák's avatar Jan Včelák :rocket:
Browse files

DNSSEC: zone keys freeing cleanup

parent 1c3335c2
Branches
Tags
No related merge requests found
......@@ -83,7 +83,6 @@ static int zone_sign(knot_zone_t *zone, knot_changeset_t *out_ch, bool force,
"Not signing the %s zone!\n",
knot_strerror(result), zname);
free(zname);
free_sign_contexts(&zone_keys);
free_zone_keys(&zone_keys);
return result;
}
......@@ -104,7 +103,6 @@ static int zone_sign(knot_zone_t *zone, knot_changeset_t *out_ch, bool force,
"Not signing the %s zone!\n",
knot_strerror(result), zname);
free(zname);
free_sign_contexts(&zone_keys);
free_zone_keys(&zone_keys);
return result;
}
......@@ -118,7 +116,6 @@ static int zone_sign(knot_zone_t *zone, knot_changeset_t *out_ch, bool force,
log_zone_error("Error signing zone %s (%s).\n",
zname, knot_strerror(result));
free(zname);
free_sign_contexts(&zone_keys);
free_zone_keys(&zone_keys);
return result;
}
......@@ -132,7 +129,6 @@ static int zone_sign(knot_zone_t *zone, knot_changeset_t *out_ch, bool force,
log_server_info("No signing performed, zone %s is valid.\n",
zname);
free(zname);
free_sign_contexts(&zone_keys);
free_zone_keys(&zone_keys);
assert(knot_changeset_is_empty(out_ch));
return KNOT_EOK;
......@@ -147,12 +143,10 @@ static int zone_sign(knot_zone_t *zone, knot_changeset_t *out_ch, bool force,
" Not signing the %s zone!\n",
knot_strerror(result), zname);
free(zname);
free_sign_contexts(&zone_keys);
free_zone_keys(&zone_keys);
return result;
}
free_sign_contexts(&zone_keys);
free_zone_keys(&zone_keys);
return KNOT_EOK;
......
......@@ -24,6 +24,15 @@
#include "libknot/dnssec/sign.h"
#include "libknot/dnssec/zone-keys.h"
static void free_sign_contexts(knot_zone_keys_t *keys)
{
for (int i = 0; i < keys->count; i++) {
knot_dnssec_sign_free(keys->contexts[i]);
keys->contexts[i] = NULL;
}
}
static int init_sign_contexts(knot_zone_keys_t *keys)
{
assert(keys);
......@@ -161,18 +170,11 @@ int load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
return KNOT_EOK;
}
void free_sign_contexts(knot_zone_keys_t *keys)
{
for (int i = 0; i < keys->count; i++) {
knot_dnssec_sign_free(keys->contexts[i]);
keys->contexts[i] = NULL;
}
}
void free_zone_keys(knot_zone_keys_t *keys)
{
free_sign_contexts(keys);
for (int i = 0; i < keys->count; i++) {
knot_dnssec_key_free(&keys->keys[i]);
}
}
......@@ -60,7 +60,11 @@ typedef struct {
int load_zone_keys(const char *keydir_name, const knot_dname_t *zone_name,
knot_zone_keys_t *keys);
void free_sign_contexts(knot_zone_keys_t *keys);
/*!
* \brief Free structure with zone keys and associated DNSSEC contexts.
*
* \param keys Zone keys.
*/
void free_zone_keys(knot_zone_keys_t *keys);
#endif // _KNOT_DNSSEC_ZONE_KEYS_H_
......
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