From: Theodore Ts'o Date: Fri, 12 Aug 2022 04:08:16 +0000 (-0400) Subject: libext2fs: avoid NULL dereference if the root file system isn't in /etc/mtab X-Git-Tag: v1.47.0~26 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d5aba8e5d349272eb221e2aab3775bb942f89684;p=thirdparty%2Fe2fsprogs.git libext2fs: avoid NULL dereference if the root file system isn't in /etc/mtab Addresses-Coverity-Bug: 1497609 Signed-off-by: Theodore Ts'o --- 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: