btrfs: fix SMAP violation, reading inline uncompressed data

should fix for #17061

Change-Id: I5973be6c443e8cf4460c6a3aca7b5378e90d717b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5426
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Jérôme Duval 2022-06-30 17:40:51 +02:00 committed by waddlesplash
parent 374a3a07a1
commit 0db74b55dc

View File

@ -269,9 +269,10 @@ Inode::ReadAt(off_t pos, uint8* buffer, size_t* _length)
}
*_length = min_c(extent_data->Size() - diff, *_length);
if (compression == BTRFS_EXTENT_COMPRESS_NONE)
memcpy(buffer, extent_data->inline_data, *_length);
else if (compression == BTRFS_EXTENT_COMPRESS_ZLIB) {
if (compression == BTRFS_EXTENT_COMPRESS_NONE) {
if (user_memcpy(buffer, extent_data->inline_data, *_length) < B_OK)
return B_BAD_ADDRESS;
} else if (compression == BTRFS_EXTENT_COMPRESS_ZLIB) {
char in[2048];
z_stream zStream = {
(Bytef*)in, // next in