1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-04 15:25:38 -08:00

Check that the manifest fileList has at least one entry

We already check that the fileList isn't excessively large. A bit later we
also check that the list contains a CRL, as required by RFC 9286. However,
between these two checks a zero-sized allocation may happen, which is now
avoided. sk_num() is one of those gifts that keep on giving, but it seems
that this is the only occurrence in rpki-client that can be problematic.

ok job
This commit is contained in:
tb 2024-12-24 10:03:59 +00:00
parent 7f8d83254f
commit bb0e26feb6

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mft.c,v 1.120 2024/11/02 12:30:28 job Exp $ */
/* $OpenBSD: mft.c,v 1.121 2024/12/24 10:03:59 tb Exp $ */
/*
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
@ -373,6 +373,10 @@ mft_parse_econtent(const char *fn, struct mft *mft, const unsigned char *d,
goto out;
}
if (sk_FileAndHash_num(mft_asn1->fileList) <= 0) {
warnx("%s: no files in manifest fileList", fn);
goto out;
}
if (sk_FileAndHash_num(mft_asn1->fileList) >= MAX_MANIFEST_ENTRIES) {
warnx("%s: %d exceeds manifest entry limit (%d)", fn,
sk_FileAndHash_num(mft_asn1->fileList),