Re: [PATCH] 1/6 Avoid overflows in calculations of groups_count
Eric Sandeen <[email protected]> Wed, 30 Aug 2006 12:01:16 -0500
| Newsgroups | gmane.comp.file-systems.ext2.devel |
|---|---|
| Message-ID | <[email protected]> |
Theodore Tso wrote: > On Wed, Aug 16, 2006 at 03:50:02PM -0500, Eric Sandeen wrote: >> When s_blocks_count is at its maximum value (2^32-1), the way >> groups_count was calculated could overflow; change the arithmetic to >> avoid this. >> >> This is the same calculation that was submitted for the ext3 kernel >> mount code. >> >> Signed-off-by: Eric Sandeen <[email protected]> > > > I created a new inline function, ext2fs_div_ceil(), which is used to > replace the problematic calculations. This makes it easier to audit > the changes, and it turns out it is needed in a lot more places than > just the groups_count calculation. I've taken hopefully all of the > other related fixups from your other patch and bundled them into this > patchset which introduces the use of the div_ceil() function. > > - Ted Looks good, Ted - and I think there's one more: Index: e2fsprogs-1.39/resize/online.c =================================================================== --- e2fsprogs-1.39.orig/resize/online.c +++ e2fsprogs-1.39/resize/online.c @@ -59,8 +59,7 @@ errcode_t online_resize_fs(ext2_filsys f exit(1); } - r_frac = ((100 * sb->s_r_blocks_count) + sb->s_blocks_count-1) / - sb->s_blocks_count; + r_frac = ext2fs_div_ceil(100 * sb->s_r_blocks_count, sb->s_blocks_count); retval = ext2fs_read_bitmaps(fs); if (retval) -Eric ------------------------------------------------------------------------- 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