From 283df83e7e2559f7190bb7a1dab759ccedac27ab Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 18 Mar 2005 20:11:59 -0500 Subject: [PATCH] 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. --- lib/ext2fs/ChangeLog | 7 +++++++ lib/ext2fs/getsize.c | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) 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; } -- 1.8.3.1