fsck.cramfs: fix crash when superblock size is too small

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>
This commit is contained in:
Ruediger Meier 2018-01-23 16:59:23 +01:00 committed by Karel Zak
parent 919e372da8
commit 2374b1ab75
3 changed files with 3 additions and 4 deletions

View 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);

View File

@ -1,2 +1 @@
fsck.cramfs: file extends past end of filesystem
fsck.cramfs: crc error
fsck.cramfs: superblock size (76) too small

View File

@ -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 "$*"