From: Ruediger Meier <ruediger.meier@xxxxxxxxxxx> errno is invalid in case that we just read(3) too short. Signed-off-by: Ruediger Meier <ruediger.meier@xxxxxxxxxxx> --- disk-utils/fsck.cramfs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c index 820816b14..2a4f75a8c 100644 --- a/disk-utils/fsck.cramfs.c +++ b/disk-utils/fsck.cramfs.c @@ -226,10 +226,15 @@ static void test_crc(int start) mmap(NULL, super.size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (buf != MAP_FAILED) { + ssize_t tmp; if (lseek(fd, 0, SEEK_SET) == (off_t) -1) err(FSCK_EX_ERROR, _("seek on %s failed"), filename); - if (read(fd, buf, super.size) != (ssize_t) super.size) + tmp = read(fd, buf, super.size); + if (tmp < 0) err(FSCK_EX_ERROR, _("cannot read %s"), filename); + if (tmp != (ssize_t) super.size) + errx(FSCK_EX_ERROR, _("failed to read %"PRIu32" bytes from file %s"), + super.size, filename); } } if (buf != MAP_FAILED) { -- 2.13.6 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html