]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
warc: reject truncated file data 3308/head
authordatauwu <datauwu@users.noreply.github.com>
Sun, 19 Jul 2026 17:25:18 +0000 (01:25 +0800)
committerdatauwu <datauwu@users.noreply.github.com>
Sun, 19 Jul 2026 17:35:04 +0000 (01:35 +0800)
Return ARCHIVE_FATAL when EOF is reached before Content-Length.

libarchive/archive_read_support_format_warc.c

index 0491522eba4624826c7ab46bda123a986c291057..50a9c3eae616988651287c10443d48e6ced0b505 100644 (file)
@@ -409,7 +409,6 @@ archive_read_format_warc_read_data(struct archive_read *a, const void **buf,
        }
 
        if (w->cntoff >= w->cntlen) {
-       eof:
                /* No data is available to return for this entry. */
                *buf = NULL;
                *bsz = 0U;
@@ -423,7 +422,9 @@ archive_read_format_warc_read_data(struct archive_read *a, const void **buf,
                /* Propagate the read error. */
                return (int)nrd;
        } else if (nrd == 0) {
-               goto eof;
+               archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+                   "Truncated WARC file data");
+               return (ARCHIVE_FATAL);
        } else if ((int64_t)nrd > w->cntlen - w->cntoff) {
                /* Clamp reads to Content-Length. */
                nrd = w->cntlen - w->cntoff;