From: Sebastian Freundt Date: Tue, 10 Jun 2014 12:46:32 +0000 (+0000) Subject: Hygiene, set unconsumed slot exactly once for each branch X-Git-Tag: v3.1.900a~295^2^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=adc91b6969e260908041a1013a01e9da3bfc7966;p=thirdparty%2Flibarchive.git Hygiene, set unconsumed slot exactly once for each branch in _warc_read(). Also kick __archive_read_consume() because the writer will consume the bytes for us. So for the EOF case, set unconsumed to 0, for the non-EOF case set unconsumed to the minimum of the number of bytes read and the content length. --- diff --git a/libarchive/archive_read_support_format_warc.c b/libarchive/archive_read_support_format_warc.c index b032e57c7..b4875a5f7 100644 --- a/libarchive/archive_read_support_format_warc.c +++ b/libarchive/archive_read_support_format_warc.c @@ -326,17 +326,13 @@ _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 */ *buf = NULL; *bsz = 0U; - *off = w->cntoff; + *off = w->cntoff + 4U/*for \r\n\r\n separator*/; + w->unconsumed = 0U; return (ARCHIVE_EOF); }