Whamcloud - gitweb
e2fsck: Don't crash if an inode with a bad extent header is not cleared
authorTheodore Ts'o <tytso@mit.edu>
Sun, 17 May 2009 12:42:52 +0000 (08:42 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 17 May 2009 12:42:52 +0000 (08:42 -0400)
If ext2fs_extent_open() fails due to a corrupt extent header, and the
user declines to clear the inode, check_blocks_extents() should bail
out; otherwise, it will cause a core dump due a null pointer
dereference.

Addresses-Sourceforge-Bug: #2791794

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
e2fsck/pass1.c

index 3b05cf2..ea7c6a2 100644 (file)
@@ -1770,9 +1770,10 @@ static void check_blocks_extents(e2fsck_t ctx, struct problem_context *pctx,
        errcode_t               retval;
 
        pctx->errcode = ext2fs_extent_open(fs, ino, &ehandle);
-       if (pctx->errcode &&
-           fix_problem(ctx, PR_1_READ_EXTENT, pctx)) {
-               e2fsck_clear_inode(ctx, ino, inode, 0, "check_blocks_extents");
+       if (pctx->errcode) {
+               if (fix_problem(ctx, PR_1_READ_EXTENT, pctx))
+                       e2fsck_clear_inode(ctx, ino, inode, 0,
+                                          "check_blocks_extents");
                pctx->errcode = 0;
                return;
        }