diff options
Diffstat (limited to 'archivers/libarchive/files/libarchive')
54 files changed, 458 insertions, 300 deletions
diff --git a/archivers/libarchive/files/libarchive/archive.h b/archivers/libarchive/files/libarchive/archive.h index 6bfe81eb24a..3f9f6e1cf67 100644 --- a/archivers/libarchive/files/libarchive/archive.h +++ b/archivers/libarchive/files/libarchive/archive.h @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/lib/libarchive/archive.h.in,v 1.49 2008/03/14 22:19:50 kientzle Exp $ + * $FreeBSD: src/lib/libarchive/archive.h.in,v 1.50 2008/05/26 17:00:22 kientzle Exp $ */ #ifndef ARCHIVE_H_INCLUDED @@ -112,13 +112,13 @@ extern "C" { * (ARCHIVE_API_VERSION * 1000000 + ARCHIVE_API_FEATURE * 1000) * #endif */ -#define ARCHIVE_VERSION_NUMBER 2005004 +#define ARCHIVE_VERSION_NUMBER 2005005 __LA_DECL int archive_version_number(void); /* * Textual name/version of the library, useful for version displays. */ -#define ARCHIVE_VERSION_STRING "libarchive 2.5.4b" +#define ARCHIVE_VERSION_STRING "libarchive 2.5.5" __LA_DECL const char * archive_version_string(void); #if ARCHIVE_VERSION_NUMBER < 3000000 diff --git a/archivers/libarchive/files/libarchive/archive_endian.h b/archivers/libarchive/files/libarchive/archive_endian.h index 61af4161c37..550be164029 100644 --- a/archivers/libarchive/files/libarchive/archive_endian.h +++ b/archivers/libarchive/files/libarchive/archive_endian.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/lib/libarchive/archive_endian.h,v 1.2 2008/02/26 07:17:47 kientzle Exp $ + * $FreeBSD: src/lib/libarchive/archive_endian.h,v 1.3 2008/05/26 17:00:22 kientzle Exp $ * * Borrowed from FreeBSD's <sys/endian.h> */ diff --git a/archivers/libarchive/files/libarchive/archive_entry.3 b/archivers/libarchive/files/libarchive/archive_entry.3 index e2d4ab11770..9ceb18b7aad 100644 --- a/archivers/libarchive/files/libarchive/archive_entry.3 +++ b/archivers/libarchive/files/libarchive/archive_entry.3 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/lib/libarchive/archive_entry.3,v 1.17 2008/03/14 23:00:53 kientzle Exp $ +.\" $FreeBSD: src/lib/libarchive/archive_entry.3,v 1.18 2008/05/26 17:00:22 kientzle Exp $ .\" .Dd May 12, 2008 .Dt archive_entry 3 diff --git a/archivers/libarchive/files/libarchive/archive_entry.c b/archivers/libarchive/files/libarchive/archive_entry.c index 210685af2b3..69921c309f1 100644 --- a/archivers/libarchive/files/libarchive/archive_entry.c +++ b/archivers/libarchive/files/libarchive/archive_entry.c @@ -24,7 +24,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry.c,v 1.51 2008/03/14 23:19:46 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry.c,v 1.52 2008/05/26 17:00:22 kientzle Exp $"); #ifdef HAVE_SYS_STAT_H #include <sys/stat.h> diff --git a/archivers/libarchive/files/libarchive/archive_entry.h b/archivers/libarchive/files/libarchive/archive_entry.h index f8601b9ee28..ee96c56a79d 100644 --- a/archivers/libarchive/files/libarchive/archive_entry.h +++ b/archivers/libarchive/files/libarchive/archive_entry.h @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/lib/libarchive/archive_entry.h,v 1.26 2008/03/14 23:00:53 kientzle Exp $ + * $FreeBSD: src/lib/libarchive/archive_entry.h,v 1.27 2008/05/26 17:00:22 kientzle Exp $ */ #ifndef ARCHIVE_ENTRY_H_INCLUDED diff --git a/archivers/libarchive/files/libarchive/archive_entry_link_resolver.c b/archivers/libarchive/files/libarchive/archive_entry_link_resolver.c index c0770c239de..4deee260d49 100644 --- a/archivers/libarchive/files/libarchive/archive_entry_link_resolver.c +++ b/archivers/libarchive/files/libarchive/archive_entry_link_resolver.c @@ -24,7 +24,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry_link_resolver.c,v 1.1 2007/12/30 04:58:21 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry_link_resolver.c,v 1.3 2008/06/15 04:31:43 kientzle Exp $"); #ifdef HAVE_SYS_STAT_H #include <sys/stat.h> @@ -181,6 +181,9 @@ archive_entry_linkify(struct archive_entry_linkresolver *res, /* If it has only one link, then we're done. */ if (archive_entry_nlink(*e) == 1) return; + /* Directories never have hardlinks. */ + if (archive_entry_filetype(*e) == AE_IFDIR) + return; switch (res->strategy) { case ARCHIVE_ENTRY_LINKIFY_LIKE_TAR: diff --git a/archivers/libarchive/files/libarchive/archive_entry_private.h b/archivers/libarchive/files/libarchive/archive_entry_private.h index f893fb982ae..0289290b198 100644 --- a/archivers/libarchive/files/libarchive/archive_entry_private.h +++ b/archivers/libarchive/files/libarchive/archive_entry_private.h @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/lib/libarchive/archive_entry_private.h,v 1.3 2008/03/31 06:24:39 kientzle Exp $ + * $FreeBSD: src/lib/libarchive/archive_entry_private.h,v 1.4 2008/05/26 17:00:22 kientzle Exp $ */ #ifndef ARCHIVE_ENTRY_PRIVATE_H_INCLUDED diff --git a/archivers/libarchive/files/libarchive/archive_entry_strmode.c b/archivers/libarchive/files/libarchive/archive_entry_strmode.c index cfe6ae33baa..16cb3f7bb33 100644 --- a/archivers/libarchive/files/libarchive/archive_entry_strmode.c +++ b/archivers/libarchive/files/libarchive/archive_entry_strmode.c @@ -24,7 +24,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry_strmode.c,v 1.3 2008/05/23 04:57:28 cperciva Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_entry_strmode.c,v 1.4 2008/06/15 05:14:01 kientzle Exp $"); #ifdef HAVE_SYS_STAT_H #include <sys/stat.h> @@ -57,6 +57,11 @@ archive_entry_strmode(struct archive_entry *entry) case AE_IFLNK: bp[0] = 'l'; break; case AE_IFSOCK: bp[0] = 's'; break; case AE_IFIFO: bp[0] = 'p'; break; + default: + if (archive_entry_hardlink(entry) != NULL) { + bp[0] = 'h'; + break; + } } for (i = 0; i < 9; i++) diff --git a/archivers/libarchive/files/libarchive/archive_platform.h b/archivers/libarchive/files/libarchive/archive_platform.h index 41fd4e549dc..99dfacc50f5 100644 --- a/archivers/libarchive/files/libarchive/archive_platform.h +++ b/archivers/libarchive/files/libarchive/archive_platform.h @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/lib/libarchive/archive_platform.h,v 1.29 2008/02/19 06:06:13 kientzle Exp $ + * $FreeBSD: src/lib/libarchive/archive_platform.h,v 1.30 2008/05/26 17:00:22 kientzle Exp $ */ /* diff --git a/archivers/libarchive/files/libarchive/archive_read.3 b/archivers/libarchive/files/libarchive/archive_read.3 index dbbe1f7f1e6..13063d917c7 100644 --- a/archivers/libarchive/files/libarchive/archive_read.3 +++ b/archivers/libarchive/files/libarchive/archive_read.3 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/lib/libarchive/archive_read.3,v 1.36 2008/03/10 14:45:29 jkoshy Exp $ +.\" $FreeBSD: src/lib/libarchive/archive_read.3,v 1.37 2008/05/26 17:00:22 kientzle Exp $ .\" .Dd August 19, 2006 .Dt archive_read 3 diff --git a/archivers/libarchive/files/libarchive/archive_read_extract.c b/archivers/libarchive/files/libarchive/archive_read_extract.c index ab01f7df3e2..e1027995ec0 100644 --- a/archivers/libarchive/files/libarchive/archive_read_extract.c +++ b/archivers/libarchive/files/libarchive/archive_read_extract.c @@ -24,7 +24,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_extract.c,v 1.60 2008/01/18 04:53:45 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_extract.c,v 1.61 2008/05/26 17:00:22 kientzle Exp $"); #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_bzip2.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_bzip2.c index e6397df9634..824b0cdeb56 100644 --- a/archivers/libarchive/files/libarchive/archive_read_support_compression_bzip2.c +++ b/archivers/libarchive/files/libarchive/archive_read_support_compression_bzip2.c @@ -25,7 +25,7 @@ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_compression_bzip2.c,v 1.17 2008/02/19 05:44:59 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_compression_bzip2.c,v 1.18 2008/05/26 17:00:22 kientzle Exp $"); #ifdef HAVE_ERRNO_H #include <errno.h> diff --git a/archivers/libarchive/files/libarchive/archive_read_support_compression_program.c b/archivers/libarchive/files/libarchive/archive_read_support_compression_program.c index 206215c897c..4f25d6ed561 100644 --- a/archivers/libarchive/files/libarchive/archive_read_support_compression_program.c +++ b/archivers/libarchive/files/libarchive/archive_read_support_compression_program.c @@ -24,11 +24,11 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_compression_program.c,v 1.2 2007/07/20 01:28:50 kientzle Exp $"); - +__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_compression_program.c,v 1.4 2008/06/15 10:45:57 kientzle Exp $"); /* This capability is only available on POSIX systems. */ -#if !defined(HAVE_PIPE) || !defined(HAVE_VFORK) || !defined(HAVE_FCNTL) +#if !defined(HAVE_PIPE) || !defined(HAVE_FCNTL) || \ + !(defined(HAVE_FORK) || defined(HAVE_VFORK)) /* * On non-Posix systems, allow the program to build, but choke if @@ -177,6 +177,12 @@ restart_read: state->child_in_buf_avail = ret; } + if (state->child_stdin == -1) { + fcntl(state->child_stdout, F_SETFL, 0); + __archive_check_child(state->child_stdin, state->child_stdout); + goto restart_read; + } + do { ret = write(state->child_stdin, state->child_in_buf, state->child_in_buf_avail); @@ -191,7 +197,7 @@ restart_read: goto restart_read; } else if (ret == 0 || (ret == -1 && errno == EPIPE)) { close(state->child_stdin); - state->child_stdout = -1; + state->child_stdin = -1; fcntl(state->child_stdout, F_SETFL, 0); goto restart_read; } else { diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_ar.c b/archivers/libarchive/files/libarchive/archive_read_support_format_ar.c index 15d7e7cfd72..baf80bd62fc 100644 --- a/archivers/libarchive/files/libarchive/archive_read_support_format_ar.c +++ b/archivers/libarchive/files/libarchive/archive_read_support_format_ar.c @@ -26,7 +26,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_ar.c,v 1.9 2008/03/12 21:10:26 kaiw Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_ar.c,v 1.10 2008/05/26 17:00:22 kientzle Exp $"); #ifdef HAVE_SYS_STAT_H #include <sys/stat.h> diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_iso9660.c b/archivers/libarchive/files/libarchive/archive_read_support_format_iso9660.c index e0825a36e1a..481220dd47b 100644 --- a/archivers/libarchive/files/libarchive/archive_read_support_format_iso9660.c +++ b/archivers/libarchive/files/libarchive/archive_read_support_format_iso9660.c @@ -24,7 +24,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_iso9660.c,v 1.25 2008/02/19 06:02:01 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_iso9660.c,v 1.26 2008/05/26 17:00:22 kientzle Exp $"); #ifdef HAVE_ERRNO_H #include <errno.h> diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_mtree.c b/archivers/libarchive/files/libarchive/archive_read_support_format_mtree.c index 72232ed7e03..33597e0de6b 100644 --- a/archivers/libarchive/files/libarchive/archive_read_support_format_mtree.c +++ b/archivers/libarchive/files/libarchive/archive_read_support_format_mtree.c @@ -25,7 +25,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_mtree.c,v 1.5 2008/05/19 18:06:48 cperciva Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_mtree.c,v 1.9 2008/06/21 19:06:37 kientzle Exp $"); #ifdef HAVE_SYS_STAT_H #include <sys/stat.h> @@ -308,7 +308,7 @@ process_global_unset(struct archive_read *a, size_t len; line += 6; - if ((next = strchr(line, '=')) != NULL) { + if (strchr(line, '=') != NULL) { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "/unset shall not contain `='"); return ARCHIVE_FATAL; @@ -663,7 +663,8 @@ parse_file(struct archive_read *a, struct archive_entry *entry, *use_next = 1; } /* Don't hold a non-regular file open. */ - close(mtree->fd); + if (mtree->fd >= 0) + close(mtree->fd); mtree->fd = -1; st = NULL; return r; @@ -759,7 +760,7 @@ parse_device(struct archive *a, struct archive_entry *entry, char *val) } ++comma1; comma2 = strchr(comma1, ','); - if (comma1 == NULL) { + if (comma2 == NULL) { archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT, "Malformed device attribute"); return (ARCHIVE_WARN); @@ -1019,7 +1020,7 @@ skip(struct archive_read *a) } /* - * Since parsing octal escapes always makes strings shorter, + * Since parsing backslash sequences always makes strings shorter, * we can always do this conversion in-place. */ static void @@ -1040,13 +1041,57 @@ parse_escapes(char *src, struct mtree_entry *mentry) if (c == '/' && mentry != NULL) mentry->full = 1; if (c == '\\') { - if (src[0] >= '0' && src[0] <= '3' - && src[1] >= '0' && src[1] <= '7' - && src[2] >= '0' && src[2] <= '7') { - c = (src[0] - '0') << 6; - c |= (src[1] - '0') << 3; - c |= (src[2] - '0'); - src += 3; + switch (src[0]) { + case '0': + if (src[1] < '0' || src[1] > '7') { + c = 0; + ++src; + break; + } + /* FALLTHROUGH */ + case '1': + case '2': + case '3': + if (src[1] >= '0' && src[1] <= '7' && + src[2] >= '0' && src[2] <= '7') { + c = (src[0] - '0') << 6; + c |= (src[1] - '0') << 3; + c |= (src[2] - '0'); + src += 3; + } + break; + case 'a': + c = '\a'; + ++src; + break; + case 'b': + c = '\b'; + ++src; + break; + case 'f': + c = '\f'; + ++src; + break; + case 'n': + c = '\n'; + ++src; + break; + case 'r': + c = '\r'; + ++src; + break; + case 's': + c = ' '; + ++src; + break; + case 't': + c = '\t'; + ++src; + break; + case 'v': + c = '\v'; + ++src; + break; } } *dest++ = c; @@ -1189,6 +1234,7 @@ readline(struct archive_read *a, struct mtree *mtree, char **start, ssize_t limi const void *t; const char *s; void *p; + char *u; /* Accumulate line in a line buffer. */ for (;;) { @@ -1221,10 +1267,32 @@ readline(struct archive_read *a, struct mtree *mtree, char **start, ssize_t limi total_size += bytes_read; /* Null terminate. */ mtree->line.s[total_size] = '\0'; - /* If we found '\n', clean up and return. */ - if (p != NULL) { - *start = mtree->line.s; - return (total_size); + /* If we found an unescaped '\n', clean up and return. */ + if (p == NULL) + continue; + for (u = mtree->line.s; *u; ++u) { + if (u[0] == '\n') { + *start = mtree->line.s; + return total_size; + } + if (u[0] == '#') { + if (p == NULL) + break; + *start = mtree->line.s; + return total_size; + } + if (u[0] != '\\') + continue; + if (u[1] == '\\') { + ++u; + continue; + } + if (u[1] == '\n') { + memmove(u, u + 1, + total_size - (u - mtree->line.s) + 1); + --total_size; + continue; + } } } } diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c b/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c index 6d7f048a40d..0c2f0077c1e 100644 --- a/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c +++ b/archivers/libarchive/files/libarchive/archive_read_support_format_tar.c @@ -24,7 +24,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_tar.c,v 1.67 2008/03/15 01:43:58 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_tar.c,v 1.69 2008/05/27 04:46:12 kientzle Exp $"); #ifdef HAVE_ERRNO_H #include <errno.h> @@ -2362,7 +2362,7 @@ url_decode(const char *in) if (out == NULL) return (NULL); for (s = in, d = out; *s != '\0'; ) { - if (*s == '%') { + if (s[0] == '%' && s[1] != '\0' && s[2] != '\0') { /* Try to convert % escape */ int digit1 = tohex(s[1]); int digit2 = tohex(s[2]); diff --git a/archivers/libarchive/files/libarchive/archive_read_support_format_zip.c b/archivers/libarchive/files/libarchive/archive_read_support_format_zip.c index a105297ad4f..f04f69bb205 100644 --- a/archivers/libarchive/files/libarchive/archive_read_support_format_zip.c +++ b/archivers/libarchive/files/libarchive/archive_read_support_format_zip.c @@ -24,7 +24,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_zip.c,v 1.22 2008/02/27 06:05:59 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_support_format_zip.c,v 1.24 2008/06/15 05:15:53 kientzle Exp $"); #ifdef HAVE_ERRNO_H #include <errno.h> @@ -564,8 +564,8 @@ archive_read_format_zip_read_data(struct archive_read *a, */ r = ARCHIVE_FATAL; } else { - /* We know compressed size; just skip it. */ - archive_read_format_zip_read_data_skip(a); + /* We can't decompress this entry, but we will + * be able to skip() it and try the next entry. */ r = ARCHIVE_WARN; } break; @@ -747,6 +747,10 @@ archive_read_format_zip_read_data_skip(struct archive_read *a) zip = (struct zip *)(a->format->data); + /* If we've already read to end of data, we're done. */ + if (zip->end_of_entry_cleanup) + return (ARCHIVE_OK); + /* * If the length is at the end, we have no choice but * to decompress all the data to find the end marker. diff --git a/archivers/libarchive/files/libarchive/archive_string.c b/archivers/libarchive/files/libarchive/archive_string.c index 7c378deead4..21fe5711516 100644 --- a/archivers/libarchive/files/libarchive/archive_string.c +++ b/archivers/libarchive/files/libarchive/archive_string.c @@ -24,7 +24,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_string.c,v 1.11 2007/07/15 19:13:59 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_string.c,v 1.16 2008/06/15 11:28:56 kientzle Exp $"); /* * Basic resizable string support, to simplify manipulating arbitrary-sized @@ -41,14 +41,6 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_string.c,v 1.11 2007/07/15 19:13: #include <wchar.h> #endif -#ifdef __sgi -/* - * The following prototype is missing on IRXI, - * even though the function is implemented in libc. - */ -size_t wcrtomb(char *, wchar_t, mbstate_t *); -#endif - #include "archive_private.h" #include "archive_string.h" @@ -172,14 +164,13 @@ __archive_strappend_int(struct archive_string *as, int d, int base) } /* - * Home-grown wcrtomb for UTF-8. + * Home-grown wctomb for UTF-8. */ -static size_t -my_wcrtomb_utf8(char *p, wchar_t wc, mbstate_t *s) +static int +my_wctomb_utf8(char *p, wchar_t wc) { - (void)s; /* UNUSED */ - if (p == NULL) + /* UTF-8 doesn't use shift states. */ return (0); if (wc <= 0x7f) { p[0] = (char)wc; @@ -208,24 +199,25 @@ my_wcrtomb_utf8(char *p, wchar_t wc, mbstate_t *s) * Awkward point: UTF-8 <-> wchar_t conversions * can actually fail. */ - return ((size_t)-1); + return (-1); } static int my_wcstombs(struct archive_string *as, const wchar_t *w, - size_t (*func)(char *, wchar_t, mbstate_t *)) + int (*func)(char *, wchar_t)) { - size_t n; + int n; char *p; - mbstate_t shift_state; char buff[256]; + /* Clear the shift state before starting. */ + (*func)(NULL, L'\0'); + /* * Convert one wide char at a time into 'buff', whenever that * fills, append it to the string. */ p = buff; - wcrtomb(NULL, L'\0', &shift_state); while (*w != L'\0') { /* Flush the buffer when we have <=16 bytes free. */ /* (No encoding has a single character >16 bytes.) */ @@ -234,8 +226,8 @@ my_wcstombs(struct archive_string *as, const wchar_t *w, archive_strcat(as, buff); p = buff; } - n = (*func)(p, *w++, &shift_state); - if (n == (size_t)-1) + n = (*func)(p, *w++); + if (n == -1) return (-1); p += n; } @@ -251,7 +243,7 @@ my_wcstombs(struct archive_string *as, const wchar_t *w, struct archive_string * __archive_strappend_w_utf8(struct archive_string *as, const wchar_t *w) { - if (my_wcstombs(as, w, my_wcrtomb_utf8)) + if (my_wcstombs(as, w, my_wctomb_utf8)) return (NULL); return (as); } @@ -260,42 +252,40 @@ __archive_strappend_w_utf8(struct archive_string *as, const wchar_t *w) * Translates a wide character string into current locale character set * and appends to the archive_string. Note: returns NULL if conversion * fails. - * - * TODO: use my_wcrtomb_utf8 if !HAVE_WCRTOMB (add configure logic first!) */ struct archive_string * __archive_strappend_w_mbs(struct archive_string *as, const wchar_t *w) { - if (my_wcstombs(as, w, wcrtomb)) +#if HAVE_WCTOMB + if (my_wcstombs(as, w, wctomb)) + return (NULL); +#else + /* TODO: Can we do better than this? Are there platforms + * that have locale support but don't have wctomb()? */ + if (my_wcstombs(as, w, my_wctomb_utf8)) return (NULL); +#endif return (as); } /* - * Home-grown mbrtowc for UTF-8. Some systems lack UTF-8 - * (or even lack mbrtowc()) and we need UTF-8 support for pax + * Home-grown mbtowc for UTF-8. Some systems lack UTF-8 + * (or even lack mbtowc()) and we need UTF-8 support for pax * format. So please don't replace this with a call to the - * standard mbrtowc() function! + * standard mbtowc() function! */ -static size_t -my_mbrtowc_utf8(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) +static int +my_mbtowc_utf8(wchar_t *pwc, const char *s, size_t n) { int ch; - /* - * This argument is here to make the prototype identical to the - * standard mbrtowc(), so I can build generic string processors - * that just accept a pointer to a suitable mbrtowc() function. - */ - (void)ps; /* UNUSED */ - /* Standard behavior: a NULL value for 's' just resets shift state. */ if (s == NULL) return (0); /* If length argument is zero, don't look at the first character. */ if (n <= 0) - return ((size_t)-2); + return (-1); /* * Decode 1-4 bytes depending on the value of the first byte. @@ -310,16 +300,16 @@ my_mbrtowc_utf8(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) } if ((ch & 0xe0) == 0xc0) { if (n < 2) - return ((size_t)-2); - if ((s[1] & 0xc0) != 0x80) return (size_t)-1; + return (-1); + if ((s[1] & 0xc0) != 0x80) return (-1); *pwc = ((ch & 0x1f) << 6) | (s[1] & 0x3f); return (2); } if ((ch & 0xf0) == 0xe0) { if (n < 3) - return ((size_t)-2); - if ((s[1] & 0xc0) != 0x80) return (size_t)-1; - if ((s[2] & 0xc0) != 0x80) return (size_t)-1; + return (-1); + if ((s[1] & 0xc0) != 0x80) return (-1); + if ((s[2] & 0xc0) != 0x80) return (-1); *pwc = ((ch & 0x0f) << 12) | ((s[1] & 0x3f) << 6) | (s[2] & 0x3f); @@ -327,10 +317,10 @@ my_mbrtowc_utf8(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) } if ((ch & 0xf8) == 0xf0) { if (n < 4) - return ((size_t)-2); - if ((s[1] & 0xc0) != 0x80) return (size_t)-1; - if ((s[2] & 0xc0) != 0x80) return (size_t)-1; - if ((s[3] & 0xc0) != 0x80) return (size_t)-1; + return (-1); + if ((s[1] & 0xc0) != 0x80) return (-1); + if ((s[2] & 0xc0) != 0x80) return (-1); + if ((s[3] & 0xc0) != 0x80) return (-1); *pwc = ((ch & 0x07) << 18) | ((s[1] & 0x3f) << 12) | ((s[2] & 0x3f) << 6) @@ -338,7 +328,7 @@ my_mbrtowc_utf8(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) return (4); } /* Invalid first byte. */ - return ((size_t)-1); + return (-1); } /* @@ -350,7 +340,7 @@ __archive_string_utf8_w(struct archive_string *as) { wchar_t *ws, *dest; const char *src; - size_t n; + int n; int err; ws = (wchar_t *)malloc((as->length + 1) * sizeof(wchar_t)); @@ -360,10 +350,10 @@ __archive_string_utf8_w(struct archive_string *as) dest = ws; src = as->s; while (*src != '\0') { - n = my_mbrtowc_utf8(dest, src, 8, NULL); + n = my_mbtowc_utf8(dest, src, 8); if (n == 0) break; - if (n == (size_t)-1 || n == (size_t)-2) { + if (n < 0) { free(ws); return (NULL); } diff --git a/archivers/libarchive/files/libarchive/archive_string.h b/archivers/libarchive/files/libarchive/archive_string.h index 61e70777f19..e59c33af198 100644 --- a/archivers/libarchive/files/libarchive/archive_string.h +++ b/archivers/libarchive/files/libarchive/archive_string.h @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/lib/libarchive/archive_string.h,v 1.10 2008/03/14 22:00:09 kientzle Exp $ + * $FreeBSD: src/lib/libarchive/archive_string.h,v 1.12 2008/06/15 05:11:08 kientzle Exp $ * */ @@ -30,6 +30,9 @@ #define ARCHIVE_STRING_H_INCLUDED #include <stdarg.h> +#ifdef HAVE_STDLIB_H +#include <stdlib.h> /* required for wchar_t on some systems */ +#endif #ifdef HAVE_STRING_H #include <string.h> #endif diff --git a/archivers/libarchive/files/libarchive/archive_util.c b/archivers/libarchive/files/libarchive/archive_util.c index 55dd1fa10c3..7fb46967715 100644 --- a/archivers/libarchive/files/libarchive/archive_util.c +++ b/archivers/libarchive/files/libarchive/archive_util.c @@ -24,7 +24,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_util.c,v 1.17 2008/03/14 22:31:57 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_util.c,v 1.18 2008/05/26 17:00:22 kientzle Exp $"); #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> diff --git a/archivers/libarchive/files/libarchive/archive_write.3 b/archivers/libarchive/files/libarchive/archive_write.3 index fff84f7cddc..14003f43c36 100644 --- a/archivers/libarchive/files/libarchive/archive_write.3 +++ b/archivers/libarchive/files/libarchive/archive_write.3 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/lib/libarchive/archive_write.3,v 1.23 2008/03/10 14:44:41 jkoshy Exp $ +.\" $FreeBSD: src/lib/libarchive/archive_write.3,v 1.24 2008/05/26 17:00:23 kientzle Exp $ .\" .Dd May 11, 2008 .Dt archive_write 3 diff --git a/archivers/libarchive/files/libarchive/archive_write_disk.3 b/archivers/libarchive/files/libarchive/archive_write_disk.3 index f71d7d54854..d68a0ffca3d 100644 --- a/archivers/libarchive/files/libarchive/archive_write_disk.3 +++ b/archivers/libarchive/files/libarchive/archive_write_disk.3 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/lib/libarchive/archive_write_disk.3,v 1.2 2008/03/10 14:44:41 jkoshy Exp $ +.\" $FreeBSD: src/lib/libarchive/archive_write_disk.3,v 1.3 2008/05/26 17:00:23 kientzle Exp $ .\" .Dd March 2, 2007 .Dt archive_write_disk 3 diff --git a/archivers/libarchive/files/libarchive/archive_write_disk.c b/archivers/libarchive/files/libarchive/archive_write_disk.c index 8010c1330ea..238173c42a2 100644 --- a/archivers/libarchive/files/libarchive/archive_write_disk.c +++ b/archivers/libarchive/files/libarchive/archive_write_disk.c @@ -25,7 +25,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.24 2008/03/15 04:20:50 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.26 2008/06/21 19:05:29 kientzle Exp $"); #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> @@ -64,9 +64,6 @@ __FBSDID("$FreeBSD: src/lib/libarchive/archive_write_disk.c,v 1.24 2008/03/15 04 #ifdef HAVE_LINUX_FS_H #include <linux/fs.h> /* for Linux file flags */ #endif -#ifdef HAVE_LINUX_EXT2_FS_H -#include <linux/ext2_fs.h> /* for Linux file flags */ -#endif #ifdef HAVE_LIMITS_H #include <limits.h> #endif @@ -613,8 +610,8 @@ _archive_write_finish_entry(struct archive *_a) /* Restore metadata. */ /* - * Look up the "real" UID only if we're going to need it. We - * need this for TODO_SGID because chown() requires both. + * Look up the "real" UID only if we're going to need it. + * TODO: the TODO_SGID condition can be dropped here, can't it? */ if (a->todo & (TODO_OWNER | TODO_SUID | TODO_SGID)) { a->uid = a->lookup_uid(a->lookup_uid_data, @@ -622,6 +619,7 @@ _archive_write_finish_entry(struct archive *_a) archive_entry_uid(a->entry)); } /* Look up the "real" GID only if we're going to need it. */ + /* TODO: the TODO_SUID condition can be dropped here, can't it? */ if (a->todo & (TODO_OWNER | TODO_SGID | TODO_SUID)) { a->gid = a->lookup_gid(a->lookup_gid_data, archive_entry_gname(a->entry), @@ -1023,7 +1021,10 @@ create_filesystem_object(struct archive_write_disk *a) a->deferred |= (a->todo & TODO_TIMES); a->todo &= ~TODO_TIMES; /* Never use an immediate chmod(). */ - if (mode != final_mode) + /* We can't avoid the chmod() entirely if EXTRACT_PERM + * because of SysV SGID inheritance. */ + if ((mode != final_mode) + || (a->flags & ARCHIVE_EXTRACT_PERM)) a->deferred |= (a->todo & TODO_MODE); a->todo &= ~TODO_MODE; } @@ -1351,7 +1352,7 @@ cleanup_pathname(struct archive_write_disk *a) if (*src == '\0') { archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Invalid empty pathname"); - return (ARCHIVE_WARN); + return (ARCHIVE_FAILED); } /* Skip leading '/'. */ @@ -1382,7 +1383,7 @@ cleanup_pathname(struct archive_write_disk *a) archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Path contains '..'"); - return (ARCHIVE_WARN); + return (ARCHIVE_FAILED); } lastdotdot = 1; } else @@ -1421,7 +1422,7 @@ cleanup_pathname(struct archive_write_disk *a) archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, "Path contains trailing '..'"); - return (ARCHIVE_WARN); + return (ARCHIVE_FAILED); } if (dest == a->name) { /* @@ -1565,8 +1566,8 @@ create_dir(struct archive_write_disk *a, char *path) /* * Note: Although we can skip setting the user id if the desired user * id matches the current user, we cannot skip setting the group, as - * many systems set the gid bit based on the containing directory. So - * we have to perform a chown syscall if we want to restore the SGID + * many systems set the gid based on the containing directory. So + * we have to perform a chown syscall if we want to set the SGID * bit. (The alternative is to stat() and then possibly chown(); it's * more efficient to skip the stat() and just always chown().) Note * that a successful chown() here clears the TODO_SGID_CHECK bit, which diff --git a/archivers/libarchive/files/libarchive/archive_write_set_compression_program.c b/archivers/libarchive/files/libarchive/archive_write_set_compression_program.c index b8b20c86cf9..69c5d428633 100644 --- a/archivers/libarchive/files/libarchive/archive_write_set_compression_program.c +++ b/archivers/libarchive/files/libarchive/archive_write_set_compression_program.c @@ -25,10 +25,12 @@ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_compression_program.c,v 1.1 2007/05/29 01:00:19 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_compression_program.c,v 1.3 2008/06/15 10:45:57 kientzle Exp $"); /* This capability is only available on POSIX systems. */ -#if !defined(HAVE_PIPE) || !defined(HAVE_VFORK) || !defined(HAVE_FCNTL) +#if !defined(HAVE_PIPE) || !defined(HAVE_FCNTL) || \ + !(defined(HAVE_FORK) || defined(HAVE_VFORK)) +#include "archive.h" /* * On non-Posix systems, allow the program to build, but choke if @@ -180,6 +182,12 @@ restart_write: if (ret == -1 && errno != EAGAIN) return (-1); + if (state->child_stdout == -1) { + fcntl(state->child_stdin, F_SETFL, 0); + __archive_check_child(state->child_stdin, state->child_stdout); + goto restart_write; + } + do { ret = read(state->child_stdout, state->child_buf + state->child_buf_avail, diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_ar.c b/archivers/libarchive/files/libarchive/archive_write_set_format_ar.c index 1731844d339..7176e6e2f40 100644 --- a/archivers/libarchive/files/libarchive/archive_write_set_format_ar.c +++ b/archivers/libarchive/files/libarchive/archive_write_set_format_ar.c @@ -26,7 +26,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_ar.c,v 1.6 2008/03/15 11:04:45 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_ar.c,v 1.7 2008/05/26 17:00:23 kientzle Exp $"); #ifdef HAVE_ERRNO_H #include <errno.h> diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_pax.c b/archivers/libarchive/files/libarchive/archive_write_set_format_pax.c index 89f89bc9f54..3e294cdf0a8 100644 --- a/archivers/libarchive/files/libarchive/archive_write_set_format_pax.c +++ b/archivers/libarchive/files/libarchive/archive_write_set_format_pax.c @@ -24,7 +24,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_pax.c,v 1.46 2008/03/15 11:04:45 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_pax.c,v 1.47 2008/05/26 17:00:23 kientzle Exp $"); #ifdef HAVE_ERRNO_H #include <errno.h> diff --git a/archivers/libarchive/files/libarchive/archive_write_set_format_ustar.c b/archivers/libarchive/files/libarchive/archive_write_set_format_ustar.c index 970fee8db1b..8aed25d1f99 100644 --- a/archivers/libarchive/files/libarchive/archive_write_set_format_ustar.c +++ b/archivers/libarchive/files/libarchive/archive_write_set_format_ustar.c @@ -24,7 +24,7 @@ */ #include "archive_platform.h" -__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_ustar.c,v 1.26 2008/03/15 11:04:45 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/archive_write_set_format_ustar.c,v 1.27 2008/05/26 17:00:23 kientzle Exp $"); #ifdef HAVE_ERRNO_H diff --git a/archivers/libarchive/files/libarchive/config_freebsd.h b/archivers/libarchive/files/libarchive/config_freebsd.h index 3d5e821612f..4182b71df47 100644 --- a/archivers/libarchive/files/libarchive/config_freebsd.h +++ b/archivers/libarchive/files/libarchive/config_freebsd.h @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/lib/libarchive/config_freebsd.h,v 1.8 2008/03/15 04:20:50 kientzle Exp $ + * $FreeBSD: src/lib/libarchive/config_freebsd.h,v 1.10 2008/06/15 05:12:47 kientzle Exp $ */ /* FreeBSD 5.0 and later have ACL support. */ @@ -87,8 +87,6 @@ #define HAVE_STRING_H 1 #define HAVE_STRRCHR 1 #define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1 -#define HAVE_STRUCT_STAT_ST_RDEV 1 -#define HAVE_STRUCT_TM_TM_GMTOFF 1 #define HAVE_SYS_ACL_H 1 #define HAVE_SYS_IOCTL_H 1 #define HAVE_SYS_SELECT_H 1 @@ -108,6 +106,7 @@ #define HAVE_WCHAR_H 1 #define HAVE_WCSCPY 1 #define HAVE_WCSLEN 1 +#define HAVE_WCTOMB 1 #define HAVE_WMEMCMP 1 #define HAVE_WMEMCPY 1 #define HAVE_ZLIB_H 1 diff --git a/archivers/libarchive/files/libarchive/config_windows.h b/archivers/libarchive/files/libarchive/config_windows.h index 0ccb2f1b166..e6a6afac505 100644 --- a/archivers/libarchive/files/libarchive/config_windows.h +++ b/archivers/libarchive/files/libarchive/config_windows.h @@ -337,12 +337,6 @@ /* Define to 1 if `st_mtim.tv_nsec' is member of `struct stat'. */
/* #undef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC */
-/* Define to 1 if `st_rdev' is member of `struct stat'. */
-#define HAVE_STRUCT_STAT_ST_RDEV 1
-
-/* Define to 1 if `tm_gmtoff' is member of `struct tm'. */
-/* #undef HAVE_STRUCT_TM_TM_GMTOFF */
-
/* Define to 1 if you have the <sys/acl.h> header file. */
/* #undef HAVE_SYS_ACL_H */
diff --git a/archivers/libarchive/files/libarchive/cpio.5 b/archivers/libarchive/files/libarchive/cpio.5 index 8f024c546a5..f54462818ae 100644 --- a/archivers/libarchive/files/libarchive/cpio.5 +++ b/archivers/libarchive/files/libarchive/cpio.5 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/lib/libarchive/cpio.5,v 1.1 2007/12/30 04:58:22 kientzle Exp $ +.\" $FreeBSD: src/lib/libarchive/cpio.5,v 1.2 2008/05/26 17:00:23 kientzle Exp $ .\" .Dd October 5, 2007 .Dt CPIO 5 diff --git a/archivers/libarchive/files/libarchive/filter_fork.c b/archivers/libarchive/files/libarchive/filter_fork.c index 3c2d829d052..c746a186f52 100644 --- a/archivers/libarchive/files/libarchive/filter_fork.c +++ b/archivers/libarchive/files/libarchive/filter_fork.c @@ -26,9 +26,10 @@ #include "archive_platform.h" /* This capability is only available on POSIX systems. */ -#if defined(HAVE_PIPE) && defined(HAVE_VFORK) && defined(HAVE_FCNTL) +#if defined(HAVE_PIPE) && defined(HAVE_FCNTL) && \ + (defined(HAVE_FORK) || defined(HAVE_VFORK)) -__FBSDID("$FreeBSD: src/lib/libarchive/filter_fork.c,v 1.2 2007/12/30 04:58:22 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/filter_fork.c,v 1.4 2008/06/15 10:45:57 kientzle Exp $"); #if defined(HAVE_POLL) # if defined(HAVE_POLL_H) @@ -75,7 +76,11 @@ __archive_create_child(const char *path, int *child_stdin, int *child_stdout) stdout_pipe[1] = tmp; } +#if HAVE_VFORK switch ((child = vfork())) { +#else + switch ((child = fork())) { +#endif case -1: goto stdout_opened; case 0: @@ -118,23 +123,35 @@ __archive_check_child(int in, int out) { #if defined(HAVE_POLL) struct pollfd fds[2]; + int idx; - fds[0].fd = in; - fds[0].events = POLLOUT; - fds[1].fd = out; - fds[1].events = POLLIN; + idx = 0; + if (in != -1) { + fds[idx].fd = in; + fds[idx].events = POLLOUT; + ++idx; + } + if (out != -1) { + fds[idx].fd = out; + fds[idx].events = POLLIN; + ++idx; + } - poll(fds, 2, -1); /* -1 == INFTIM, wait forever */ + poll(fds, idx, -1); /* -1 == INFTIM, wait forever */ #elif defined(HAVE_SELECT) fd_set fds_in, fds_out, fds_error; FD_ZERO(&fds_in); - FD_SET(out, &fds_in); FD_ZERO(&fds_out); - FD_SET(in, &fds_out); FD_ZERO(&fds_error); - FD_SET(in, &fds_error); - FD_SET(out, &fds_error); + if (out != -1) { + FD_SET(out, &fds_in); + FD_SET(out, &fds_error); + } + if (in != -1) { + FD_SET(in, &fds_out); + FD_SET(in, &fds_error); + } select(in < out ? out + 1 : in + 1, &fds_in, &fds_out, &fds_error, NULL); #else sleep(1); diff --git a/archivers/libarchive/files/libarchive/libarchive-formats.5 b/archivers/libarchive/files/libarchive/libarchive-formats.5 index f570935c824..dd054a93916 100644 --- a/archivers/libarchive/files/libarchive/libarchive-formats.5 +++ b/archivers/libarchive/files/libarchive/libarchive-formats.5 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/lib/libarchive/libarchive-formats.5,v 1.15 2007/12/30 04:58:22 kientzle Exp $ +.\" $FreeBSD: src/lib/libarchive/libarchive-formats.5,v 1.16 2008/05/26 17:00:23 kientzle Exp $ .\" .Dd April 27, 2004 .Dt libarchive-formats 3 diff --git a/archivers/libarchive/files/libarchive/tar.5 b/archivers/libarchive/files/libarchive/tar.5 index c873a938f4b..06873268097 100644 --- a/archivers/libarchive/files/libarchive/tar.5 +++ b/archivers/libarchive/files/libarchive/tar.5 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/lib/libarchive/tar.5,v 1.17 2007/01/09 08:05:56 kientzle Exp $ +.\" $FreeBSD: src/lib/libarchive/tar.5,v 1.18 2008/05/26 17:00:23 kientzle Exp $ .\" .Dd May 20, 2004 .Dt TAR 5 diff --git a/archivers/libarchive/files/libarchive/test/main.c b/archivers/libarchive/files/libarchive/test/main.c index 6e6ca6c8da1..83d3147d9f8 100644 --- a/archivers/libarchive/files/libarchive/test/main.c +++ b/archivers/libarchive/files/libarchive/test/main.c @@ -27,13 +27,13 @@ * Various utility routines useful for test programs. * Each test program is linked against this file. */ +#include "test.h" + #include <errno.h> #include <locale.h> #include <stdarg.h> #include <time.h> -#include "test.h" - /* * This same file is used pretty much verbatim for all test harnesses. * @@ -43,7 +43,7 @@ #define ENVBASE "LIBARCHIVE" /* Prefix for environment variables. */ #define EXTRA_DUMP(x) archive_error_string((struct archive *)(x)) #define EXTRA_VERSION archive_version() -__FBSDID("$FreeBSD: src/lib/libarchive/test/main.c,v 1.11 2008/03/12 05:12:23 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/test/main.c,v 1.13 2008/06/15 10:35:22 kientzle Exp $"); /* * "list.h" is simply created by "grep DEFINE_TEST"; it has @@ -540,6 +540,48 @@ test_assert_equal_file(const char *f1, const char *f2pattern, ...) return (0); } +int +test_assert_file_exists(const char *fpattern, ...) +{ + char f[1024]; + va_list ap; + + va_start(ap, fpattern); + vsprintf(f, fpattern, ap); + va_end(ap); + + if (!access(f, F_OK)) + return (1); + if (!previous_failures(test_filename, test_line)) { + fprintf(stderr, "%s:%d: File doesn't exist\n", + test_filename, test_line); + fprintf(stderr, " file=\"%s\"\n", f); + report_failure(test_extra); + } + return (0); +} + +int +test_assert_file_not_exists(const char *fpattern, ...) +{ + char f[1024]; + va_list ap; + + va_start(ap, fpattern); + vsprintf(f, fpattern, ap); + va_end(ap); + + if (access(f, F_OK)) + return (1); + if (!previous_failures(test_filename, test_line)) { + fprintf(stderr, "%s:%d: File exists and shouldn't\n", + test_filename, test_line); + fprintf(stderr, " file=\"%s\"\n", f); + report_failure(test_extra); + } + return (0); +} + /* assertFileContents() asserts the contents of a file. */ int test_assert_file_contents(const void *buff, int s, const char *fpattern, ...) @@ -669,8 +711,11 @@ static int test_run(int i, const char *tmpdir) { int failures_before = failures; - if (!quiet_flag) + if (!quiet_flag) { printf("%d: %s\n", i, tests[i].name); + fflush(stdout); + } + /* * Always explicitly chdir() in case the last test moved us to * a strange place. diff --git a/archivers/libarchive/files/libarchive/test/test.h b/archivers/libarchive/files/libarchive/test/test.h index dcb190ff3fe..fbbf10a8c3d 100644 --- a/archivers/libarchive/files/libarchive/test/test.h +++ b/archivers/libarchive/files/libarchive/test/test.h @@ -22,7 +22,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/lib/libarchive/test/test.h,v 1.9 2008/03/12 05:12:23 kientzle Exp $ + * $FreeBSD: src/lib/libarchive/test/test.h,v 1.10 2008/06/15 10:35:22 kientzle Exp $ */ /* Every test program should #include "test.h" as the first thing. */ @@ -31,8 +31,18 @@ * The goal of this file (and the matching test.c) is to * simplify the very repetitive test-*.c test programs. */ -#ifndef _FILE_OFFSET_BITS -#define _FILE_OFFSET_BITS 64 +#if defined(HAVE_CONFIG_H) +/* Most POSIX platforms use the 'configure' script to build config.h */ +#include "../../config.h" +#elif defined(__FreeBSD__) +/* Building as part of FreeBSD system requires a pre-built config.h. */ +#include "../config_freebsd.h" +#elif defined(_WIN32) +/* Win32 can't run the 'configure' script. */ +#include "../config_windows.h" +#else +/* Warn if the library hasn't been (automatically or manually) configured. */ +#error Oops: No config.h and no pre-built configuration in test.h. #endif #include <dirent.h> @@ -51,20 +61,6 @@ #include <dmalloc.h> #endif -#if defined(HAVE_CONFIG_H) -/* Most POSIX platforms use the 'configure' script to build config.h */ -#include "../../config.h" -#elif defined(__FreeBSD__) -/* Building as part of FreeBSD system requires a pre-built config.h. */ -#include "../config_freebsd.h" -#elif defined(_WIN32) -/* Win32 can't run the 'configure' script. */ -#include "../config_windows.h" -#else -/* Warn if the library hasn't been (automatically or manually) configured. */ -#error Oops: No config.h and no pre-built configuration in test.h. -#endif - /* No non-FreeBSD platform will have __FBSDID, so just define it here. */ #ifdef __FreeBSD__ #include <sys/cdefs.h> /* For __FBSDID */ @@ -102,6 +98,15 @@ /* Assert that a file is empty; supports printf-style arguments. */ #define assertEmptyFile \ test_setup(__FILE__, __LINE__);test_assert_empty_file +/* Assert that a file exists; supports printf-style arguments. */ +#define assertFileExists \ + test_setup(__FILE__, __LINE__);test_assert_file_exists +/* Assert that a file exists; supports printf-style arguments. */ +#define assertFileNotExists \ + test_setup(__FILE__, __LINE__);test_assert_file_not_exists +/* Assert that file contents match a string; supports printf-style arguments. */ +#define assertFileContents \ + test_setup(__FILE__, __LINE__);test_assert_file_contents /* * This would be simple with C99 variadic macros, but I don't want to @@ -124,6 +129,8 @@ int test_assert_equal_string(const char *, int, const char *v1, const char *, co int test_assert_equal_wstring(const char *, int, const wchar_t *v1, const char *, const wchar_t *v2, const char *, void *); int test_assert_equal_mem(const char *, int, const char *, const char *, const char *, const char *, size_t, const char *, void *); int test_assert_file_contents(const void *, int, const char *, ...); +int test_assert_file_exists(const char *, ...); +int test_assert_file_not_exists(const char *, ...); /* Like sprintf, then system() */ int systemf(const char * fmt, ...); diff --git a/archivers/libarchive/files/libarchive/test/test_acl_pax.c b/archivers/libarchive/files/libarchive/test/test_acl_pax.c index 6ae3dd271f1..1eb3d399a9e 100644 --- a/archivers/libarchive/files/libarchive/test/test_acl_pax.c +++ b/archivers/libarchive/files/libarchive/test/test_acl_pax.c @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_acl_pax.c,v 1.4 2007/07/06 15:43:11 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/test/test_acl_pax.c,v 1.5 2008/05/26 17:00:24 kientzle Exp $"); /* * Exercise the system-independent portion of the ACL support. diff --git a/archivers/libarchive/files/libarchive/test/test_archive_api_feature.c b/archivers/libarchive/files/libarchive/test/test_archive_api_feature.c index 21d189d5876..23a7083c07f 100644 --- a/archivers/libarchive/files/libarchive/test/test_archive_api_feature.c +++ b/archivers/libarchive/files/libarchive/test/test_archive_api_feature.c @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_archive_api_feature.c,v 1.4 2008/03/14 22:31:57 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/test/test_archive_api_feature.c,v 1.5 2008/05/26 17:00:24 kientzle Exp $"); DEFINE_TEST(test_archive_api_feature) { diff --git a/archivers/libarchive/files/libarchive/test/test_entry.c b/archivers/libarchive/files/libarchive/test/test_entry.c index 5ed3278c60b..52820923803 100644 --- a/archivers/libarchive/files/libarchive/test/test_entry.c +++ b/archivers/libarchive/files/libarchive/test/test_entry.c @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_entry.c,v 1.5 2008/03/14 23:19:46 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/test/test_entry.c,v 1.6 2008/05/26 17:00:24 kientzle Exp $"); #include <locale.h> diff --git a/archivers/libarchive/files/libarchive/test/test_link_resolver.c b/archivers/libarchive/files/libarchive/test/test_link_resolver.c index a51e4a4ddc9..8332c4f985b 100644 --- a/archivers/libarchive/files/libarchive/test/test_link_resolver.c +++ b/archivers/libarchive/files/libarchive/test/test_link_resolver.c @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$FreeBSD$"); +__FBSDID("$FreeBSD: src/lib/libarchive/test/test_link_resolver.c,v 1.2 2008/06/15 04:31:43 kientzle Exp $"); static void test_linkify_tar(void) { @@ -68,6 +68,24 @@ static void test_linkify_tar(void) assertEqualInt(0, archive_entry_size(entry)); + /* Dirs should never be matched as hardlinks, regardless. */ + archive_entry_set_pathname(entry, "test3"); + archive_entry_set_nlink(entry, 2); + archive_entry_set_filetype(entry, AE_IFDIR); + archive_entry_set_ino(entry, 3); + archive_entry_set_hardlink(entry, NULL); + archive_entry_linkify(resolver, &entry, &e2); + /* Shouldn't be altered, since it wasn't seen before. */ + assert(e2 == NULL); + assertEqualString("test3", archive_entry_pathname(entry)); + assertEqualString(NULL, archive_entry_hardlink(entry)); + + /* Dir, so it shouldn't get matched. */ + archive_entry_linkify(resolver, &entry, &e2); + assert(e2 == NULL); + assertEqualString("test3", archive_entry_pathname(entry)); + assertEqualString(NULL, archive_entry_hardlink(entry)); + archive_entry_free(entry); archive_entry_linkresolver_free(resolver); } diff --git a/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.c b/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.c index 34c4fc8230f..aad8327431d 100644 --- a/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.c +++ b/archivers/libarchive/files/libarchive/test/test_pax_filename_encoding.c @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_pax_filename_encoding.c,v 1.1 2008/03/15 01:43:59 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/test/test_pax_filename_encoding.c,v 1.2 2008/05/26 17:00:24 kientzle Exp $"); #include <locale.h> diff --git a/archivers/libarchive/files/libarchive/test/test_read_extract.c b/archivers/libarchive/files/libarchive/test/test_read_extract.c index bd42fd0c967..ec8483077c2 100644 --- a/archivers/libarchive/files/libarchive/test/test_read_extract.c +++ b/archivers/libarchive/files/libarchive/test/test_read_extract.c @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_extract.c,v 1.3 2007/05/29 01:00:20 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_extract.c,v 1.4 2008/06/15 10:35:22 kientzle Exp $"); #define BUFF_SIZE 1000000 #define FILE_BUFF_SIZE 100000 @@ -135,12 +135,18 @@ DEFINE_TEST(test_read_extract) #endif /* Test the entries on disk. */ + /* This first entry was extracted with ARCHIVE_EXTRACT_PERM, + * so the permissions should have been restored exactly, + * including resetting the gid bit on those platforms + * where gid is inherited by subdirs. */ assert(0 == stat("dir_0775", &st)); failure("This was 0775 in archive, and should be 0775 on disk"); - assert(st.st_mode == (S_IFDIR | 0775)); + assertEqualInt(st.st_mode, S_IFDIR | 0775); + /* Everything else was extracted without ARCHIVE_EXTRACT_PERM, + * so there may be some sloppiness about gid bits on directories. */ assert(0 == stat("file", &st)); failure("st.st_mode=%o should be %o", st.st_mode, S_IFREG | 0755); - assert(st.st_mode == (S_IFREG | 0755)); + assertEqualInt(st.st_mode, S_IFREG | 0755); failure("The file extracted to disk is the wrong size."); assert(st.st_size == FILE_BUFF_SIZE); fd = open("file", O_RDONLY); @@ -153,23 +159,26 @@ DEFINE_TEST(test_read_extract) assert(memcmp(buff, file_buff, FILE_BUFF_SIZE) == 0); assert(0 == stat("dir", &st)); failure("This was 0777 in archive, but umask should make it 0755"); - assert(st.st_mode == (S_IFDIR | 0755)); + /* If EXTRACT_PERM wasn't used, be careful to ignore sgid bit + * when checking dir modes, as some systems inherit sgid bit + * from the parent dir. */ + assertEqualInt(0755, st.st_mode & 0777); assert(0 == stat("dir/file", &st)); assert(st.st_mode == (S_IFREG | 0700)); assert(0 == stat("dir2", &st)); - assert(st.st_mode == (S_IFDIR | 0755)); + assertEqualInt(0755, st.st_mode & 0777); assert(0 == stat("dir2/file", &st)); assert(st.st_mode == (S_IFREG | 0000)); assert(0 == stat("dir3", &st)); - assert(st.st_mode == (S_IFDIR | 0710)); + assertEqualInt(0710, st.st_mode & 0777); assert(0 == stat("dir4", &st)); - assert(st.st_mode == (S_IFDIR | 0755)); + assertEqualInt(0755, st.st_mode & 0777); assert(0 == stat("dir4/a", &st)); - assert(st.st_mode == (S_IFDIR | 0755)); + assertEqualInt(0755, st.st_mode & 0777); assert(0 == stat("dir4/b", &st)); - assert(st.st_mode == (S_IFDIR | 0755)); + assertEqualInt(0755, st.st_mode & 0777); assert(0 == stat("dir4/c", &st)); - assert(st.st_mode == (S_IFDIR | 0711)); + assertEqualInt(0711, st.st_mode & 0777); assert(0 == lstat("symlink", &st)); assert(S_ISLNK(st.st_mode)); #if HAVE_LCHMOD diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_isorr_bz2.c b/archivers/libarchive/files/libarchive/test/test_read_format_isorr_bz2.c index 107024f5ede..5457c7fd96f 100644 --- a/archivers/libarchive/files/libarchive/test/test_read_format_isorr_bz2.c +++ b/archivers/libarchive/files/libarchive/test/test_read_format_isorr_bz2.c @@ -23,11 +23,11 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_isorr_bz2.c,v 1.3 2008/01/01 22:28:04 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_isorr_bz2.c,v 1.4 2008/06/21 19:11:51 kientzle Exp $"); /* Execute the following to rebuild the data for this program: - tail -n +5 test-read_format-isorr_bz2.c | /bin/sh + tail -n +32 test_read_format_isorr_bz2.c | /bin/sh rm -rf /tmp/iso mkdir /tmp/iso @@ -35,79 +35,37 @@ mkdir /tmp/iso/dir echo "hello" >/tmp/iso/file ln /tmp/iso/file /tmp/iso/hardlink (cd /tmp/iso; ln -s file symlink) -TZ=utc touch -afhm -t 197001010000.01 /tmp/iso /tmp/iso/file /tmp/iso/dir -TZ=utc touch -afhm -t 196912312359.58 /tmp/iso/symlink -mkhybrid -R -uid 1 -gid 2 /tmp/iso | bzip2 > data.iso.bz2 -cat data.iso.bz2 | ./maketest.pl > data.c +TZ=utc touch -afhm -t 197001020000.01 /tmp/iso /tmp/iso/file /tmp/iso/dir +TZ=utc touch -afhm -t 197001030000.02 /tmp/iso/symlink +mkhybrid -R -uid 1 -gid 2 /tmp/iso | bzip2 > test_read_format_isorr_bz2.iso.bz2 +F=test_read_format_isorr_bz2.iso.bz2 +uuencode $F $F > $F.uu exit 1 */ -static unsigned char archive[] = { -'B','Z','h','9','1','A','Y','&','S','Y','G',11,4,'c',0,0,199,255,221,255, -255,203,252,221,'c',251,248,'?',255,223,224,167,255,222,'&','!',234,'$',0, -'0',1,' ',0,'D',2,129,8,192,3,14,'2','3','$',19,184,'J',' ','F',168,244,201, -149,'6','Q',226,155,'S',212,209,160,'h','4','i',160,26,13,0,244,134,212,0, -218,'O',212,153,1,144,244,128,148,' ',147,13,' ',213,'=','1','\'',169,166, -128,'=','!',233,0,208,0,26,0,0,30,160,'h',0,'4','z',130,180,163,'@',0,0,4, -211,0,0,0,2,'b','`',0,0,0,0,0,8,146,133,'F',154,'y','A',163,'A',161,163,'@', -'z',134,'C','C','F',131,'F','@',0,0,0,0,6,154,26,'Q',24,234,180,'P',172,251, -'=',2,'P','H','&','Y','o',130,28,'"',229,210,247,227,248,200,'?','6',161, -'?',170,'H',172,'"','H','I',16,'2','"','&',148,'G',133,'T','z',224,1,215, -' ',0,191,184,10,160,24,248,180,183,244,156,'K',202,133,208,'U',5,'6','C', -26,144,'H',168,'H','H','(','"',151,'@','m',223,'(','P',169,'e',145,148,'6', -237,235,7,227,204,']','k','{',241,187,227,244,251,':','a','L',138,'#','R', -'"',221,'_',239,')',140,'*','*',172,'Q',16,1,16,207,166,251,233,'Z',169,'4', -'_',195,'a',14,18,231,'}',14,139,137,'e',213,185,'T',194,'D','`',25,'$',187, -208,'%','c',162,'~',181,'@',204,'2',238,'P',161,213,127,'I',169,3,' ','o', -6,161,16,128,'F',214,'S','m',6,244,11,229,'Z','y','.',176,'q',' ',248,167, -204,26,193,'q',211,241,214,133,221,212,'I','`',28,244,'N','N','f','H','9', -'w',245,209,'*',20,26,208,'h','(',194,156,192,'l',';',192,'X','T',151,177, -209,'0',156,16,'=',20,'k',184,144,'z',26,'j',133,194,'9',227,'<','[','^', -17,'w','p',225,220,248,'>',205,'>','[',19,'5',155,17,175,28,28,168,175,'n', -'\'','c','w',27,222,204,'k','n','x','I',23,237,'c',145,11,184,'A','(',1,169, -'0',180,189,134,'\\','Y','x',187,'C',151,'d','k','y','-','L',218,138,'s', -'*','(',12,'h',242,'*',17,'E','L',202,146,138,'l','0',217,160,'9','.','S', -214,198,143,'3','&',237,'=','t','P',168,214,210,'`','p','J',181,'H',138,149, -'1','B',206,22,164,'[','O','A',172,134,224,179,219,166,184,'X',185,'W',154, -219,19,161,'Y',184,220,237,147,'9',191,237,'&','i','_',226,146,205,160,'@', -'b',182,';',3,'!',183,'J','t',161,160,178,173,'S',235,':','2',159,':',245, -'{','U',174,'P',142,'G','(',')',9,168,185,'A','U',231,193,'g',213,'e',12, -'X',223,22,249,')',152,237,'G',150,156,3,201,245,212,'2',218,209,177,196, -235,'_','~',137,24,31,196,232,'B',172,'w',159,24,'n',156,150,225,'1','y', -22,'#',138,193,227,232,169,170,166,179,1,11,182,'i',')',160,180,198,175,128, -249,167,5,194,142,183,'f',134,206,180,'&','E','!','[',31,195,':',192,'s', -232,187,'N',131,'Y',137,243,15,'y',12,'J',163,'-',242,'5',197,151,130,163, -240,220,'T',161,'L',159,141,159,152,'4',18,128,'.','^',250,168,200,163,'P', -231,'Y','w','F','U',186,'x',190,16,'0',228,22,'9','F','t',168,157,'i',190, -'+',246,141,142,18,' ','M',174,197,'O',165,'m',224,27,'b',150,'|','W','H', -196,'.','*','Q','$',225,'I','-',148,169,'F',7,197,'m','-',130,153,0,158,21, -'(',221,221,226,206,'g',13,159,163,'y',176,'~',158,'k','4','q','d','s',177, -'7',14,217,'1',173,206,228,'t',250,200,170,162,'d','2','Z','$','e',168,224, -223,129,174,229,165,187,252,203,'-',28,'`',207,183,'-','/',127,196,230,131, -'B',30,237,' ',8,26,194,'O',132,'L','K','\\',144,'L','c',1,10,176,192,'c', -0,244,2,168,3,0,'+',233,186,16,17,'P',17,129,252,'2',0,2,154,247,255,166, -'.',228,138,'p',161,' ',142,22,8,198}; - DEFINE_TEST(test_read_format_isorr_bz2) { + const char *refname = "test_read_format_isorr_bz2.iso.bz2"; struct archive_entry *ae; struct archive *a; const void *p; size_t size; off_t offset; + + extract_reference_file(refname); assert((a = archive_read_new()) != NULL); - assert(0 == archive_read_support_compression_all(a)); - assert(0 == archive_read_support_format_all(a)); - assert(0 == archive_read_open_memory(a, archive, sizeof(archive))); + assertEqualInt(0, archive_read_support_compression_all(a)); + assertEqualInt(0, archive_read_support_format_all(a)); + assertEqualInt(0, archive_read_open_filename(a, refname, 10240)); /* First entry is '.' root directory. */ - assert(0 == archive_read_next_header(a, &ae)); + assertEqualInt(0, archive_read_next_header(a, &ae)); assertEqualString(".", archive_entry_pathname(ae)); assert(S_ISDIR(archive_entry_stat(ae)->st_mode)); assertEqualInt(2048, archive_entry_size(ae)); - assertEqualInt(1, archive_entry_mtime(ae)); + assertEqualInt(86401, archive_entry_mtime(ae)); assertEqualInt(0, archive_entry_mtime_nsec(ae)); - assertEqualInt(1, archive_entry_ctime(ae)); + assertEqualInt(86401, archive_entry_ctime(ae)); assertEqualInt(0, archive_entry_stat(ae)->st_nlink); assertEqualInt(0, archive_entry_uid(ae)); assertEqualIntA(a, ARCHIVE_EOF, @@ -115,66 +73,66 @@ DEFINE_TEST(test_read_format_isorr_bz2) assertEqualInt(size, 0); /* A directory. */ - assert(0 == archive_read_next_header(a, &ae)); + assertEqualInt(0, archive_read_next_header(a, &ae)); assertEqualString("dir", archive_entry_pathname(ae)); assert(S_ISDIR(archive_entry_stat(ae)->st_mode)); - assert(2048 == archive_entry_size(ae)); - assert(1 == archive_entry_mtime(ae)); - assert(1 == archive_entry_atime(ae)); - assert(2 == archive_entry_stat(ae)->st_nlink); - assert(1 == archive_entry_uid(ae)); - assert(2 == archive_entry_gid(ae)); + assertEqualInt(2048, archive_entry_size(ae)); + assertEqualInt(86401, archive_entry_mtime(ae)); + assertEqualInt(86401, archive_entry_atime(ae)); + assertEqualInt(2, archive_entry_stat(ae)->st_nlink); + assertEqualInt(1, archive_entry_uid(ae)); + assertEqualInt(2, archive_entry_gid(ae)); /* A regular file. */ - assert(0 == archive_read_next_header(a, &ae)); + assertEqualInt(0, archive_read_next_header(a, &ae)); assertEqualString("file", archive_entry_pathname(ae)); assert(S_ISREG(archive_entry_stat(ae)->st_mode)); - assert(6 == archive_entry_size(ae)); - assert(0 == archive_read_data_block(a, &p, &size, &offset)); - assert(6 == size); - assert(0 == offset); - assert(0 == memcmp(p, "hello\n", 6)); - assert(1 == archive_entry_mtime(ae)); - assert(1 == archive_entry_atime(ae)); - assert(2 == archive_entry_stat(ae)->st_nlink); - assert(1 == archive_entry_uid(ae)); - assert(2 == archive_entry_gid(ae)); + assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(0, archive_read_data_block(a, &p, &size, &offset)); + assertEqualInt(6, size); + assertEqualInt(0, offset); + assertEqualInt(0, memcmp(p, "hello\n", 6)); + assertEqualInt(86401, archive_entry_mtime(ae)); + assertEqualInt(86401, archive_entry_atime(ae)); + assertEqualInt(2, archive_entry_stat(ae)->st_nlink); + assertEqualInt(1, archive_entry_uid(ae)); + assertEqualInt(2, archive_entry_gid(ae)); /* A hardlink to the regular file. */ - assert(0 == archive_read_next_header(a, &ae)); + assertEqualInt(0, archive_read_next_header(a, &ae)); assertEqualString("hardlink", archive_entry_pathname(ae)); assert(S_ISREG(archive_entry_stat(ae)->st_mode)); assertEqualString("file", archive_entry_hardlink(ae)); - assert(6 == archive_entry_size(ae)); - assert(1 == archive_entry_mtime(ae)); - assert(1 == archive_entry_atime(ae)); - assert(2 == archive_entry_stat(ae)->st_nlink); - assert(1 == archive_entry_uid(ae)); - assert(2 == archive_entry_gid(ae)); + assertEqualInt(6, archive_entry_size(ae)); + assertEqualInt(86401, archive_entry_mtime(ae)); + assertEqualInt(86401, archive_entry_atime(ae)); + assertEqualInt(2, archive_entry_stat(ae)->st_nlink); + assertEqualInt(1, archive_entry_uid(ae)); + assertEqualInt(2, archive_entry_gid(ae)); /* A symlink to the regular file. */ - assert(0 == archive_read_next_header(a, &ae)); + assertEqualInt(0, archive_read_next_header(a, &ae)); assertEqualString("symlink", archive_entry_pathname(ae)); assert(S_ISLNK(archive_entry_stat(ae)->st_mode)); assertEqualString("file", archive_entry_symlink(ae)); - assert(0 == archive_entry_size(ae)); - assert(-2 == archive_entry_mtime(ae)); - assert(-2 == archive_entry_atime(ae)); - assert(1 == archive_entry_stat(ae)->st_nlink); - assert(1 == archive_entry_uid(ae)); - assert(2 == archive_entry_gid(ae)); + assertEqualInt(0, archive_entry_size(ae)); + assertEqualInt(172802, archive_entry_mtime(ae)); + assertEqualInt(172802, archive_entry_atime(ae)); + assertEqualInt(1, archive_entry_stat(ae)->st_nlink); + assertEqualInt(1, archive_entry_uid(ae)); + assertEqualInt(2, archive_entry_gid(ae)); /* End of archive. */ - assert(ARCHIVE_EOF == archive_read_next_header(a, &ae)); + assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae)); /* Verify archive format. */ - assert(archive_compression(a) == ARCHIVE_COMPRESSION_BZIP2); - assert(archive_format(a) == ARCHIVE_FORMAT_ISO9660_ROCKRIDGE); + assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_BZIP2); + assertEqualInt(archive_format(a), ARCHIVE_FORMAT_ISO9660_ROCKRIDGE); /* Close the archive. */ - assert(0 == archive_read_close(a)); + assertEqualInt(0, archive_read_close(a)); #if ARCHIVE_API_VERSION > 1 - assert(0 == archive_read_finish(a)); + assertEqualInt(0, archive_read_finish(a)); #else archive_read_finish(a); #endif diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu b/archivers/libarchive/files/libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu new file mode 100644 index 00000000000..3f0cfca5021 --- /dev/null +++ b/archivers/libarchive/files/libarchive/test/test_read_format_isorr_bz2.iso.bz2.uu @@ -0,0 +1,22 @@ +begin 644 test_read_format_isorr_bz2.iso.bz2 +M0EIH.3%!629361M#:2D``,?_W?__6_Y58_GX/__?X*?OWB8AZB0`,`$@`$0" +M@0C``QP`U:!,&J>FJ>2:CR)^I'ZB#3U/4-`!H:#(:``]0P@`!H9!D!II-$,A +M&BGFJ>34]0T!IHT&AHT:#0:``!ZC$`#0T.`!H&@&AH``!IB&C30```!H9``! +MA(D0DTQ3T3$TVA-!IIZAA-'J:!H!H#0:#30:#30T;1*PHGAZ"/F;E""L"I6" +M8W&#'./D%S=_T4T96&+@94X&AL;:`Y+0C?:%=B#:8`:PP`2WF"20!EXL)6=] +M8=A)!0Q)($C&$U#8AI(&QL2!"10P4^8D$"0,8$I-.!3R8YWZ]Q1./IDR^VYN +MRJ&76*,$3PG?U(,=C;I20`D<&9/%5ILJIGI0(SWP3KRID6=#1MV*A>)(*B0$ +M$E:><!0D%K$G(WM("\:="00+`OCJ`Y0K(4B%(:1`#1-.%*`S0+)N`I4'MID+ +M$8MAN[,\.QJ`I=ZDA(5<O`KS[(+3L4-$,@&#*7!<`@AO7Y8*E9S#7L>B944( +MO-&.8&:1K;>[K$?O7R-FWA;%5+E]WBV<T&*%[O-6_,_/]:YC;<A-%^UFF09U +MP`*D@;&4KUHN&1:F_D1:YM:J-EG8L%<+BF4W%"6TU:I68MIJ6"FVH>T9PR7J +MNU2C2G2>5**"XH4HD`PF+(*DTT&47'A+)B";NS-UH>(]7G^\/G_343KU\17< +M<*""-SM"%>BVIJL8SF]7L-1.-LSRP2%=KX&C56*FC&#C$XNMGL)]3X&^$V4Z +MY`()G`%`KUR!HU8Z'"HWNE&P6MI:KZ<F%H/X3DN/F&%#`.%8#!HTK295C.#[ +M+^4C&90I^(::@`Y$=<OX=S3?,A#ZU'\'^+PYHV2PK?Q-,&8/Q$A3@$*X*=$A +MK;I2)&A^MSZ`*](@"[>^Q"H0L7.OV8ZJW409[QO=`&&D%=5&@RP`MO%R/J#Q +M-KJ*6D;EH7:DK0.48@8HF*IP(>*YMR$>!+A,)X+;`$94@@?U]B/=2T0CY-2= +M*_1FPF<-G\\@Z-_,Q>06='5:(B#3`W$8Y!:C-CE22SM9*S$00,XXJTIZ!GA( +LGTMN:F\J-,D9>?.38*!I7T>--*B_=T44HJ?#@``"1;7#_Q=R13A0D!M#:2D` +` +end diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_mtree.c b/archivers/libarchive/files/libarchive/test/test_read_format_mtree.c index b2fdbb88349..954f0222ad1 100644 --- a/archivers/libarchive/files/libarchive/test/test_read_format_mtree.c +++ b/archivers/libarchive/files/libarchive/test/test_read_format_mtree.c @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_mtree.c,v 1.1 2008/01/01 22:28:04 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_mtree.c,v 1.2 2008/05/26 17:00:24 kientzle Exp $"); /* Single entry with a hardlink. */ static unsigned char archive[] = { diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_zip.c b/archivers/libarchive/files/libarchive/test/test_read_format_zip.c index 9829217fc41..50e522bb4d5 100644 --- a/archivers/libarchive/files/libarchive/test/test_read_format_zip.c +++ b/archivers/libarchive/files/libarchive/test/test_read_format_zip.c @@ -25,26 +25,9 @@ #include "test.h" __FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_zip.c,v 1.3 2008/01/01 22:28:04 kientzle Exp $"); -static unsigned char archive[] = { -'P','K',3,4,10,0,0,0,0,0,'Y','f',179,'6',0,0,0,0,0,0,0,0,0,0,0,0,4,0,21,0, -'d','i','r','/','U','T',9,0,3,25,'U','O','F',25,'U','O','F','U','x',4,0,232, -3,232,3,'P','K',3,4,20,0,0,0,8,0,'o','f',179,'6',':','7','f','=',10,0,0,0, -18,0,0,0,5,0,21,0,'f','i','l','e','1','U','T',9,0,3,'A','U','O','F',172,'[', -'O','F','U','x',4,0,232,3,232,3,203,'H',205,201,201,231,202,'@','"',1,'P', -'K',3,4,20,0,0,0,8,0,'Z','j',179,'6',':','7','f','=',10,0,0,0,18,0,0,0,5, -0,21,0,'f','i','l','e','2','U','T',9,0,3,172,'[','O','F',172,'[','O','F', -'U','x',4,0,232,3,232,3,203,'H',205,201,201,231,202,'@','"',1,'P','K',1,2, -23,3,10,0,0,0,0,0,'Y','f',179,'6',0,0,0,0,0,0,0,0,0,0,0,0,4,0,13,0,0,0,0, -0,0,0,16,0,237,'A',0,0,0,0,'d','i','r','/','U','T',5,0,3,25,'U','O','F','U', -'x',0,0,'P','K',1,2,23,3,20,0,0,0,8,0,'o','f',179,'6',':','7','f','=',10, -0,0,0,18,0,0,0,5,0,13,0,0,0,0,0,1,0,0,0,164,129,'7',0,0,0,'f','i','l','e', -'1','U','T',5,0,3,'A','U','O','F','U','x',0,0,'P','K',1,2,23,3,20,0,0,0,8, -0,'Z','j',179,'6',':','7','f','=',10,0,0,0,18,0,0,0,5,0,13,0,0,0,0,0,1,0, -0,0,164,129,'y',0,0,0,'f','i','l','e','2','U','T',5,0,3,172,'[','O','F','U', -'x',0,0,'P','K',5,6,0,0,0,0,3,0,3,0,191,0,0,0,187,0,0,0,0,0}; - DEFINE_TEST(test_read_format_zip) { + const char *refname = "test_read_format_zip.zip"; struct archive_entry *ae; struct archive *a; char *buff[128]; @@ -52,10 +35,11 @@ DEFINE_TEST(test_read_format_zip) size_t s; off_t o; + extract_reference_file(refname); assert((a = archive_read_new()) != NULL); assertA(0 == archive_read_support_compression_all(a)); assertA(0 == archive_read_support_format_all(a)); - assertA(0 == archive_read_open_memory(a, archive, sizeof(archive))); + assertA(0 == archive_read_open_filename(a, refname, 10240)); assertA(0 == archive_read_next_header(a, &ae)); assertEqualString("dir/", archive_entry_pathname(ae)); assertEqualInt(1179604249, archive_entry_mtime(ae)); diff --git a/archivers/libarchive/files/libarchive/test/test_read_format_zip.zip.uu b/archivers/libarchive/files/libarchive/test/test_read_format_zip.zip.uu new file mode 100644 index 00000000000..f61340e2f93 --- /dev/null +++ b/archivers/libarchive/files/libarchive/test/test_read_format_zip.zip.uu @@ -0,0 +1,13 @@ +$FreeBSD$ +begin 645 test_read_format_zip.zip +M4$L#!`H``````%EFLS8````````````````$`!4`9&ER+U54"0`#&55/1AE5 +M3T95>`0`Z`/H`U!+`P04````"`!O9K,V.C=F/0H````2````!0`5`&9I;&4Q +M550)``-!54]&K%M/1E5X!`#H`^@#RTC-R<GGRD`B`5!+`P04````"`!::K,V +M.C=F/0H````2````!0`5`&9I;&4R550)``.L6T]&K%M/1E5X!`#H`^@#RTC- +MR<GGRD`B`5!+`0(7`PH``````%EFLS8````````````````$``T````````` +M$`#M00````!D:7(O550%``,954]&57@``%!+`0(7`Q0````(`&]FLS8Z-V8] +M"@```!(````%``T```````$```"D@3<```!F:6QE,554!0`#055/1E5X``!0 +M2P$"%P,4````"`!::K,V.C=F/0H````2````!0`-```````!````I(%Y```` +H9FEL93)55`4``ZQ;3T95>```4$L%!@`````#``,`OP```+L````````` +` +end diff --git a/archivers/libarchive/files/libarchive/test/test_tar_filenames.c b/archivers/libarchive/files/libarchive/test/test_tar_filenames.c index 9b98448e4a7..e863fbd23cd 100644 --- a/archivers/libarchive/files/libarchive/test/test_tar_filenames.c +++ b/archivers/libarchive/files/libarchive/test/test_tar_filenames.c @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_tar_filenames.c,v 1.8 2008/01/01 22:28:04 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/test/test_tar_filenames.c,v 1.9 2008/05/26 17:00:24 kientzle Exp $"); /* * Exercise various lengths of filenames in tar archives, diff --git a/archivers/libarchive/files/libarchive/test/test_tar_large.c b/archivers/libarchive/files/libarchive/test/test_tar_large.c index a05b49f6ab5..df8a1399ad9 100644 --- a/archivers/libarchive/files/libarchive/test/test_tar_large.c +++ b/archivers/libarchive/files/libarchive/test/test_tar_large.c @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_tar_large.c,v 1.1 2008/01/01 22:28:04 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/test/test_tar_large.c,v 1.2 2008/05/26 17:00:24 kientzle Exp $"); #include <errno.h> #include <stdlib.h> diff --git a/archivers/libarchive/files/libarchive/test/test_write_disk.c b/archivers/libarchive/files/libarchive/test/test_write_disk.c index 480cf29b566..fe44a4538e2 100644 --- a/archivers/libarchive/files/libarchive/test/test_write_disk.c +++ b/archivers/libarchive/files/libarchive/test/test_write_disk.c @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_disk.c,v 1.8 2008/01/23 05:47:08 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_disk.c,v 1.9 2008/06/15 10:35:22 kientzle Exp $"); #if ARCHIVE_VERSION_STAMP >= 1009000 @@ -48,7 +48,11 @@ static void create(struct archive_entry *ae, const char *msg) assert(0 == stat(archive_entry_pathname(ae), &st)); failure("st.st_mode=%o archive_entry_mode(ae)=%o", st.st_mode, archive_entry_mode(ae)); - assert(st.st_mode == (archive_entry_mode(ae) & ~UMASK)); + /* When verifying a dir, ignore the S_ISGID bit, as some systems set + * that automatically. */ + if (archive_entry_filetype(ae) == AE_IFDIR) + st.st_mode &= ~S_ISGID; + assertEqualInt(st.st_mode, archive_entry_mode(ae) & ~UMASK); } static void create_reg_file(struct archive_entry *ae, const char *msg) diff --git a/archivers/libarchive/files/libarchive/test/test_write_disk_hardlink.c b/archivers/libarchive/files/libarchive/test/test_write_disk_hardlink.c index 0729c38a114..dda384a85a1 100644 --- a/archivers/libarchive/files/libarchive/test/test_write_disk_hardlink.c +++ b/archivers/libarchive/files/libarchive/test/test_write_disk_hardlink.c @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_disk_hardlink.c,v 1.1 2008/01/18 05:05:58 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_disk_hardlink.c,v 1.2 2008/05/26 17:00:24 kientzle Exp $"); #define UMASK 022 diff --git a/archivers/libarchive/files/libarchive/test/test_write_disk_perms.c b/archivers/libarchive/files/libarchive/test/test_write_disk_perms.c index 4c03c75b491..2e872a1e359 100644 --- a/archivers/libarchive/files/libarchive/test/test_write_disk_perms.c +++ b/archivers/libarchive/files/libarchive/test/test_write_disk_perms.c @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_disk_perms.c,v 1.8 2008/01/01 22:28:04 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_disk_perms.c,v 1.9 2008/06/15 10:35:22 kientzle Exp $"); #if ARCHIVE_VERSION_STAMP >= 1009000 @@ -186,7 +186,7 @@ DEFINE_TEST(test_write_disk_perms) /* Check original perms. */ assert(0 == stat("dir_overwrite_0744", &st)); failure("dir_overwrite_0744: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == 0744); + assert((st.st_mode & 0777) == 0744); /* Overwrite shouldn't edit perms. */ assert((ae = archive_entry_new()) != NULL); archive_entry_copy_pathname(ae, "dir_overwrite_0744"); @@ -197,7 +197,7 @@ DEFINE_TEST(test_write_disk_perms) /* Make sure they're unchanged. */ assert(0 == stat("dir_overwrite_0744", &st)); failure("dir_overwrite_0744: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == 0744); + assert((st.st_mode & 0777) == 0744); /* Write a regular file with SUID bit, but don't use _EXTRACT_PERM. */ assert((ae = archive_entry_new()) != NULL); @@ -385,7 +385,7 @@ DEFINE_TEST(test_write_disk_perms) assert(0 == stat("dir_overwrite_0744", &st)); failure("dir_overwrite_0744: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == 0744); + assert((st.st_mode & 0777) == 0744); assert(0 == stat("file_no_suid", &st)); failure("file_0755: st.st_mode=%o", st.st_mode); diff --git a/archivers/libarchive/files/libarchive/test/test_write_disk_secure.c b/archivers/libarchive/files/libarchive/test/test_write_disk_secure.c index 80876b46c4c..2bcc95762c3 100644 --- a/archivers/libarchive/files/libarchive/test/test_write_disk_secure.c +++ b/archivers/libarchive/files/libarchive/test/test_write_disk_secure.c @@ -23,7 +23,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_disk_secure.c,v 1.3 2007/07/06 15:43:11 kientzle Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_disk_secure.c,v 1.4 2008/06/15 10:35:22 kientzle Exp $"); #define UMASK 022 @@ -115,7 +115,7 @@ DEFINE_TEST(test_write_disk_secure) /* Test the entries on disk. */ assert(0 == lstat("dir", &st)); failure("dir: st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == 0755); + assert((st.st_mode & 0777) == 0755); assert(0 == lstat("link_to_dir", &st)); failure("link_to_dir: st.st_mode=%o", st.st_mode); @@ -137,7 +137,7 @@ DEFINE_TEST(test_write_disk_secure) failure("link_to_dir2 should have been re-created as a true dir"); assert(S_ISDIR(st.st_mode)); failure("link_to_dir2: Implicit dir creation should obey umask, but st.st_mode=%o", st.st_mode); - assert((st.st_mode & 07777) == 0755); + assert((st.st_mode & 0777) == 0755); assert(0 == lstat("link_to_dir2/filec", &st)); assert(S_ISREG(st.st_mode)); diff --git a/archivers/libarchive/files/libarchive/test/test_write_format_ar.c b/archivers/libarchive/files/libarchive/test/test_write_format_ar.c index 4bb84a6a615..a60a0cd8800 100644 --- a/archivers/libarchive/files/libarchive/test/test_write_format_ar.c +++ b/archivers/libarchive/files/libarchive/test/test_write_format_ar.c @@ -26,7 +26,7 @@ */ #include "test.h" -__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_format_ar.c,v 1.6 2008/03/12 21:10:26 kaiw Exp $"); +__FBSDID("$FreeBSD: src/lib/libarchive/test/test_write_format_ar.c,v 1.7 2008/05/26 17:00:24 kientzle Exp $"); char buff[4096]; char buff2[64]; |