Whamcloud - gitweb
getsize.c (ext2fs_get_device_size): Check to see if the number
authorTheodore Ts'o <tytso@mit.edu>
Sat, 19 Mar 2005 01:11:59 +0000 (20:11 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 19 Mar 2005 01:11:59 +0000 (20:11 -0500)
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
lib/ext2fs/getsize.c

index 9de84c4..4b2cfb9 100644 (file)
@@ -1,3 +1,10 @@
+2005-03-18  Theodore Ts'o  <tytso@mit.edu>
+
+       * 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  <tytso@mit.edu>
 
        * Release of E2fsprogs 1.36
index ad7ac1c..0c7355f 100644 (file)
@@ -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;
 }