]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
resize2fs: sanity check the free blocks and inode counts
authorTheodore Ts'o <tytso@mit.edu>
Sun, 23 Jul 2017 04:46:36 +0000 (00:46 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 23 Jul 2017 04:46:36 +0000 (00:46 -0400)
If the free block or free inodes count are larger than the number of
blocks or inodes in the system, request that the file system be
checked.  Otherwise it's possible for calcuate_minimum_resize_size()
to hang in an infinite loop.

This problem was found using American Fuzzy Lop.

Reported-by: Adam Buchbinder <abuchbinder@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
resize/main.c

index 396391b68520b9b69b9f39cb8a2c972a2a28b978..ab7375c172af4ecaf944b13805991afd3bd6610e 100644 (file)
@@ -440,6 +440,10 @@ int main (int argc, char ** argv)
                    !print_min_size)
                        checkit = 1;
 
+               if ((fs->super->s_free_blocks_count > fs->super->s_blocks_count) ||
+                   (fs->super->s_free_inodes_count > fs->super->s_inodes_count))
+                       checkit = 1;
+
                if (checkit) {
                        fprintf(stderr,
                                _("Please run 'e2fsck -f %s' first.\n\n"),