From fa28baa097ba6c62ce48a22314c4b3295919b997 Mon Sep 17 00:00:00 2001 From: Sebastian Freundt Date: Wed, 21 May 2014 14:10:48 +0000 Subject: [PATCH] fix, request just the bare minimum for a WARC header Moreover, assume a response of less than the bare minimum header length to be the archive's EOF. --- libarchive/archive_read_support_format_warc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libarchive/archive_read_support_format_warc.c b/libarchive/archive_read_support_format_warc.c index 62372a219..0e69d0b3e 100644 --- a/libarchive/archive_read_support_format_warc.c +++ b/libarchive/archive_read_support_format_warc.c @@ -180,7 +180,7 @@ _warc_bid(struct archive_read *a, int best_bid) static int _warc_rdhdr(struct archive_read *a, struct archive_entry *entry) { -#define HDR_PROBE_LEN (512U) +#define HDR_PROBE_LEN (12U) struct warc_s *w = a->format->data; unsigned int ver; const char *buf; @@ -199,13 +199,13 @@ start_over: * and reproduce that functionality here */ buf = __archive_read_ahead(a, HDR_PROBE_LEN, &nrd); - if (nrd < 0 || buf == NULL) { + if (nrd < 0) { /* no good */ archive_set_error( &a->archive, ARCHIVE_ERRNO_MISC, "Bad record header"); return (ARCHIVE_FATAL); - } else if (nrd < 12U) { + } else if (nrd < 12U || buf == NULL) { /* there should be room for at least WARC/bla\r\n * must be EOF therefore */ return (ARCHIVE_EOF); -- 2.47.2