The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=ca20444e2ad664c34bb12f1a24f4ca6dc407a5bc
commit ca20444e2ad664c34bb12f1a24f4ca6dc407a5bc Author: Mark Johnston <[email protected]> AuthorDate: 2021-03-27 17:42:48 +0000 Commit: Mark Johnston <[email protected]> CommitDate: 2021-04-03 15:12:21 +0000 vfs: Add an assertion around name length limits Some filesystems assume that they can copy a name component, with length bounded by NAME_MAX, into a dirent buffer of size MAXNAMLEN. These constants have the same value; add a compile-time assertion to that effect. Reported by: Alexey Kulaev <[email protected]> Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29431 (cherry picked from commit 71c160a8f614fa4812838002ba9d266af3cf988c) --- sys/kern/vfs_lookup.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index e881e8f909a4..07c89e634de4 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/systm.h> +#include <sys/dirent.h> #include <sys/kernel.h> #include <sys/capsicum.h> #include <sys/fcntl.h> @@ -747,6 +748,14 @@ needs_exclusive_leaf(struct mount *mp, int flags) return (0); } +/* + * Various filesystems expect to be able to copy a name component with length + * bounded by NAME_MAX into a directory entry buffer of size MAXNAMLEN. Make + * sure that these are the same size. + */ +_Static_assert(MAXNAMLEN == NAME_MAX, + "MAXNAMLEN and NAME_MAX have different values"); + /* * Search a pathname. * This is a very central and rather complicated routine. _______________________________________________ [email protected] mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "[email protected]"
