summaryrefslogtreecommitdiff
path: root/lib/ext2fs/res_gdt.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2008-04-06 17:00:23 -0400
committerTheodore Ts'o <tytso@mit.edu>2008-04-06 17:00:23 -0400
commit52bb0b050ab7001f92f8110c0167cedec53bdcb5 (patch)
tree0147e388508544613df10e5fee15fd23c8fe09ff /lib/ext2fs/res_gdt.c
parent283986cafe8fb710479d79ca566a4d7dfc6e5880 (diff)
downloade2fsprogs-52bb0b050ab7001f92f8110c0167cedec53bdcb5.tar.gz
libext2fs: Fix resize inode creation with non-standard s_first_data_block
Thanks to Max Lindner (lokimuh) for pointing this out. I'm playing around a bit with ext2 and multi-user encryption and I need space for my key management. So I set s_first_data_block to 4000 or something like that. This way mke2fs segfaults when executing ext2fs_create_resize_inode() because blk_t goal = 3 + sb->s_reserved_gdt_blocks + fs->desc_blocks + fs->inode_blocks_per_group; will produce a integer underrun later and segfault then in the ext2fs_test_bit assembler inline function. when exchanging 3 with 2 + sb->s_first_data_block, mke2fs does not segfault. I'm not 100% sure if thats the correct way dealing with this issue but I think its a proper solution. Addresses-Sourceforge-Bug: #1935847 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib/ext2fs/res_gdt.c')
-rw-r--r--lib/ext2fs/res_gdt.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/ext2fs/res_gdt.c b/lib/ext2fs/res_gdt.c
index fa72fc93..ef87ab72 100644
--- a/lib/ext2fs/res_gdt.c
+++ b/lib/ext2fs/res_gdt.c
@@ -93,8 +93,9 @@ errcode_t ext2fs_create_resize_inode(ext2_filsys fs)
if (retval)
goto out_inode;
} else {
- blk_t goal = 3 + sb->s_reserved_gdt_blocks +
- fs->desc_blocks + fs->inode_blocks_per_group;
+ blk_t goal = sb->s_first_data_block + fs->desc_blocks +
+ sb->s_reserved_gdt_blocks + 2 +
+ fs->inode_blocks_per_group;
retval = ext2fs_alloc_block(fs, goal, 0, &dindir_blk);
if (retval)