]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - disk-utils/fsck.cramfs.c
agetty: fix output of escaped characters
[thirdparty/util-linux.git] / disk-utils / fsck.cramfs.c
index 50c7d33b9e0d8a30da2e130124307e2eb75cbf97..0d9bdadf779f25846888b34337d49ac83c6977ee 100644 (file)
@@ -47,7 +47,7 @@
 
 /* We don't use our include/crc32.h, but crc32 from zlib!
  *
- * The zlib implemenation performs pre/post-conditioning. The util-linux
+ * The zlib implementation performs pre/post-conditioning. The util-linux
  * imlemenation requires post-conditioning (xor) in the applications.
  */
 #include <zlib.h>
@@ -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);
 
@@ -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) {