[PATCH] fix size calculation when mkfs is pointed at a regular file

Eric Sandeen <[email protected]> Wed, 16 Aug 2006 18:32:49 -0500
Newsgroups gmane.comp.file-systems.ext2.devel
Message-ID <[email protected]>
stat64 could overflow the retblocks container when 1k blocks come in by default
for a very large device.

Signed-off-by: Eric Sandeen <[email protected]>

Index: e2fsprogs-1.39-test/lib/ext2fs/getsize.c
===================================================================
--- e2fsprogs-1.39-test.orig/lib/ext2fs/getsize.c
+++ e2fsprogs-1.39-test/lib/ext2fs/getsize.c
@@ -250,6 +250,11 @@ errcode_t ext2fs_get_device_size(const c
 		if (fstat(fd, &st) == 0)
 #endif
 			if (S_ISREG(st.st_mode)) {
+				if ((sizeof(*retblocks) < sizeof(unsigned long long)) &&
+				    ((st.st_size / blocksize) > 0xFFFFFFFF)) {
+					rc = EFBIG;
+					goto out;
+				}
 				*retblocks = st.st_size / blocksize;
 				goto out;
 			}



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642