]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fsck.cramfs: fix crash when superblock size is too small
authorRuediger Meier <ruediger.meier@ga-group.nl>
Tue, 23 Jan 2018 15:59:23 +0000 (16:59 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 24 Jan 2018 11:53:31 +0000 (12:53 +0100)
This hopefully fixes the original problem addressed by the reverted
patch 7cb962c7.

The bug was introduced by myself in
    f991dbd3 "fsck.cramfs: allow smaller superblock sizes"

CC: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
disk-utils/fsck.cramfs.c
tests/expected/cramfs/fsck-bad-header
tests/ts/cramfs/fsck-bad-header

index 50c7d33b9e0d8a30da2e130124307e2eb75cbf97..820816b14d3be2f9acdf1b8813a72e1740582b2f 100644 (file)
@@ -192,7 +192,7 @@ static void test_super(int *start, size_t * length)
                errx(FSCK_EX_ERROR, _("unsupported filesystem features"));
 
        /* What are valid superblock sizes? */
-       if (super.size < sizeof(struct cramfs_super))
+       if (super.size < *start + sizeof(struct cramfs_super))
                errx(FSCK_EX_UNCORRECTED, _("superblock size (%d) too small"),
                     super.size);
 
index ade8a9c3a401b9250327a0858232edb5c3e0e3d2..41c2c125ec4dfc1cc1f1c98b0fa93ecbce1ebf9f 100644 (file)
@@ -1,2 +1 @@
-fsck.cramfs: file extends past end of filesystem
-fsck.cramfs: crc error
+fsck.cramfs: superblock size (76) too small
index 8d5309c35228842a57d293ed3b1f5d4a1b3b1f14..add3885774ae31296a97313cfe3ca5d50dd955ac 100755 (executable)
@@ -16,7 +16,7 @@
 # GNU General Public License for more details.
 #
 TS_TOPDIR="${0%/*}/../.."
-TS_DESC="fsck endianness"
+TS_DESC="fsck bad header"
 
 . $TS_TOPDIR/functions.sh
 ts_init "$*"