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

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