From: Sebastian Freundt Date: Wed, 21 May 2014 15:18:41 +0000 (+0000) Subject: Fix, actually consume data between calls to _warc_read() X-Git-Tag: v3.1.900a~295^2^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb3e79b342a584ee6802e958f20bca03f34089a1;p=thirdparty%2Flibarchive.git Fix, actually consume data between calls to _warc_read() --- diff --git a/libarchive/archive_read_support_format_warc.c b/libarchive/archive_read_support_format_warc.c index d138a3549..926847bb7 100644 --- a/libarchive/archive_read_support_format_warc.c +++ b/libarchive/archive_read_support_format_warc.c @@ -87,6 +87,8 @@ struct warc_s { size_t cntlen; /* and how much we've processed so far */ size_t cntoff; + /* and how much we need to consume between calls */ + size_t unconsumed; /* string pool */ warc_strbuf_t pool; @@ -297,6 +299,11 @@ _warc_read(struct archive_read *a, const void **buf, size_t *bsz, int64_t *off) const char *rab; ssize_t nrd; + if (w->unconsumed) { + __archive_read_consume(a, w->unconsumed); + w->unconsumed = 0U; + } + if (w->cntoff >= w->cntlen) { eof: /* it's our lucky day, no work, we can leave early */ @@ -322,6 +329,7 @@ _warc_read(struct archive_read *a, const void **buf, size_t *bsz, int64_t *off) *buf = rab; w->cntoff += nrd; + w->unconsumed = (size_t)nrd; return (ARCHIVE_OK); }