From: Tim Kientzle Date: Sat, 17 Jul 2010 23:23:16 +0000 (-0400) Subject: Virtualize archive_read_next_header(). In particular, attempts to X-Git-Tag: v3.0.0a~913 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a044cc5543722d043c3bc46f9a4ead14b5ae4bcf;p=thirdparty%2Flibarchive.git Virtualize archive_read_next_header(). In particular, attempts to call this on a read_disk handle will fail immediately with a Null pointer dereference instead of trying to run the archive_read implementation, which fails with a much more inscrutable error. SVN-Revision: 2535 --- diff --git a/libarchive/archive_private.h b/libarchive/archive_private.h index 8b96937b7..ab148ee93 100644 --- a/libarchive/archive_private.h +++ b/libarchive/archive_private.h @@ -66,6 +66,8 @@ struct archive_vtable { ssize_t (*archive_write_data_block)(struct archive *, const void *, size_t, int64_t); + int (*archive_read_next_header)(struct archive *, + struct archive_entry **); int (*archive_read_next_header2)(struct archive *, struct archive_entry *); int (*archive_read_data_block)(struct archive *, diff --git a/libarchive/archive_read.c b/libarchive/archive_read.c index 319590c50..81d1abcfb 100644 --- a/libarchive/archive_read.c +++ b/libarchive/archive_read.c @@ -68,6 +68,8 @@ static int _archive_read_close(struct archive *); static int _archive_read_data_block(struct archive *, const void **, size_t *, int64_t *); static int _archive_read_free(struct archive *); +static int _archive_read_next_header(struct archive *, + struct archive_entry **); static int _archive_read_next_header2(struct archive *, struct archive_entry *); static int64_t advance_file_pointer(struct archive_read_filter *, int64_t); @@ -84,6 +86,7 @@ archive_read_vtable(void) av.archive_filter_name = _archive_filter_name; av.archive_filter_count = _archive_filter_count; av.archive_read_data_block = _archive_read_data_block; + av.archive_read_next_header = _archive_read_next_header; av.archive_read_next_header2 = _archive_read_next_header2; av.archive_free = _archive_read_free; av.archive_close = _archive_read_close; @@ -500,7 +503,7 @@ _archive_read_next_header2(struct archive *_a, struct archive_entry *entry) } int -archive_read_next_header(struct archive *_a, struct archive_entry **entryp) +_archive_read_next_header(struct archive *_a, struct archive_entry **entryp) { int ret; struct archive_read *a = (struct archive_read *)_a; diff --git a/libarchive/archive_virtual.c b/libarchive/archive_virtual.c index 96982c86f..58be92fad 100644 --- a/libarchive/archive_virtual.c +++ b/libarchive/archive_virtual.c @@ -126,6 +126,12 @@ archive_write_data_block(struct archive *a, const void *buff, size_t s, int64_t return ((a->vtable->archive_write_data_block)(a, buff, s, o)); } +int +archive_read_next_header(struct archive *a, struct archive_entry **entry) +{ + return ((a->vtable->archive_read_next_header)(a, entry)); +} + int archive_read_next_header2(struct archive *a, struct archive_entry *entry) {