-/* $OpenBSD: parser.c,v 1.116 2024/02/02 12:35:15 job Exp $ */
+/* $OpenBSD: parser.c,v 1.117 2024/02/02 13:40:50 job Exp $ */
/*
* Copyright (c) 2019 Claudio Jeker <claudio@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
* Return the mft on success or NULL on failure.
*/
static struct mft *
-proc_parser_mft_pre(struct entity *entp, enum location loc, char **file,
+proc_parser_mft_pre(struct entity *entp, enum location loc, char *file,
struct crl **crl, char **crlfile, struct mft *cached_mft,
const char **errstr)
{
*crlfile = NULL;
*errstr = NULL;
- /* XXX - pull this into proc_parser_mft. */
- *file = parse_filepath(entp->repoid, entp->path, entp->file, loc);
- if (*file == NULL)
+ if (file == NULL)
return NULL;
if (noop && loc == DIR_TEMP)
return NULL;
- der = load_file(*file, &len);
+ der = load_file(file, &len);
if (der == NULL && errno != ENOENT)
- warn("parse file %s", *file);
+ warn("parse file %s", file);
- if ((mft = mft_parse(&x509, *file, entp->talid, der, len)) == NULL) {
+ if ((mft = mft_parse(&x509, file, entp->talid, der, len)) == NULL) {
free(der);
return NULL;
}
if (*crl == NULL)
*crl = parse_load_crl_from_mft(entp, mft, DIR_VALID, crlfile);
- a = valid_ski_aki(*file, &auths, mft->ski, mft->aki, NULL);
- if (!valid_x509(*file, ctx, x509, a, *crl, errstr))
+ a = valid_ski_aki(file, &auths, mft->ski, mft->aki, NULL);
+ if (!valid_x509(file, ctx, x509, a, *crl, errstr))
goto err;
X509_free(x509);
x509 = NULL;
now = get_current_time();
/* check that now is not before from */
if (now < mft->thisupdate) {
- warnx("%s: manifest not yet valid %s", *file,
+ warnx("%s: manifest not yet valid %s", file,
time2str(mft->thisupdate));
mft->stale = 1;
}
/* check that now is not after until */
if (now > mft->nextupdate) {
- warnx("%s: manifest expired on %s", *file,
+ warnx("%s: manifest expired on %s", file,
time2str(mft->nextupdate));
mft->stale = 1;
}
if ((issued_cmp = mft_compare_issued(mft, cached_mft)) < 0) {
warnx("%s: unexpected manifest issuance date (want >= %lld, "
- "got %lld)", *file, (long long)cached_mft->thisupdate,
+ "got %lld)", file, (long long)cached_mft->thisupdate,
(long long)mft->thisupdate);
goto err;
}
if ((seqnum_cmp = mft_compare_seqnum(mft, cached_mft)) < 0) {
warnx("%s: unexpected manifest number (want >= #%s, got #%s)",
- *file, cached_mft->seqnum, mft->seqnum);
+ file, cached_mft->seqnum, mft->seqnum);
goto err;
}
if (issued_cmp > 0 && seqnum_cmp == 0) {
warnx("%s: manifest issued at %lld and %lld with same "
- "manifest number #%s", *file, (long long)mft->thisupdate,
+ "manifest number #%s", file, (long long)mft->thisupdate,
(long long)cached_mft->thisupdate, cached_mft->seqnum);
goto err;
}
if (issued_cmp == 0 && seqnum_cmp > 0) {
warnx("%s: #%s and #%s were issued at same issuance date %lld",
- *file, mft->seqnum, cached_mft->seqnum,
+ file, mft->seqnum, cached_mft->seqnum,
(long long)mft->thisupdate);
goto err;
}
if (issued_cmp == 0 && seqnum_cmp == 0 && memcmp(mft->mfthash,
cached_mft->mfthash, SHA256_DIGEST_LENGTH) != 0) {
warnx("%s: misissuance, issuance date %lld and manifest number "
- "#%s were recycled", *file, (long long)mft->thisupdate,
+ "#%s were recycled", file, (long long)mft->thisupdate,
mft->seqnum);
goto err;
}
*mp = NULL;
*crlmtime = 0;
- mft2 = proc_parser_mft_pre(entp, DIR_VALID, &file2, &crl2, &crl2file,
+ file2 = parse_filepath(entp->repoid, entp->path, entp->file, DIR_VALID);
+ mft2 = proc_parser_mft_pre(entp, DIR_VALID, file2, &crl2, &crl2file,
NULL, &err2);
- mft1 = proc_parser_mft_pre(entp, DIR_TEMP, &file1, &crl1, &crl1file,
+
+ file1 = parse_filepath(entp->repoid, entp->path, entp->file, DIR_TEMP);
+ mft1 = proc_parser_mft_pre(entp, DIR_TEMP, file1, &crl1, &crl1file,
mft2, &err1);
/* overload error from temp file if it is set */