]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Virtualize archive_read_next_header(). In particular, attempts to
authorTim Kientzle <kientzle@gmail.com>
Sat, 17 Jul 2010 23:23:16 +0000 (19:23 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sat, 17 Jul 2010 23:23:16 +0000 (19:23 -0400)
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

libarchive/archive_private.h
libarchive/archive_read.c
libarchive/archive_virtual.c

index 8b96937b7ceeead8aee7eb03bf0120f2729f8ee3..ab148ee935f64ae498a982eddb419273029e7a61 100644 (file)
@@ -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 *,
index 319590c50715b266947d6a23cb87c96fa43e5f08..81d1abcfb6bc45e2196ad6232b8fcc83e3f57c51 100644 (file)
@@ -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;
index 96982c86fdeb94a98f604263f4f7b8375a64e24b..58be92fadc038f65c18168b17ac660261d4a6ed1 100644 (file)
@@ -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)
 {