From: Theodore Ts'o Date: Sat, 19 Mar 2005 01:11:59 +0000 (-0500) Subject: getsize.c (ext2fs_get_device_size): Check to see if the number X-Git-Tag: E2FSPROGS-1_37~16 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=283df83e7e2559f7190bb7a1dab759ccedac27ab;p=tools%2Fe2fsprogs.git getsize.c (ext2fs_get_device_size): Check to see if the number of blocks is greater than 2**32 when we are doing a binary search to determine the device size. Thanks to Stephen Tweedie for the patch. --- diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 9de84c4..4b2cfb9 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,10 @@ +2005-03-18 Theodore Ts'o + + * getsize.c (ext2fs_get_device_size): Check to see if the number + of blocks is greater than 2**32 when we are doing a binary + search to determine the device size. Thanks to Stephen + Tweedie for the patch. + 2006-02-05 Theodore Ts'o * Release of E2fsprogs 1.36 diff --git a/lib/ext2fs/getsize.c b/lib/ext2fs/getsize.c index ad7ac1c..0c7355f 100644 --- a/lib/ext2fs/getsize.c +++ b/lib/ext2fs/getsize.c @@ -260,7 +260,11 @@ errcode_t ext2fs_get_device_size(const char *file, int blocksize, } valid_offset (fd, 0); close(fd); - *retblocks = (low + 1) / blocksize; + size64 = low + 1; + if ((sizeof(*retblocks) < sizeof(unsigned long long)) + && ((size64 / blocksize) > 0xFFFFFFFF)) + return EFBIG; + *retblocks = size64 / blocksize; return 0; }