]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Hygiene, set unconsumed slot exactly once for each branch
authorSebastian Freundt <freundt@ga-group.nl>
Tue, 10 Jun 2014 12:46:32 +0000 (12:46 +0000)
committerSebastian Freundt <freundt@ga-group.nl>
Tue, 10 Jun 2014 12:53:19 +0000 (12:53 +0000)
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.

libarchive/archive_read_support_format_warc.c

index b032e57c71f649e2bb7c7d79a3229cfa7962041d..b4875a5f79033daacd8b30e4d93edea9bf4e22d5 100644 (file)
@@ -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);
        }