Whamcloud - gitweb
Detect overflows in loop counters
authorEric Sandeen <esandeen@redhat.com>
Wed, 30 Aug 2006 06:16:55 +0000 (02:16 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 30 Aug 2006 06:16:55 +0000 (02:16 -0400)
commit5830d6be9c33e23bb20c339036083e6e4fa6795e
treee896bdb9499e533e0a89d11d7f652ab4bd32ffea
parent57d7bb7b087d93d67623e260c1380afed1665e24
Detect overflows in loop counters

For loops such as:

for (i=1; i <= fs->super->s_blocks_count; i++) {
        <do_stuff>
}

if i is an int and s_blocks_count is (2^32-1), the condition is never false.
Change these loops to:

for (i=1; i <= fs->super->s_blocks_count && i > 0; i++) {
        <do_stuff>
}

to stop the loop when we overflow i

Signed-off-by: Eric Sandeen <esandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck/ChangeLog
e2fsck/pass4.c
e2fsck/pass5.c
lib/ext2fs/ChangeLog
lib/ext2fs/bitmaps.c
resize/ChangeLog
resize/resize2fs.c