summaryrefslogtreecommitdiff
path: root/lib/ext2fs
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@users.sf.net>2011-09-15 22:23:24 -0400
committerTheodore Ts'o <tytso@mit.edu>2011-09-15 22:23:24 -0400
commit15749d7da9b6242d477801a54164b3d04c2b4102 (patch)
treee62b89abdc99042174e7abaabc5f2abda9c1dbe4 /lib/ext2fs
parent8595c5bfe60c21000707ae516dee6eed0e535f8a (diff)
downloade2fsprogs-15749d7da9b6242d477801a54164b3d04c2b4102.tar.gz
libext2fs: fix the range validation in bitmap_range2 funcs
The condition ((start+num) & ~0xffffffffULL) in bitmap_range2 and generic_bmap_range funcs in get_bitmap64.c was wrong and inconsistent with the condition (start+num-1 > bmap->real_end) in generic_bitmap_range funcs in get_bitmap.c. I got the following error from tune2fs on a 16TB fs: Illegal block number passed to ext2fs_unmark_block_bitmap #4294967295 for block bitmap for 16TB.img tune2fs: Invalid argument while reading bitmaps Fix to condition to ((start+num-1) & ~0xffffffffULL), because the bit (start+num) is not going to be changed by the funcs. Signed-off-by: Amir Goldstein <amir73il@users.sf.net> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'lib/ext2fs')
-rw-r--r--lib/ext2fs/gen_bitmap64.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c
index 80c9f7a0..06f5ce9b 100644
--- a/lib/ext2fs/gen_bitmap64.c
+++ b/lib/ext2fs/gen_bitmap64.c
@@ -392,7 +392,7 @@ errcode_t ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap bmap,
return EINVAL;
if (EXT2FS_IS_32_BITMAP(bmap)) {
- if ((start+num) & ~0xffffffffULL) {
+ if ((start+num-1) & ~0xffffffffULL) {
ext2fs_warn_bitmap2(bmap, EXT2FS_UNMARK_ERROR,
0xffffffff);
return EINVAL;
@@ -415,7 +415,7 @@ errcode_t ext2fs_get_generic_bmap_range(ext2fs_generic_bitmap bmap,
return EINVAL;
if (EXT2FS_IS_32_BITMAP(bmap)) {
- if ((start+num) & ~0xffffffffULL) {
+ if ((start+num-1) & ~0xffffffffULL) {
ext2fs_warn_bitmap2(bmap,
EXT2FS_UNMARK_ERROR, 0xffffffff);
return EINVAL;
@@ -486,7 +486,7 @@ int ext2fs_test_block_bitmap_range2(ext2fs_block_bitmap bmap,
bmap, block);
if (EXT2FS_IS_32_BITMAP(bmap)) {
- if ((block+num) & ~0xffffffffULL) {
+ if ((block+num-1) & ~0xffffffffULL) {
ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bmap,
EXT2FS_UNMARK_ERROR, 0xffffffff);
return EINVAL;
@@ -508,7 +508,7 @@ void ext2fs_mark_block_bitmap_range2(ext2fs_block_bitmap bmap,
return;
if (EXT2FS_IS_32_BITMAP(bmap)) {
- if ((block+num) & ~0xffffffffULL) {
+ if ((block+num-1) & ~0xffffffffULL) {
ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bmap,
EXT2FS_UNMARK_ERROR, 0xffffffff);
return;
@@ -536,7 +536,7 @@ void ext2fs_unmark_block_bitmap_range2(ext2fs_block_bitmap bmap,
return;
if (EXT2FS_IS_32_BITMAP(bmap)) {
- if ((block+num) & ~0xffffffffULL) {
+ if ((block+num-1) & ~0xffffffffULL) {
ext2fs_warn_bitmap2((ext2fs_generic_bitmap) bmap,
EXT2FS_UNMARK_ERROR, 0xffffffff);
return;