From: Tim Kientzle Date: Sun, 21 Jun 2009 17:10:46 +0000 (-0400) Subject: Clear error buffer on entry to archive_read_open2(). X-Git-Tag: v2.8.0~574 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=394043b98d56e1d72715106fd63df9796e4dad9e;p=thirdparty%2Flibarchive.git Clear error buffer on entry to archive_read_open2(). Limit options setting to archives that have not yet been opened. SVN-Revision: 1177 --- 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,