Commit 19e674b7 authored by Vitezslav Kriz's avatar Vitezslav Kriz Committed by Daniel Salzman

zone: fix double free when loading zone with journal

parent c7b247bd
......@@ -378,7 +378,7 @@ int apply_replace_soa(apply_ctx_t *ctx, changeset_t *chset)
// Check for SOA with proper serial but different rdata.
if (node_rrtype_exists(contents->apex, KNOT_RRTYPE_SOA)) {
return KNOT_EINVAL;
return KNOT_EZONEINVAL;
}
return apply_add_rr(ctx, chset->soa_to);
......@@ -483,17 +483,11 @@ int apply_changesets_directly(apply_ctx_t *ctx, list_t *chsets)
WALK_LIST(set, *chsets) {
int ret = apply_single(ctx, set);
if (ret != KNOT_EOK) {
update_rollback(ctx);
return ret;
}
}
int ret = zone_contents_adjust_full(ctx->contents);
if (ret != KNOT_EOK) {
update_rollback(ctx);
}
return ret;
return zone_contents_adjust_full(ctx->contents);
}
int apply_changeset_directly(apply_ctx_t *ctx, changeset_t *ch)
......
......@@ -129,6 +129,8 @@ int apply_changeset(apply_ctx_t *ctx, zone_t *zone, changeset_t *ch,
/*!
* \brief Applies changesets directly to the zone, without copying it.
*
* \warning Modified zone is in inconsitent state after error and should be freed.
*
* \param ctx Apply context.
* \param chsets List of changesets to be applied to the zone.
*
......
......@@ -136,7 +136,7 @@ int zone_load_journal(conf_t *conf, zone_t *zone, zone_contents_t *contents)
log_zone_info(zone->name, "changes from journal applied %u -> %u",
serial, zone_contents_serial(contents));
} else {
log_zone_error(zone->name, "changes from journal applied %u -> %u (%s)",
log_zone_error(zone->name, "failed to apply journal changes %u -> %u (%s)",
serial, zone_contents_serial(contents),
knot_strerror(ret));
}
......
......@@ -42,6 +42,8 @@ int zone_load_check(conf_t *conf, zone_contents_t *contents);
/*!
* \brief Update zone contents from the journal.
*
* \warning If error, the zone is in inconsitent state and should be freed.
*
* \param conf
* \param zone
* \param contents
......
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