From: Alberto Leiva Popper Date: Thu, 5 Dec 2024 12:44:56 +0000 (-0300) Subject: Fix random errors X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=669b70de46d03a47c558b65d3cb97d48e211fc56;p=thirdparty%2FFORT-validator.git Fix random errors Not much to say. Testing some slightly dirtier inputs; these pipelines were crashing or returning incorrectly. --- diff --git a/src/cache.c b/src/cache.c index 6cf6f9ba..07dab4c9 100644 --- a/src/cache.c +++ b/src/cache.c @@ -910,13 +910,12 @@ cache_refresh_by_sias(struct sia_uris *sias, struct cache_cage **result) if (!node) return EINVAL; /* Nothing to work with */ - *result = cage = pmalloc(sizeof(struct cache_cage)); - cage->refresh = NULL; + *result = cage = pzalloc(sizeof(struct cache_cage)); cage->fallback = node; return 0; refresh_success: - *result = cage = pmalloc(sizeof(struct cache_cage)); + *result = cage = pzalloc(sizeof(struct cache_cage)); cage->rpkiNotify = rpkiNotify; cage->refresh = node; cage->fallback = get_fallback(sias); diff --git a/src/object/certificate.c b/src/object/certificate.c index 3f59f5ac..2a1b810b 100644 --- a/src/object/certificate.c +++ b/src/object/certificate.c @@ -1848,8 +1848,10 @@ certificate_validate(struct rpki_certificate *cert) fnstack_push_map(&cert->map); cert->x509 = certificate_load(cert->map.path); - if (!cert->x509) - return -EINVAL; + if (!cert->x509) { + error = -EINVAL; + goto end; + } cert->type = get_certificate_type(cert); error = certificate_validate_chain(cert); diff --git a/src/resource.c b/src/resource.c index 4468bcce..980ae8fc 100644 --- a/src/resource.c +++ b/src/resource.c @@ -45,6 +45,9 @@ resources_create(enum rpki_policy policy, bool force_inherit) void resources_destroy(struct resources *resources) { + if (resources == NULL) + return; + if (resources->ip4s != NULL) res4_put(resources->ip4s); if (resources->ip6s != NULL)