aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNickolai Zeldovich <nickolai@csail.mit.edu>2013-01-08 15:45:31 -0500
committerTheodore Ts'o <tytso@mit.edu>2013-01-08 20:42:26 -0500
commita046da5963649663933cf16d54ca2a892cc1a560 (patch)
tree763f0f4fbe1a9db3b025c37c801a3d9701c86d49
parent6dd83548f4193f8bfd7983240471db0d0c7af626 (diff)
downloade2fsprogs-a046da5963649663933cf16d54ca2a892cc1a560.tar.gz
e2fsprogs-a046da5963649663933cf16d54ca2a892cc1a560.tar.xz
e2fsprogs-a046da5963649663933cf16d54ca2a892cc1a560.zip
e2fsck: avoid memory corruption on ext2fs_open2 failure
In try_open_fs(), if ext2fs_open2() returns an error, do not try to access the struct ext2_filesys. The previous check 'if (ret_fs)' was always true, but even 'if (*ret_fs)' might be incorrect in some cases, so check 'retval==0' instead. Signed-off-by: Nickolai Zeldovich <nickolai@csail.mit.edu> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--e2fsck/unix.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 6471592a..51eeb251 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -1062,7 +1062,7 @@ static errcode_t try_open_fs(e2fsck_t ctx, int flags, io_manager io_ptr,
retval = ext2fs_open2(ctx->filesystem_name, ctx->io_options,
flags, 0, 0, io_ptr, ret_fs);
- if (ret_fs)
+ if (retval == 0)
e2fsck_set_bitmap_type(*ret_fs, EXT2FS_BMAP64_RBTREE,
"default", NULL);
return retval;