From 394043b98d56e1d72715106fd63df9796e4dad9e Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Sun, 21 Jun 2009 13:10:46 -0400 Subject: [PATCH] Clear error buffer on entry to archive_read_open2(). Limit options setting to archives that have not yet been opened. SVN-Revision: 1177 --- libarchive/archive_read.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libarchive/archive_read.c b/libarchive/archive_read.c index f24e2c278..12df0bd06 100644 --- a/libarchive/archive_read.c +++ b/libarchive/archive_read.c @@ -121,6 +121,9 @@ archive_read_set_format_options(struct archive *_a, const char *s) size_t i; int len, r; + __archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, + "archive_read_set_format_options"); + if (s == NULL || *s == '\0') return (ARCHIVE_OK); a = (struct archive_read *)_a; @@ -165,6 +168,9 @@ archive_read_set_filter_options(struct archive *_a, const char *s) char key[64], val[64]; int len, r; + __archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, + "archive_read_set_filter_options"); + if (s == NULL || *s == '\0') return (ARCHIVE_OK); a = (struct archive_read *)_a; @@ -206,6 +212,10 @@ archive_read_set_options(struct archive *_a, const char *s) { int r; + __archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, + "archive_read_set_options"); + archive_clear_error(&a->archive); + r = archive_read_set_format_options(_a, s); if (r != ARCHIVE_OK) return (r); @@ -290,6 +300,7 @@ archive_read_open2(struct archive *_a, void *client_data, __archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, "archive_read_open"); + archive_clear_error(&a->archive); if (client_reader == NULL) __archive_errx(1, -- 2.47.3