diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libarchive/archive_read.c | 2 | ||||
-rw-r--r-- | lib/libarchive/test/read_open_memory.c | 28 | ||||
-rw-r--r-- | lib/libarchive/test/test.h | 2 | ||||
-rw-r--r-- | lib/libarchive/test/test_read_pax_truncated.c | 2 |
4 files changed, 31 insertions, 3 deletions
diff --git a/lib/libarchive/archive_read.c b/lib/libarchive/archive_read.c index 552dec8..ddaf686 100644 --- a/lib/libarchive/archive_read.c +++ b/lib/libarchive/archive_read.c @@ -234,6 +234,8 @@ static int64_t client_skip_proxy(struct archive_read_filter *self, int64_t request) { int64_t r; + if (self->archive->client.skipper == NULL) + return (0); r = (self->archive->client.skipper)(&self->archive->archive, self->data, request); self->archive->archive.raw_position += r; diff --git a/lib/libarchive/test/read_open_memory.c b/lib/libarchive/test/read_open_memory.c index bae26b9..312e9ad 100644 --- a/lib/libarchive/test/read_open_memory.c +++ b/lib/libarchive/test/read_open_memory.c @@ -54,10 +54,30 @@ static ssize_t memory_read_skip(struct archive *, void *, size_t request); static off_t memory_read_skip(struct archive *, void *, off_t request); #endif static ssize_t memory_read(struct archive *, void *, const void **buff); +static int read_open_memory_internal(struct archive *a, void *buff, + size_t size, size_t read_size, int fullapi); + int read_open_memory(struct archive *a, void *buff, size_t size, size_t read_size) { + return read_open_memory_internal(a, buff, size, read_size, 1); +} + +/* + * As above, but don't register any optional part of the API, to verify + * that internals work correctly with just the minimal entry points. + */ +int +read_open_memory2(struct archive *a, void *buff, size_t size, size_t read_size) +{ + return read_open_memory_internal(a, buff, size, read_size, 0); +} + +static int +read_open_memory_internal(struct archive *a, void *buff, + size_t size, size_t read_size, int fullapi) +{ struct read_memory_data *mine; mine = (struct read_memory_data *)malloc(sizeof(*mine)); @@ -71,8 +91,12 @@ read_open_memory(struct archive *a, void *buff, size_t size, size_t read_size) mine->read_size = read_size; mine->copy_buff_size = read_size + 64; mine->copy_buff = malloc(mine->copy_buff_size); - return (archive_read_open2(a, mine, memory_read_open, - memory_read, memory_read_skip, memory_read_close)); + if (fullapi) + return (archive_read_open2(a, mine, memory_read_open, + memory_read, memory_read_skip, memory_read_close)); + else + return (archive_read_open2(a, mine, NULL, + memory_read, NULL, NULL)); } /* diff --git a/lib/libarchive/test/test.h b/lib/libarchive/test/test.h index 34ee9f2..678910a 100644 --- a/lib/libarchive/test/test.h +++ b/lib/libarchive/test/test.h @@ -166,6 +166,8 @@ void extract_reference_file(const char *); /* Special customized read-from-memory interface. */ int read_open_memory(struct archive *, void *, size_t, size_t); +/* "2" version exercises a slightly different set of libarchive APIs. */ +int read_open_memory2(struct archive *, void *, size_t, size_t); /* * ARCHIVE_VERSION_STAMP first appeared in 1.9 and libarchive 2.2.4. diff --git a/lib/libarchive/test/test_read_pax_truncated.c b/lib/libarchive/test/test_read_pax_truncated.c index b30e1d1..d2af2ca 100644 --- a/lib/libarchive/test/test_read_pax_truncated.c +++ b/lib/libarchive/test/test_read_pax_truncated.c @@ -72,7 +72,7 @@ DEFINE_TEST(test_read_pax_truncated) assert((a = archive_read_new()) != NULL); assertA(0 == archive_read_support_format_all(a)); assertA(0 == archive_read_support_compression_all(a)); - assertA(0 == read_open_memory(a, buff, i, 13)); + assertA(0 == read_open_memory2(a, buff, i, 13)); if (i < 1536) { assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae)); |