From: Darrick J. Wong Date: Mon, 8 Sep 2014 23:11:49 +0000 (-0700) Subject: libext2fs: report bad magic over bad sb checksum X-Git-Tag: v1.43-WIP-2015-05-18~207 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f92c600c09bbda482c6c4a37602db4f0db864a9e;p=thirdparty%2Fe2fsprogs.git libext2fs: report bad magic over bad sb checksum We don't want ext2fs_open2() to report bad sb checksum on something that's not even an ext* superblock. This apparently happens pretty easily if we try to open an XFS filesystem. Thus, make it so that a bad magic number code always trumps the sb checksum error code. Signed-off-by: Darrick J. Wong Signed-off-by: Theodore Ts'o --- diff --git a/lib/ext2fs/openfs.c b/lib/ext2fs/openfs.c index 00320f34c..1d6f147c6 100644 --- a/lib/ext2fs/openfs.c +++ b/lib/ext2fs/openfs.c @@ -221,8 +221,6 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, retval = EXT2_ET_UNKNOWN_CSUM; if (!ext2fs_superblock_csum_verify(fs, fs->super)) retval = EXT2_ET_SB_CSUM_INVALID; - if (retval) - goto cleanup; } #ifdef WORDS_BIGENDIAN @@ -235,10 +233,11 @@ errcode_t ext2fs_open2(const char *name, const char *io_options, } #endif - if (fs->super->s_magic != EXT2_SUPER_MAGIC) { + if (fs->super->s_magic != EXT2_SUPER_MAGIC) retval = EXT2_ET_BAD_MAGIC; + if (retval) goto cleanup; - } + if (fs->super->s_rev_level > EXT2_LIB_CURRENT_REV) { retval = EXT2_ET_REV_TOO_HIGH; goto cleanup;