Skip to content

Commit c3be70e

Browse files
authored
Merge pull request libarchive#2665 from stoeckmann/read_data_sparse
archive_read_data: Handle sparse holes at end of file correctly
2 parents 9bdc5b8 + b1839a2 commit c3be70e

4 files changed

Lines changed: 5 additions & 5 deletions

File tree

libarchive/archive_read.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,9 @@ archive_read_data(struct archive *_a, void *buff, size_t s)
834834
r = archive_read_data_block(a, &read_buf,
835835
&a->read_data_remaining, &a->read_data_offset);
836836
a->read_data_block = read_buf;
837-
if (r == ARCHIVE_EOF)
837+
if (r == ARCHIVE_EOF &&
838+
a->read_data_offset == a->read_data_output_offset &&
839+
a->read_data_remaining == 0)
838840
return (bytes_read);
839841
/*
840842
* Error codes are all negative, so the status

libarchive/archive_read_support_format_rar.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,8 +1117,6 @@ archive_read_format_rar_read_data(struct archive_read *a, const void **buff,
11171117
if (rar->entry_eof || rar->offset_seek >= rar->unp_size) {
11181118
*size = 0;
11191119
*offset = rar->offset;
1120-
if (*offset < rar->unp_size)
1121-
*offset = rar->unp_size;
11221120
return (ARCHIVE_EOF);
11231121
}
11241122

libarchive/archive_read_support_format_warc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ _warc_read(struct archive_read *a, const void **buf, size_t *bsz, int64_t *off)
405405
/* it's our lucky day, no work, we can leave early */
406406
*buf = NULL;
407407
*bsz = 0U;
408-
*off = w->cntoff + 4U/*for \r\n\r\n separator*/;
408+
*off = w->cntoff;
409409
w->unconsumed = 0U;
410410
return (ARCHIVE_EOF);
411411
}

libarchive/archive_read_support_format_xar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ xar_read_data(struct archive_read *a,
930930
abort_read_data:
931931
*buff = NULL;
932932
*size = 0;
933-
*offset = xar->total;
933+
*offset = (int64_t)xar->entry_total;
934934
return (r);
935935
}
936936

0 commit comments

Comments
 (0)