From: Sebastian Freundt Date: Wed, 21 May 2014 14:10:48 +0000 (+0000) Subject: fix, request just the bare minimum for a WARC header X-Git-Tag: v3.1.900a~295^2^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa28baa097ba6c62ce48a22314c4b3295919b997;p=thirdparty%2Flibarchive.git 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. --- 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);