btrfs: factor out validation of btrfs_ioctl_vol_args_v2::name
authorDavid Sterba <dsterba@suse.com>
Wed, 14 Feb 2024 09:54:31 +0000 (10:54 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 4 Mar 2024 15:24:52 +0000 (16:24 +0100)
commit0478adff0fae7555c10787470ae04390a8b45e12
treeb88ef215b68c880269850350f14d4e2d16b744ae
parent5ab2b180884c2b8e6fc923cd2a0aa5c744f45eec
btrfs: factor out validation of btrfs_ioctl_vol_args_v2::name

The validation of vol args v2 name in snapshot and device remove 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/ioctl.c