Commit cb8f9afd authored by Daniel Salzman's avatar Daniel Salzman

knotd: improve some function parameters checks

parent 6b7bdf74
......@@ -95,7 +95,9 @@ static int ctx_init_dnssec(kdnssec_ctx_t *ctx, const char *kasp_path,
void kdnssec_ctx_deinit(kdnssec_ctx_t *ctx)
{
assert(ctx);
if (ctx == NULL) {
return;
}
dnssec_keystore_deinit(ctx->keystore);
dnssec_kasp_policy_free(ctx->policy);
......@@ -107,9 +109,9 @@ void kdnssec_ctx_deinit(kdnssec_ctx_t *ctx)
int kdnssec_ctx_init(kdnssec_ctx_t *ctx_ptr, const char *kasp, const char *zone)
{
assert(ctx_ptr);
assert(kasp);
assert(zone);
if (ctx_ptr == NULL || kasp == NULL || zone == NULL) {
return KNOT_EINVAL;
}
kdnssec_ctx_t ctx = { 0 };
......
......@@ -46,6 +46,9 @@ void update_policy_from_zone(dnssec_kasp_policy_t *policy,
void set_default_policy(dnssec_kasp_policy_t *policy,
const zone_contents_t *zone)
{
assert(policy);
assert(zone);
policy->rrsig_lifetime = 30 * 24 * 3600;
policy->rrsig_refresh_before = policy->rrsig_lifetime / 10;
policy->algorithm = 0;
......
......@@ -341,6 +341,8 @@ const zone_key_t *get_zone_key(const zone_keyset_t *keyset, uint16_t search)
*/
time_t knot_get_next_zone_key_event(const zone_keyset_t *keyset)
{
assert(keyset);
time_t result = LONG_MAX;
for (size_t i = 0; i < keyset->count; i++) {
......
......@@ -1193,9 +1193,9 @@ bool knot_zone_sign_soa_expired(const zone_contents_t *zone,
const zone_keyset_t *zone_keys,
const kdnssec_ctx_t *dnssec_ctx)
{
if (!zone || !zone_keys || !dnssec_ctx) {
return KNOT_EINVAL;
}
assert(zone);
assert(zone_keys);
assert(dnssec_ctx);
knot_rrset_t soa = node_rrset(zone->apex, KNOT_RRTYPE_SOA);
knot_rrset_t rrsigs = node_rrset(zone->apex, KNOT_RRTYPE_RRSIG);
......@@ -1209,7 +1209,7 @@ bool knot_zone_sign_soa_expired(const zone_contents_t *zone,
int knot_zone_sign_update_soa(const knot_rrset_t *soa,
const knot_rrset_t *rrsigs,
const zone_keyset_t *zone_keys,
const kdnssec_ctx_t *dnssec_ctx,
const kdnssec_ctx_t *dnssec_ctx,
changeset_t *changeset)
{
if (knot_rrset_empty(soa) || !zone_keys || !dnssec_ctx || !changeset) {
......@@ -1319,9 +1319,9 @@ int knot_zone_sign_nsecs_in_changeset(const zone_keyset_t *zone_keys,
const kdnssec_ctx_t *dnssec_ctx,
changeset_t *changeset)
{
assert(zone_keys);
assert(dnssec_ctx);
assert(changeset);
if (zone_keys == NULL || dnssec_ctx == NULL || changeset == NULL) {
return KNOT_EINVAL;
}
changeset_iter_t itt;
changeset_iter_add(&itt, changeset, false);
......
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