Blame SOURCES/e2fsprogs-1.45.6-libext2fs-fix-crash-when-ext2fs_mmp_stop-is-called-b.patch

a77133
From df34e45c71cff889927a412c6296d02866cdc5cc Mon Sep 17 00:00:00 2001
a77133
From: Theodore Ts'o <tytso@mit.edu>
a77133
Date: Sun, 14 Feb 2021 23:51:45 -0500
a77133
Subject: [PATCH 20/46] libext2fs: fix crash when ext2fs_mmp_stop() is called
a77133
 before MMP is initialized
a77133
Content-Type: text/plain
a77133
a77133
The fatal_error() function in e2fsck can call ext2fs_mmp_stop() on a
a77133
file system where MMP hasn't yet been initialized.  When that happens,
a77133
instead of crashing, have ext2fs_mmp_stop() return success, since mmp
a77133
doesn't need to be stopped if it hasn't even been initialized yet.
a77133
a77133
Addresses-Debian-Bug: #696609
a77133
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
a77133
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
a77133
---
a77133
 lib/ext2fs/mmp.c | 3 ++-
a77133
 1 file changed, 2 insertions(+), 1 deletion(-)
a77133
a77133
diff --git a/lib/ext2fs/mmp.c b/lib/ext2fs/mmp.c
a77133
index 973b9ecd..eddc66a7 100644
a77133
--- a/lib/ext2fs/mmp.c
a77133
+++ b/lib/ext2fs/mmp.c
a77133
@@ -401,7 +401,8 @@ errcode_t ext2fs_mmp_stop(ext2_filsys fs)
a77133
 	errcode_t retval = 0;
a77133
 
a77133
 	if (!ext2fs_has_feature_mmp(fs->super) ||
a77133
-	    !(fs->flags & EXT2_FLAG_RW) || (fs->flags & EXT2_FLAG_SKIP_MMP))
a77133
+	    !(fs->flags & EXT2_FLAG_RW) || (fs->flags & EXT2_FLAG_SKIP_MMP) ||
a77133
+	    (fs->mmp_buf == NULL) || (fs->mmp_cmp == NULL))
a77133
 		goto mmp_error;
a77133
 
a77133
 	retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);
a77133
-- 
a77133
2.35.1
a77133