Skip to content

Commit adc91b6

Browse files
committed
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.
1 parent 75b78d5 commit adc91b6

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

libarchive/archive_read_support_format_warc.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,17 +326,13 @@ _warc_read(struct archive_read *a, const void **buf, size_t *bsz, int64_t *off)
326326
const char *rab;
327327
ssize_t nrd;
328328

329-
if (w->unconsumed) {
330-
__archive_read_consume(a, w->unconsumed);
331-
w->unconsumed = 0U;
332-
}
333-
334329
if (w->cntoff >= w->cntlen) {
335330
eof:
336331
/* it's our lucky day, no work, we can leave early */
337332
*buf = NULL;
338333
*bsz = 0U;
339-
*off = w->cntoff;
334+
*off = w->cntoff + 4U/*for \r\n\r\n separator*/;
335+
w->unconsumed = 0U;
340336
return (ARCHIVE_EOF);
341337
}
342338

0 commit comments

Comments
 (0)