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 <alex.qart@gmail.com> Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29431
This commit is contained in:
parent
90d2f7c413
commit
71c160a8f6
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user