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

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