btrfs: factor out validation of btrfs_ioctl_vol_args::name
authorDavid Sterba <dsterba@suse.com>
Wed, 14 Feb 2024 09:32:47 +0000 (10:32 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 4 Mar 2024 15:24:52 +0000 (16:24 +0100)
commit5ab2b180884c2b8e6fc923cd2a0aa5c744f45eec
treeba59cd72e37b401349334e4b0859e574752025e1
parentf33163ee4c9b6dc0e94857f9912af11ac1fc7845
btrfs: factor out validation of btrfs_ioctl_vol_args::name

The validation of vol args name in several ioctls is not done properly.
a terminating NUL is written to the end of the buffer unconditionally,
assuming that this would be the last place in case the buffer is used
completely. This does not communicate back the actual error (either an
invalid or too long path).

Factor out all such cases and use a helper to do the verification,
simply look for NUL in the buffer. There's no expected practical change,
the size of buffer is 4088, this is enough for most paths or names.

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/fs.h
fs/btrfs/ioctl.c
fs/btrfs/super.c