From b1d56901ffa93221e1a33c805ab3ceeeada24e64 Mon Sep 17 00:00:00 2001 From: job Date: Fri, 2 Feb 2024 16:15:08 +0000 Subject: [PATCH] refactor: populate mft->path in the pre parser OK tb@ --- usr.sbin/rpki-client/parser.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/usr.sbin/rpki-client/parser.c b/usr.sbin/rpki-client/parser.c index 5a0a7fc8358..9288e5e3e2b 100644 --- a/usr.sbin/rpki-client/parser.c +++ b/usr.sbin/rpki-client/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.118 2024/02/02 14:13:58 job Exp $ */ +/* $OpenBSD: parser.c,v 1.119 2024/02/02 16:15:08 job Exp $ */ /* * Copyright (c) 2019 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -284,6 +284,11 @@ proc_parser_mft_pre(struct entity *entp, char *file, struct crl **crl, return NULL; } + if (entp->path != NULL) { + if ((mft->path = strdup(entp->path)) == NULL) + err(1, NULL); + } + if (!EVP_Digest(der, len, mft->mfthash, NULL, EVP_sha256(), NULL)) errx(1, "EVP_Digest failed"); @@ -373,8 +378,8 @@ proc_parser_mft_pre(struct entity *entp, char *file, struct crl **crl, * Return the mft on success or NULL on failure. */ static struct mft * -proc_parser_mft_post(char *file, struct mft *mft, const char *path, - const char *errstr, int *warned) +proc_parser_mft_post(char *file, struct mft *mft, const char *errstr, + int *warned) { if (mft == NULL) { if (errstr == NULL) @@ -385,11 +390,6 @@ proc_parser_mft_post(char *file, struct mft *mft, const char *path, return NULL; } - - if (path != NULL) - if ((mft->path = strdup(path)) == NULL) - err(1, NULL); - if (!mft->stale) if (!proc_parser_mft_check(file, mft)) { mft_free(mft); @@ -432,8 +432,7 @@ proc_parser_mft(struct entity *entp, struct mft **mp, char **crlfile, err2 = err1; if (mft1 != NULL) { - *mp = proc_parser_mft_post(file1, mft1, entp->path, err1, - &warned); + *mp = proc_parser_mft_post(file1, mft1, err1, &warned); if (*mp == NULL) { mft1 = NULL; if (mft2 != NULL) @@ -454,8 +453,7 @@ proc_parser_mft(struct entity *entp, struct mft **mp, char **crlfile, } else { if (err2 == NULL) err2 = err1; - *mp = proc_parser_mft_post(file2, mft2, entp->path, err2, - &warned); + *mp = proc_parser_mft_post(file2, mft2, err2, &warned); mft_free(mft1); crl_free(crl1); -- 2.20.1