tarfs: Limit file name length

When indexing the tarball on mount, fail if a file or directory name
exceeds MAXNAMLEN.

Reported by:	n0ps1ed
Reported by:	Franz Bettag <[email protected]>
MFC after:	1 week
Reviewed by:	markj, emaste
Differential Revision:	https://reviews.freebsd.org/D60903
This commit is contained in:
Dag-Erling Smørgrav committed 2026-11-02 13:29:17 +01:00
1 parent d667885130
commit a380332346
1 file changed
+2
+2
View File
@@ -173,6 +173,8 @@ tarfs_alloc_node(struct tarfs_mount *tmp, const char *name, size_t namelen,
if (parent != NULL && parent->type != VDIR)
return (ENOTDIR);
if (namelen > NAME_MAX)
return (ENAMETOOLONG);
tnp = malloc(sizeof(struct tarfs_node), M_TARFSNODE, M_WAITOK | M_ZERO);
mtx_init(&tnp->lock, "tarfs node lock", NULL, MTX_DEF);
tnp->gen = arc4random();