Re: [PATCH] 2/6 Detect overflows in loop counters
Eric Sandeen <[email protected]> Fri, 18 Aug 2006 14:47:14 -0500
| Newsgroups | gmane.comp.file-systems.ext2.devel |
|---|---|
| Message-ID | <[email protected]> |
Mingming Cao wrote: > On Fri, 2006-08-18 at 12:45 -0500, Eric Sandeen wrote: >> Mingming Cao wrote: >> How much do we want to intermix full 32-bit fixes with the 64-bit >> changes? All at once or step by step? Step by step seems like a safer >> approach, though it probably means reworking some of the 64-bit patches >> (I'll sign up to do that work if 32-bit stuff goes in first...) >> > > Either way is fine with me ... > > But I think making the loop counter to unsigned value seems more > straightforward than keep it as int type, and adding a check of < 0 in > the end condition. Well, the loop counters already -are- unsigned in these cases, via a typedef usually. The issue is that if the loop tests that the counter is "<= <value>", where <value> is using all the bits in the type (say 2^32-1 blocks....) then the test can never be false, and the loop will run forever w/o the extra "&& counter > <something>" to detect a wraparound. -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