From: Darrick J. Wong Date: Thu, 23 Feb 2023 21:29:39 +0000 (-0800) Subject: mkfs: check dirent names when reading protofile X-Git-Tag: xfsprogs-fixes-6.2_2023-03-14~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c7814e49c682cace66d2fb0394bf797347f029f8;p=thirdparty%2Fxfsprogs-dev.git mkfs: check dirent names when reading protofile The protofile parser in mkfs does not check directory entry names when populating the filesystem. The libxfs directory code doesn't check them either, since they depend on the Linux VFS to sanitize incoming names. If someone puts a slash in the first (name) column in the protofile, this results in a successful format and xfs_repair -n immediately complains. Screen the names that are being read from the protofile. Signed-off-by: Darrick J. Wong --- diff --git a/mkfs/proto.c b/mkfs/proto.c index 68ecdbf36..7e3fc1b81 100644 --- a/mkfs/proto.c +++ b/mkfs/proto.c @@ -326,6 +326,12 @@ newdirent( int error; int rsv; + if (!libxfs_dir2_namecheck(name->name, name->len)) { + fprintf(stderr, _("%.*s: invalid directory entry name\n"), + name->len, name->name); + exit(1); + } + rsv = XFS_DIRENTER_SPACE_RES(mp, name->len); error = -libxfs_dir_createname(tp, pip, name, inum, rsv);