Whamcloud - gitweb
LU-13197 e2fsck: fix e2fsck_allocate_memory() overflow
e2fsck_allocate_memory() takes an "unsigned int size" argument, which
will overflow for allocations above 4GB. This happens for dir_info
and dx_dir_info arrays when there are more than 350M directories in a
filesystem, and for the dblist array above 180M directories.
Also, in some places inode numbers are "int" instead of "ext2_ino_t",
which can also cause problems with the array size calculations, and
makes it hard to identify where inode numbers are used.
Fix e2fsck_allocate_memory() to take an "unsigned long" argument so
that it can do single memory allocations larger than 4GB. Change
variables that hold inode numbers to be ext2_ino_t, and print them as
unsigned values instead of signed.
There is also a risk of overflow during the binary search in both
e2fsck_get_dir_info() and e2fsck_get_dx_dir_info() when the midpoint
of the array is calculated, if there would be more than 2B directories
in the filesystem and working above the half way point.
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: If6624feb391be2ebf2ddfa46f62a0d2b3f3ebbe5
Reviewed-on: https://review.whamcloud.com/37423
Reviewed-by: Wang Shilong <wshilong@ddn.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>