Whamcloud - gitweb
e2fsck: drop redundant checks of symlink i_size
authorEric Biggers <ebiggers@google.com>
Sat, 3 Mar 2018 00:59:20 +0000 (16:59 -0800)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 3 Mar 2018 22:10:16 +0000 (17:10 -0500)
e2fsck_pass1_check_symlink() verifies that the symlink inode's i_size is
less than the buffer length (60 for fast symlinks, fs->blocksize for
slow symlinks).  But it also verifies that len == i_size &&
len < buflen, which already implies i_size < buflen.  Thus, remove the
redundant checks of i_size.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
e2fsck/pass1.c

index 6a6c596..3a49e02 100644 (file)
@@ -230,14 +230,10 @@ int e2fsck_pass1_check_symlink(ext2_filsys fs, ext2_ino_t ino,
        }
 
        if (ext2fs_is_fast_symlink(inode)) {
-               if (inode->i_size >= sizeof(inode->i_block))
-                       return 0;
-
                buf = (char *)inode->i_block;
                buflen = sizeof(inode->i_block);
        } else {
-               if ((inode->i_size >= fs->blocksize) ||
-                   (inode->i_block[0] < fs->super->s_first_data_block) ||
+               if ((inode->i_block[0] < fs->super->s_first_data_block) ||
                    (inode->i_block[0] >= ext2fs_blocks_count(fs->super)))
                        return 0;