From d5aba8e5d349272eb221e2aab3775bb942f89684 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 12 Aug 2022 00:08:16 -0400 Subject: [PATCH] libext2fs: avoid NULL dereference if the root file system isn't in /etc/mtab Addresses-Coverity-Bug: 1497609 Signed-off-by: Theodore Ts'o --- lib/ext2fs/ismounted.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c index c73273b84..f4fcdfd02 100644 --- a/lib/ext2fs/ismounted.c +++ b/lib/ext2fs/ismounted.c @@ -208,9 +208,10 @@ is_root: (void) unlink(TEST_FILE); } - if (!strcmp(mnt->mnt_type, "ext4") || - !strcmp(mnt->mnt_type, "ext3") || - !strcmp(mnt->mnt_type, "ext2")) + if (mnt && mnt->mnt_type && + (!strcmp(mnt->mnt_type, "ext4") || + !strcmp(mnt->mnt_type, "ext3") || + !strcmp(mnt->mnt_type, "ext2"))) *mount_flags |= EXT2_MF_EXTFS; retval = 0; errout: -- 2.47.3