diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2022-01-13 13:46:04 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2022-01-13 13:46:04 +0000 |
commit | c6767b51147fd70dda048bd0e31f1ebcbf41de14 (patch) | |
tree | 374ecf4fe6e406797545dd53e4793bcadb7ba2c1 /usr.sbin/rpki-client/mft.c | |
parent | cf017c9839d7346d630456513c02b7f4cf6cb2c5 (diff) |
Alter valid_filehash() to take a file descriptor instead of a path.
This is needed so that callers can allow a file to be in multiple
locations. Also move mft_check() from mft.c to parser.c.
OK tb@
Diffstat (limited to 'usr.sbin/rpki-client/mft.c')
-rw-r--r-- | usr.sbin/rpki-client/mft.c | 41 |
1 files changed, 1 insertions, 40 deletions
diff --git a/usr.sbin/rpki-client/mft.c b/usr.sbin/rpki-client/mft.c index d9268fda7d6..bd8be3091aa 100644 --- a/usr.sbin/rpki-client/mft.c +++ b/usr.sbin/rpki-client/mft.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mft.c,v 1.44 2022/01/11 13:06:07 claudio Exp $ */ +/* $OpenBSD: mft.c,v 1.45 2022/01/13 13:46:03 claudio Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -20,7 +20,6 @@ #include <limits.h> #include <stdarg.h> #include <stdint.h> -#include <fcntl.h> #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -459,44 +458,6 @@ out: } /* - * Check all files and their hashes in a MFT structure. - * Return zero on failure, non-zero on success. - */ -int -mft_check(const char *fn, struct mft *p) -{ - size_t i; - int rc = 1; - char *cp, *h, *path = NULL; - - /* Check hash of file now, but first build path for it */ - cp = strrchr(fn, '/'); - assert(cp != NULL); - assert(cp - fn < INT_MAX); - - for (i = 0; i < p->filesz; i++) { - const struct mftfile *m = &p->files[i]; - if (!valid_filename(m->file)) { - if (base64_encode(m->hash, sizeof(m->hash), &h) == -1) - errx(1, "base64_encode failed in %s", __func__); - warnx("%s: unsupported filename for %s", fn, h); - free(h); - continue; - } - if (asprintf(&path, "%.*s/%s", (int)(cp - fn), fn, - m->file) == -1) - err(1, NULL); - if (!valid_filehash(path, m->hash, sizeof(m->hash))) { - warnx("%s: bad message digest for %s", fn, m->file); - rc = 0; - } - free(path); - } - - return rc; -} - -/* * Free an MFT pointer. * Safe to call with NULL. */ |