]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libext2fs: avoid NULL dereference if the root file system isn't in /etc/mtab
authorTheodore Ts'o <tytso@mit.edu>
Fri, 12 Aug 2022 04:08:16 +0000 (00:08 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 12 Aug 2022 04:08:16 +0000 (00:08 -0400)
Addresses-Coverity-Bug: 1497609
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/ismounted.c

index c73273b84344166cf9a9b98cd0d29a330118543a..f4fcdfd02cc4893dcb12fc1c073e8c8b1e40a039 100644 (file)
@@ -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: