Skip to content

Commit 50398fd

Browse files
asjkdave
authored andcommitted
btrfs: prop: fix zstd compression parameter validation
We let pass zstd compression parameter even if it is not fully valid. For example: $ btrfs prop set /btrfs compression zst $ btrfs prop get /btrfs compression compression=zst zlib and lzo are fine. Fix it by checking the correct prefix length. Fixes: 5c1aab1 ("btrfs: Add zstd support") CC: [email protected] # 4.14+ Reviewed-by: Nikolay Borisov <[email protected]> Signed-off-by: Anand Jain <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent f35f06c commit 50398fd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/btrfs/props.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ static int prop_compression_apply(struct inode *inode,
396396
btrfs_set_fs_incompat(fs_info, COMPRESS_LZO);
397397
} else if (!strncmp("zlib", value, 4)) {
398398
type = BTRFS_COMPRESS_ZLIB;
399-
} else if (!strncmp("zstd", value, len)) {
399+
} else if (!strncmp("zstd", value, 4)) {
400400
type = BTRFS_COMPRESS_ZSTD;
401401
btrfs_set_fs_incompat(fs_info, COMPRESS_ZSTD);
402402
} else {

0 commit comments

Comments
 (0)