]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Set a proper error message if we hit end-of-file when
authorTim Kientzle <kientzle@acm.org>
Sat, 7 Feb 2015 06:07:16 +0000 (22:07 -0800)
committerTim Kientzle <kientzle@acm.org>
Sat, 7 Feb 2015 06:07:16 +0000 (22:07 -0800)
trying to read a cpio header.

Suggested by Issue #395, although the actual problem there
seems to have been the same as Issue #394.

libarchive/archive_read_support_format_cpio.c

index e7b3d0c1d8a12c3da16094feca82d990d451b3e7..c2ca85bd3ad9990d126bab6d52a3168529686239 100644 (file)
@@ -866,8 +866,11 @@ header_bin_le(struct archive_read *a, struct cpio *cpio,
 
        /* Read fixed-size portion of header. */
        h = __archive_read_ahead(a, bin_header_size, NULL);
-       if (h == NULL)
+       if (h == NULL) {
+           archive_set_error(&a->archive, 0,
+               "End of file trying to read next cpio header");
            return (ARCHIVE_FATAL);
+       }
 
        /* Parse out binary fields. */
        header = (const unsigned char *)h;
@@ -902,8 +905,11 @@ header_bin_be(struct archive_read *a, struct cpio *cpio,
 
        /* Read fixed-size portion of header. */
        h = __archive_read_ahead(a, bin_header_size, NULL);
-       if (h == NULL)
+       if (h == NULL) {
+           archive_set_error(&a->archive, 0,
+               "End of file trying to read next cpio header");
            return (ARCHIVE_FATAL);
+       }
 
        /* Parse out binary fields. */
        header = (const unsigned char *)h;