From 0a68b181c1c1d59a284c9cb524b301d183825099 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sun, 17 May 2009 08:42:52 -0400 Subject: [PATCH] e2fsck: Don't crash if an inode with a bad extent header is not cleared 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" --- e2fsck/pass1.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index 3b05cf2..ea7c6a2 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -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; } -- 1.8.3.1