-/* $OpenBSD: extern.h,v 1.84 2021/10/28 11:57:00 claudio Exp $ */
+/* $OpenBSD: extern.h,v 1.85 2021/10/28 13:51:42 job Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
*/
#define MAX_FILE_SIZE 2000000
+/*
+ * Maximum number of FileAndHash entries per Manifest.
+ */
+#define MAX_MANIFEST_ENTRIES 100000
+
#endif /* ! EXTERN_H */
-/* $OpenBSD: mft.c,v 1.41 2021/10/26 10:52:50 claudio Exp $ */
+/* $OpenBSD: mft.c,v 1.42 2021/10/28 13:51:42 job Exp $ */
/*
* Copyright (c) 2019 Kristaps Dzonsons <kristaps@bsd.lv>
*
goto out;
}
+ if (sk_ASN1_TYPE_num(seq) > MAX_MANIFEST_ENTRIES) {
+ warnx("%s: %d exceeds manifest entry limit (%d)", p->fn,
+ sk_ASN1_TYPE_num(seq), MAX_MANIFEST_ENTRIES);
+ goto out;
+ }
+
p->res->files = calloc(sk_ASN1_TYPE_num(seq), sizeof(struct mftfile));
if (p->res->files == NULL)
err(1, NULL);
}
rc = 1;
-out:
+ out:
sk_ASN1_TYPE_pop_free(seq, ASN1_TYPE_free);
return rc;
}