summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--disk-io.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/disk-io.c b/disk-io.c
index 29d22fb1..bfc2879c 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -326,16 +326,17 @@ struct extent_buffer* read_tree_block_fs_info(
* Such unaligned tree block will free overlapping extent buffer,
* causing use-after-free bugs for fuzzed images.
*/
- if (!IS_ALIGNED(bytenr, sectorsize)) {
+ if (bytenr < sectorsize || !IS_ALIGNED(bytenr, sectorsize)) {
error("tree block bytenr %llu is not aligned to sectorsize %u",
bytenr, sectorsize);
return ERR_PTR(-EIO);
}
- if (!IS_ALIGNED(blocksize, nodesize)) {
+ if (blocksize < nodesize || !IS_ALIGNED(blocksize, nodesize)) {
error("tree block size %u is not aligned to nodesize %u",
blocksize, nodesize);
return ERR_PTR(-EIO);
}
+
eb = btrfs_find_create_tree_block(fs_info, bytenr, blocksize);
if (!eb)
return ERR_PTR(-ENOMEM);