diff options
author | grehan <grehan@FreeBSD.org> | 2011-07-18 22:00:21 +0000 |
---|---|---|
committer | grehan <grehan@FreeBSD.org> | 2011-07-18 22:00:21 +0000 |
commit | 1823067d93fba5ecf7990fee39428954fa5cbf1b (patch) | |
tree | 02a0ea02eab1c6db10baf7c805a29a81132bbe98 /lib | |
parent | cba736c8eee565e8ba803c9ef7c7f06aefb162ed (diff) | |
parent | 9a6ff5ad378cfaaa99c5162e2b0f6e4cb6a3c796 (diff) | |
download | FreeBSD-src-1823067d93fba5ecf7990fee39428954fa5cbf1b.zip FreeBSD-src-1823067d93fba5ecf7990fee39428954fa5cbf1b.tar.gz |
IFC @ r224187
Diffstat (limited to 'lib')
141 files changed, 6930 insertions, 396 deletions
diff --git a/lib/bind/Makefile b/lib/bind/Makefile index 4268219..e2457b7 100644 --- a/lib/bind/Makefile +++ b/lib/bind/Makefile @@ -1,5 +1,5 @@ # $FreeBSD$ -SUBDIR= bind9 dns isc isccc isccfg lwres +SUBDIR= isc isccc dns isccfg bind9 lwres .include <bsd.subdir.mk> diff --git a/lib/bind/config.h b/lib/bind/config.h index 7a5ea06..003a756 100644 --- a/lib/bind/config.h +++ b/lib/bind/config.h @@ -3,7 +3,7 @@ /* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.in by autoheader. */ /* - * Copyright (C) 2004, 2005, 2007, 2009 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2005, 2007, 2008 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and/or distribute this software for any @@ -19,7 +19,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: acconfig.h,v 1.51.334.2 2009/02/16 23:47:15 tbox Exp $ */ +/* $Id: acconfig.h,v 1.53 2008-12-01 23:47:44 tbox Exp $ */ /*! \file */ @@ -150,6 +150,9 @@ int sigwait(const unsigned int *set, int *sig); /* Define if building universal (internal helper macro) */ /* #undef AC_APPLE_UNIVERSAL_BUILD */ +/* Define to enable the "filter-aaaa-on-v4" option. */ +/* #undef ALLOW_FILTER_AAAA_ON_V4 */ + /* Define if recvmsg() does not meet all of the BSD socket API specifications. */ /* #undef BROKEN_RECVMSG */ @@ -160,6 +163,12 @@ int sigwait(const unsigned int *set, int *sig); /* Define to enable "rrset-order fixed" syntax. */ /* #undef DNS_RDATASET_FIXED */ +/* Define to enable rpz-nsdname rules. */ +/* #undef ENABLE_RPZ_NSDNAME */ + +/* Define to enable rpz-nsip rules. */ +/* #undef ENABLE_RPZ_NSIP */ + /* Solaris hack to get select_large_fdset. */ /* #undef FD_SETSIZE */ @@ -193,9 +202,15 @@ int sigwait(const unsigned int *set, int *sig); /* Define to 1 if you have the <gssapi/gssapi.h> header file. */ /* #undef HAVE_GSSAPI_GSSAPI_H */ +/* Define to 1 if you have the <gssapi/gssapi_krb5.h> header file. */ +/* #undef HAVE_GSSAPI_GSSAPI_KRB5_H */ + /* Define to 1 if you have the <gssapi.h> header file. */ /* #undef HAVE_GSSAPI_H */ +/* Define to 1 if you have the <gssapi_krb5.h> header file. */ +/* #undef HAVE_GSSAPI_KRB5_H */ + /* Define to 1 if you have the <inttypes.h> header file. */ #define HAVE_INTTYPES_H 1 @@ -214,6 +229,9 @@ int sigwait(const unsigned int *set, int *sig); /* Define to 1 if you have the `cap' library (-lcap). */ /* #undef HAVE_LIBCAP */ +/* if system have backtrace function */ +/* #undef HAVE_LIBCTRACE */ + /* Define to 1 if you have the `c_r' library (-lc_r). */ /* #undef HAVE_LIBC_R */ @@ -250,9 +268,27 @@ int sigwait(const unsigned int *set, int *sig); /* Define to 1 if you have the <net/if6.h> header file. */ /* #undef HAVE_NET_IF6_H */ +/* Define if your OpenSSL version supports GOST. */ +/* #undef HAVE_OPENSSL_GOST */ + +/* Define to 1 if you have the <regex.h> header file. */ +#define HAVE_REGEX_H 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + /* Define to 1 if you have the `setlocale' function. */ #define HAVE_SETLOCALE 1 +/* Define to 1 if you have the `setresgid' function. */ +#define HAVE_SETRESGID 1 + +/* Define to 1 if you have the `setresuid' function. */ +#define HAVE_SETRESUID 1 + /* Define to 1 if you have the <stdint.h> header file. */ #define HAVE_STDINT_H 1 @@ -307,6 +343,15 @@ int sigwait(const unsigned int *set, int *sig); /* Define to 1 if you have the <unistd.h> header file. */ #define HAVE_UNISTD_H 1 +/* return type of gai_strerror */ +#define IRS_GAISTRERROR_RETURN_T const char * + +/* Define to the buffer length type used by getnameinfo(3). */ +#define IRS_GETNAMEINFO_BUFLEN_T size_t + +/* Define to the flags type used by getnameinfo(3). */ +#define IRS_GETNAMEINFO_FLAGS_T int + /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #define LT_OBJDIR ".libs/" @@ -368,11 +413,8 @@ int sigwait(const unsigned int *set, int *sig); /* Define to empty if `const' does not conform to ANSI C. */ /* #undef const */ -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus +/* Define to empty if your compiler does not support "static inline". */ #define inline /**/ -#endif /* Define to `unsigned int' if <sys/types.h> does not define. */ /* #undef size_t */ diff --git a/lib/bind/config.mk b/lib/bind/config.mk index 184d017..ebac59a 100644 --- a/lib/bind/config.mk +++ b/lib/bind/config.mk @@ -67,8 +67,10 @@ CFLAGS+= -I${LIB_BIND_DIR} # Use the right version of the atomic.h file from lib/isc .if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" ISC_ATOMIC_ARCH= x86_32 +.elif ${MACHINE_ARCH} == "ia64" +ISC_ATOMIC_ARCH= ia64 .else -ISC_ATOMIC_ARCH= ${MACHINE_CPUARCH} +ISC_ATOMIC_ARCH= noatomic .endif # Optional features @@ -78,11 +80,6 @@ CFLAGS+= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 .if ${MK_BIND_SIGCHASE} == "yes" CFLAGS+= -DDIG_SIGCHASE .endif -.if ${MK_BIND_XML} == "yes" -CFLAGS+= -DHAVE_LIBXML2 -CFLAGS+= -I/usr/local/include -I/usr/local/include/libxml2 -CFLAGS+= -L/usr/local/lib -lxml2 -lz -liconv -lm -.endif # Link against BIND libraries .if ${MK_BIND_LIBS} == "no" @@ -110,6 +107,13 @@ BIND_DPADD= ${LIBBIND9} ${LIBDNS} ${LIBISCCC} ${LIBISCCFG} \ ${LIBISC} ${LIBLWRES} .if ${MK_BIND_LIBS} != "no" BIND_LDADD= -lbind9 -ldns -lisccc -lisccfg -lisc -llwres +CFLAGS+= -I${BIND_DIR}/lib/isc/include +CFLAGS+= -I${BIND_DIR}/lib/isc/unix/include +CFLAGS+= -I${BIND_DIR}/lib/isc/pthreads/include +CFLAGS+= -I${.CURDIR}/../dns +CFLAGS+= -I${BIND_DIR}/lib/dns/include +CFLAGS+= -I${BIND_DIR}/lib/isccfg/include +CFLAGS+= -I${.CURDIR}/../isc .else BIND_LDADD= ${BIND_DPADD} .endif @@ -120,5 +124,16 @@ CRYPTO_DPADD= ${LIBCRYPTO} CRYPTO_LDADD= -lcrypto .endif +.if ${MK_BIND_XML} == "yes" +CFLAGS+= -DHAVE_LIBXML2 +CFLAGS+= -I/usr/local/include -I/usr/local/include/libxml2 +.if ${MK_BIND_LIBS} != "no" +BIND_LDADD+= -L/usr/local/lib -lxml2 -lz -liconv -lm +.else +BIND_DPADD+= /usr/local/lib/libxml2.a ${LIBZ} +BIND_DPADD+= /usr/local/lib/libiconv.a ${LIBM} +.endif +.endif + PTHREAD_DPADD= ${LIBPTHREAD} PTHREAD_LDADD= -lpthread diff --git a/lib/bind/dns/Makefile b/lib/bind/dns/Makefile index 72b9f80..159de00 100644 --- a/lib/bind/dns/Makefile +++ b/lib/bind/dns/Makefile @@ -15,26 +15,24 @@ LIB= dns SRCS+= acache.c acl.c adb.c byaddr.c \ cache.c callbacks.c compress.c \ db.c dbiterator.c dbtable.c diff.c dispatch.c \ - dlz.c dnssec.c ds.c \ + dlz.c dns64.c dnssec.c ds.c \ dst_api.c dst_lib.c dst_parse.c dst_result.c \ forward.c \ gssapi_link.c gssapictx.c hmac_link.c \ - iptable.c \ - journal.c \ + iptable.c journal.c \ key.c \ - keytable.c \ - lib.c log.c lookup.c \ + keydata.c keytable.c lib.c log.c lookup.c \ master.c masterdump.c message.c \ name.c ncache.c nsec.c nsec3.c \ openssl_link.c openssldh_link.c \ - openssldsa_link.c opensslrsa_link.c \ - order.c peer.c portlist.c \ - rbt.c rbtdb.c rbtdb64.c rcode.c rdata.c \ - rdatalist.c \ + openssldsa_link.c opensslgost_link.c opensslrsa_link.c \ + order.c peer.c portlist.c private.c \ + rbt.c rbtdb.c rbtdb64.c rcode.c rdata.c rdatalist.c \ rdataset.c rdatasetiter.c rdataslab.c request.c \ - resolver.c result.c rootns.c sdb.c sdlz.c soa.c ssu.c \ + resolver.c result.c rootns.c rpz.c rriterator.c \ + sdb.c sdlz.c soa.c ssu.c ssu_external.c \ stats.c tcpmsg.c time.c timer.c tkey.c \ - tsig.c ttl.c validator.c \ + tsec.c tsig.c ttl.c validator.c \ version.c view.c xfrin.c zone.c zonekey.c zt.c CFLAGS+= -I${SRCDIR}/include/dst -I${SRCDIR}/include -I${SRCDIR} @@ -84,6 +82,7 @@ DNSINCS= ${SRCDIR}/include/dns/acache.h \ ${SRCDIR}/include/dns/order.h \ ${SRCDIR}/include/dns/peer.h \ ${SRCDIR}/include/dns/portlist.h \ + ${SRCDIR}/include/dns/private.h \ ${SRCDIR}/include/dns/rbt.h \ ${SRCDIR}/include/dns/rcode.h \ ${SRCDIR}/include/dns/rdata.h \ diff --git a/lib/bind/dns/code.h b/lib/bind/dns/code.h index 779285e..bfc5330 100644 --- a/lib/bind/dns/code.h +++ b/lib/bind/dns/code.h @@ -83,11 +83,13 @@ #include "rdata/in_1/dhcid_49.c" #include "rdata/generic/nsec3_50.c" #include "rdata/generic/nsec3param_51.c" +#include "rdata/generic/hip_55.c" #include "rdata/generic/spf_99.c" #include "rdata/generic/unspec_103.c" #include "rdata/generic/tkey_249.c" #include "rdata/any_255/tsig_250.c" #include "rdata/generic/dlv_32769.c" +#include "rdata/generic/keydata_65533.c" @@ -190,6 +192,7 @@ break; \ case 50: result = fromtext_nsec3(rdclass, type, lexer, origin, options, target, callbacks); break; \ case 51: result = fromtext_nsec3param(rdclass, type, lexer, origin, options, target, callbacks); break; \ + case 55: result = fromtext_hip(rdclass, type, lexer, origin, options, target, callbacks); break; \ case 99: result = fromtext_spf(rdclass, type, lexer, origin, options, target, callbacks); break; \ case 103: result = fromtext_unspec(rdclass, type, lexer, origin, options, target, callbacks); break; \ case 249: result = fromtext_tkey(rdclass, type, lexer, origin, options, target, callbacks); break; \ @@ -199,6 +202,7 @@ } \ break; \ case 32769: result = fromtext_dlv(rdclass, type, lexer, origin, options, target, callbacks); break; \ + case 65533: result = fromtext_keydata(rdclass, type, lexer, origin, options, target, callbacks); break; \ default: result = DNS_R_UNKNOWN; break; \ } @@ -301,6 +305,7 @@ break; \ case 50: result = totext_nsec3(rdata, tctx, target); break; \ case 51: result = totext_nsec3param(rdata, tctx, target); break; \ + case 55: result = totext_hip(rdata, tctx, target); break; \ case 99: result = totext_spf(rdata, tctx, target); break; \ case 103: result = totext_unspec(rdata, tctx, target); break; \ case 249: result = totext_tkey(rdata, tctx, target); break; \ @@ -310,6 +315,7 @@ } \ break; \ case 32769: result = totext_dlv(rdata, tctx, target); break; \ + case 65533: result = totext_keydata(rdata, tctx, target); break; \ default: use_default = ISC_TRUE; break; \ } @@ -412,6 +418,7 @@ break; \ case 50: result = fromwire_nsec3(rdclass, type, source, dctx, options, target); break; \ case 51: result = fromwire_nsec3param(rdclass, type, source, dctx, options, target); break; \ + case 55: result = fromwire_hip(rdclass, type, source, dctx, options, target); break; \ case 99: result = fromwire_spf(rdclass, type, source, dctx, options, target); break; \ case 103: result = fromwire_unspec(rdclass, type, source, dctx, options, target); break; \ case 249: result = fromwire_tkey(rdclass, type, source, dctx, options, target); break; \ @@ -421,6 +428,7 @@ } \ break; \ case 32769: result = fromwire_dlv(rdclass, type, source, dctx, options, target); break; \ + case 65533: result = fromwire_keydata(rdclass, type, source, dctx, options, target); break; \ default: use_default = ISC_TRUE; break; \ } @@ -523,6 +531,7 @@ break; \ case 50: result = towire_nsec3(rdata, cctx, target); break; \ case 51: result = towire_nsec3param(rdata, cctx, target); break; \ + case 55: result = towire_hip(rdata, cctx, target); break; \ case 99: result = towire_spf(rdata, cctx, target); break; \ case 103: result = towire_unspec(rdata, cctx, target); break; \ case 249: result = towire_tkey(rdata, cctx, target); break; \ @@ -532,6 +541,7 @@ } \ break; \ case 32769: result = towire_dlv(rdata, cctx, target); break; \ + case 65533: result = towire_keydata(rdata, cctx, target); break; \ default: use_default = ISC_TRUE; break; \ } @@ -634,6 +644,7 @@ break; \ case 50: result = compare_nsec3(rdata1, rdata2); break; \ case 51: result = compare_nsec3param(rdata1, rdata2); break; \ + case 55: result = compare_hip(rdata1, rdata2); break; \ case 99: result = compare_spf(rdata1, rdata2); break; \ case 103: result = compare_unspec(rdata1, rdata2); break; \ case 249: result = compare_tkey(rdata1, rdata2); break; \ @@ -643,6 +654,120 @@ } \ break; \ case 32769: result = compare_dlv(rdata1, rdata2); break; \ + case 65533: result = compare_keydata(rdata1, rdata2); break; \ + default: use_default = ISC_TRUE; break; \ + } + +#define CASECOMPARESWITCH \ + switch (rdata1->type) { \ + case 1: switch (rdata1->rdclass) { \ + case 1: result = casecompare_in_a(rdata1, rdata2); break; \ + case 3: result = casecompare_ch_a(rdata1, rdata2); break; \ + case 4: result = casecompare_hs_a(rdata1, rdata2); break; \ + default: use_default = ISC_TRUE; break; \ + } \ + break; \ + case 2: result = casecompare_ns(rdata1, rdata2); break; \ + case 3: result = casecompare_md(rdata1, rdata2); break; \ + case 4: result = casecompare_mf(rdata1, rdata2); break; \ + case 5: result = casecompare_cname(rdata1, rdata2); break; \ + case 6: result = casecompare_soa(rdata1, rdata2); break; \ + case 7: result = casecompare_mb(rdata1, rdata2); break; \ + case 8: result = casecompare_mg(rdata1, rdata2); break; \ + case 9: result = casecompare_mr(rdata1, rdata2); break; \ + case 10: result = casecompare_null(rdata1, rdata2); break; \ + case 11: switch (rdata1->rdclass) { \ + case 1: result = casecompare_in_wks(rdata1, rdata2); break; \ + default: use_default = ISC_TRUE; break; \ + } \ + break; \ + case 12: result = casecompare_ptr(rdata1, rdata2); break; \ + case 13: result = casecompare_hinfo(rdata1, rdata2); break; \ + case 14: result = casecompare_minfo(rdata1, rdata2); break; \ + case 15: result = casecompare_mx(rdata1, rdata2); break; \ + case 16: result = casecompare_txt(rdata1, rdata2); break; \ + case 17: result = casecompare_rp(rdata1, rdata2); break; \ + case 18: result = casecompare_afsdb(rdata1, rdata2); break; \ + case 19: result = casecompare_x25(rdata1, rdata2); break; \ + case 20: result = casecompare_isdn(rdata1, rdata2); break; \ + case 21: result = casecompare_rt(rdata1, rdata2); break; \ + case 22: switch (rdata1->rdclass) { \ + case 1: result = casecompare_in_nsap(rdata1, rdata2); break; \ + default: use_default = ISC_TRUE; break; \ + } \ + break; \ + case 23: switch (rdata1->rdclass) { \ + case 1: result = casecompare_in_nsap_ptr(rdata1, rdata2); break; \ + default: use_default = ISC_TRUE; break; \ + } \ + break; \ + case 24: result = casecompare_sig(rdata1, rdata2); break; \ + case 25: result = casecompare_key(rdata1, rdata2); break; \ + case 26: switch (rdata1->rdclass) { \ + case 1: result = casecompare_in_px(rdata1, rdata2); break; \ + default: use_default = ISC_TRUE; break; \ + } \ + break; \ + case 27: result = casecompare_gpos(rdata1, rdata2); break; \ + case 28: switch (rdata1->rdclass) { \ + case 1: result = casecompare_in_aaaa(rdata1, rdata2); break; \ + default: use_default = ISC_TRUE; break; \ + } \ + break; \ + case 29: result = casecompare_loc(rdata1, rdata2); break; \ + case 30: result = casecompare_nxt(rdata1, rdata2); break; \ + case 33: switch (rdata1->rdclass) { \ + case 1: result = casecompare_in_srv(rdata1, rdata2); break; \ + default: use_default = ISC_TRUE; break; \ + } \ + break; \ + case 35: switch (rdata1->rdclass) { \ + case 1: result = casecompare_in_naptr(rdata1, rdata2); break; \ + default: use_default = ISC_TRUE; break; \ + } \ + break; \ + case 36: switch (rdata1->rdclass) { \ + case 1: result = casecompare_in_kx(rdata1, rdata2); break; \ + default: use_default = ISC_TRUE; break; \ + } \ + break; \ + case 37: result = casecompare_cert(rdata1, rdata2); break; \ + case 38: switch (rdata1->rdclass) { \ + case 1: result = casecompare_in_a6(rdata1, rdata2); break; \ + default: use_default = ISC_TRUE; break; \ + } \ + break; \ + case 39: result = casecompare_dname(rdata1, rdata2); break; \ + case 41: result = casecompare_opt(rdata1, rdata2); break; \ + case 42: switch (rdata1->rdclass) { \ + case 1: result = casecompare_in_apl(rdata1, rdata2); break; \ + default: use_default = ISC_TRUE; break; \ + } \ + break; \ + case 43: result = casecompare_ds(rdata1, rdata2); break; \ + case 44: result = casecompare_sshfp(rdata1, rdata2); break; \ + case 45: result = casecompare_ipseckey(rdata1, rdata2); break; \ + case 46: result = casecompare_rrsig(rdata1, rdata2); break; \ + case 47: result = casecompare_nsec(rdata1, rdata2); break; \ + case 48: result = casecompare_dnskey(rdata1, rdata2); break; \ + case 49: switch (rdata1->rdclass) { \ + case 1: result = casecompare_in_dhcid(rdata1, rdata2); break; \ + default: use_default = ISC_TRUE; break; \ + } \ + break; \ + case 50: result = casecompare_nsec3(rdata1, rdata2); break; \ + case 51: result = casecompare_nsec3param(rdata1, rdata2); break; \ + case 55: result = casecompare_hip(rdata1, rdata2); break; \ + case 99: result = casecompare_spf(rdata1, rdata2); break; \ + case 103: result = casecompare_unspec(rdata1, rdata2); break; \ + case 249: result = casecompare_tkey(rdata1, rdata2); break; \ + case 250: switch (rdata1->rdclass) { \ + case 255: result = casecompare_any_tsig(rdata1, rdata2); break; \ + default: use_default = ISC_TRUE; break; \ + } \ + break; \ + case 32769: result = casecompare_dlv(rdata1, rdata2); break; \ + case 65533: result = casecompare_keydata(rdata1, rdata2); break; \ default: use_default = ISC_TRUE; break; \ } @@ -745,6 +870,7 @@ break; \ case 50: result = fromstruct_nsec3(rdclass, type, source, target); break; \ case 51: result = fromstruct_nsec3param(rdclass, type, source, target); break; \ + case 55: result = fromstruct_hip(rdclass, type, source, target); break; \ case 99: result = fromstruct_spf(rdclass, type, source, target); break; \ case 103: result = fromstruct_unspec(rdclass, type, source, target); break; \ case 249: result = fromstruct_tkey(rdclass, type, source, target); break; \ @@ -754,6 +880,7 @@ } \ break; \ case 32769: result = fromstruct_dlv(rdclass, type, source, target); break; \ + case 65533: result = fromstruct_keydata(rdclass, type, source, target); break; \ default: use_default = ISC_TRUE; break; \ } @@ -856,6 +983,7 @@ break; \ case 50: result = tostruct_nsec3(rdata, target, mctx); break; \ case 51: result = tostruct_nsec3param(rdata, target, mctx); break; \ + case 55: result = tostruct_hip(rdata, target, mctx); break; \ case 99: result = tostruct_spf(rdata, target, mctx); break; \ case 103: result = tostruct_unspec(rdata, target, mctx); break; \ case 249: result = tostruct_tkey(rdata, target, mctx); break; \ @@ -865,6 +993,7 @@ } \ break; \ case 32769: result = tostruct_dlv(rdata, target, mctx); break; \ + case 65533: result = tostruct_keydata(rdata, target, mctx); break; \ default: use_default = ISC_TRUE; break; \ } @@ -967,6 +1096,7 @@ break; \ case 50: freestruct_nsec3(source); break; \ case 51: freestruct_nsec3param(source); break; \ + case 55: freestruct_hip(source); break; \ case 99: freestruct_spf(source); break; \ case 103: freestruct_unspec(source); break; \ case 249: freestruct_tkey(source); break; \ @@ -976,6 +1106,7 @@ } \ break; \ case 32769: freestruct_dlv(source); break; \ + case 65533: freestruct_keydata(source); break; \ default: break; \ } @@ -1078,6 +1209,7 @@ break; \ case 50: result = additionaldata_nsec3(rdata, add, arg); break; \ case 51: result = additionaldata_nsec3param(rdata, add, arg); break; \ + case 55: result = additionaldata_hip(rdata, add, arg); break; \ case 99: result = additionaldata_spf(rdata, add, arg); break; \ case 103: result = additionaldata_unspec(rdata, add, arg); break; \ case 249: result = additionaldata_tkey(rdata, add, arg); break; \ @@ -1087,6 +1219,7 @@ } \ break; \ case 32769: result = additionaldata_dlv(rdata, add, arg); break; \ + case 65533: result = additionaldata_keydata(rdata, add, arg); break; \ default: use_default = ISC_TRUE; break; \ } @@ -1189,6 +1322,7 @@ break; \ case 50: result = digest_nsec3(rdata, digest, arg); break; \ case 51: result = digest_nsec3param(rdata, digest, arg); break; \ + case 55: result = digest_hip(rdata, digest, arg); break; \ case 99: result = digest_spf(rdata, digest, arg); break; \ case 103: result = digest_unspec(rdata, digest, arg); break; \ case 249: result = digest_tkey(rdata, digest, arg); break; \ @@ -1198,6 +1332,7 @@ } \ break; \ case 32769: result = digest_dlv(rdata, digest, arg); break; \ + case 65533: result = digest_keydata(rdata, digest, arg); break; \ default: use_default = ISC_TRUE; break; \ } @@ -1300,6 +1435,7 @@ break; \ case 50: result = checkowner_nsec3(name, rdclass, type, wildcard); break; \ case 51: result = checkowner_nsec3param(name, rdclass, type, wildcard); break; \ + case 55: result = checkowner_hip(name, rdclass, type, wildcard); break; \ case 99: result = checkowner_spf(name, rdclass, type, wildcard); break; \ case 103: result = checkowner_unspec(name, rdclass, type, wildcard); break; \ case 249: result = checkowner_tkey(name, rdclass, type, wildcard); break; \ @@ -1309,6 +1445,7 @@ } \ break; \ case 32769: result = checkowner_dlv(name, rdclass, type, wildcard); break; \ + case 65533: result = checkowner_keydata(name, rdclass, type, wildcard); break; \ default: result = ISC_TRUE; break; \ } @@ -1411,6 +1548,7 @@ break; \ case 50: result = checknames_nsec3(rdata, owner, bad); break; \ case 51: result = checknames_nsec3param(rdata, owner, bad); break; \ + case 55: result = checknames_hip(rdata, owner, bad); break; \ case 99: result = checknames_spf(rdata, owner, bad); break; \ case 103: result = checknames_unspec(rdata, owner, bad); break; \ case 249: result = checknames_tkey(rdata, owner, bad); break; \ @@ -1420,6 +1558,7 @@ } \ break; \ case 32769: result = checknames_dlv(rdata, owner, bad); break; \ + case 65533: result = checknames_keydata(rdata, owner, bad); break; \ default: result = ISC_TRUE; break; \ } #define RDATATYPE_COMPARE(_s, _d, _tn, _n, _tp) \ @@ -1579,6 +1718,9 @@ case 233: \ RDATATYPE_COMPARE("nsec3", 50, _typename, _length, _typep); \ break; \ + case 208: \ + RDATATYPE_COMPARE("hip", 55, _typename, _length, _typep); \ + break; \ case 230: \ RDATATYPE_COMPARE("uinfo", 100, _typename, _length, _typep); \ break; \ @@ -1605,6 +1747,7 @@ break; \ case 50: \ RDATATYPE_COMPARE("maila", 254, _typename, _length, _typep); \ + RDATATYPE_COMPARE("keydata", 65533, _typename, _length, _typep); \ break; \ case 68: \ RDATATYPE_COMPARE("any", 255, _typename, _length, _typep); \ @@ -1663,6 +1806,7 @@ case 49: return (RRTYPE_DHCID_ATTRIBUTES); \ case 50: return (RRTYPE_NSEC3_ATTRIBUTES); \ case 51: return (RRTYPE_NSEC3PARAM_ATTRIBUTES); \ + case 55: return (RRTYPE_HIP_ATTRIBUTES); \ case 99: return (RRTYPE_SPF_ATTRIBUTES); \ case 100: return (DNS_RDATATYPEATTR_RESERVED); \ case 101: return (DNS_RDATATYPEATTR_RESERVED); \ @@ -1676,6 +1820,7 @@ case 254: return (DNS_RDATATYPEATTR_META | DNS_RDATATYPEATTR_QUESTIONONLY); \ case 255: return (DNS_RDATATYPEATTR_META | DNS_RDATATYPEATTR_QUESTIONONLY); \ case 32769: return (RRTYPE_DLV_ATTRIBUTES); \ + case 65533: return (RRTYPE_KEYDATA_ATTRIBUTES); \ } #define RDATATYPE_TOTEXT_SW \ switch (type) { \ @@ -1730,6 +1875,7 @@ case 49: return (str_totext("DHCID", target)); \ case 50: return (str_totext("NSEC3", target)); \ case 51: return (str_totext("NSEC3PARAM", target)); \ + case 55: return (str_totext("HIP", target)); \ case 99: return (str_totext("SPF", target)); \ case 100: return (str_totext("UINFO", target)); \ case 101: return (str_totext("UID", target)); \ @@ -1743,5 +1889,6 @@ case 254: return (str_totext("MAILA", target)); \ case 255: return (str_totext("ANY", target)); \ case 32769: return (str_totext("DLV", target)); \ + case 65533: return (str_totext("KEYDATA", target)); \ } #endif /* DNS_CODE_H */ diff --git a/lib/bind/dns/dns/enumtype.h b/lib/bind/dns/dns/enumtype.h index 1f4e375..ef81791 100644 --- a/lib/bind/dns/dns/enumtype.h +++ b/lib/bind/dns/dns/enumtype.h @@ -78,11 +78,13 @@ enum { dns_rdatatype_dhcid = 49, dns_rdatatype_nsec3 = 50, dns_rdatatype_nsec3param = 51, + dns_rdatatype_hip = 55, dns_rdatatype_spf = 99, dns_rdatatype_unspec = 103, dns_rdatatype_tkey = 249, dns_rdatatype_tsig = 250, dns_rdatatype_dlv = 32769, + dns_rdatatype_keydata = 65533, dns_rdatatype_ixfr = 251, dns_rdatatype_axfr = 252, dns_rdatatype_mailb = 253, @@ -138,11 +140,13 @@ enum { #define dns_rdatatype_dhcid ((dns_rdatatype_t)dns_rdatatype_dhcid) #define dns_rdatatype_nsec3 ((dns_rdatatype_t)dns_rdatatype_nsec3) #define dns_rdatatype_nsec3param ((dns_rdatatype_t)dns_rdatatype_nsec3param) +#define dns_rdatatype_hip ((dns_rdatatype_t)dns_rdatatype_hip) #define dns_rdatatype_spf ((dns_rdatatype_t)dns_rdatatype_spf) #define dns_rdatatype_unspec ((dns_rdatatype_t)dns_rdatatype_unspec) #define dns_rdatatype_tkey ((dns_rdatatype_t)dns_rdatatype_tkey) #define dns_rdatatype_tsig ((dns_rdatatype_t)dns_rdatatype_tsig) #define dns_rdatatype_dlv ((dns_rdatatype_t)dns_rdatatype_dlv) +#define dns_rdatatype_keydata ((dns_rdatatype_t)dns_rdatatype_keydata) #define dns_rdatatype_ixfr ((dns_rdatatype_t)dns_rdatatype_ixfr) #define dns_rdatatype_axfr ((dns_rdatatype_t)dns_rdatatype_axfr) #define dns_rdatatype_mailb ((dns_rdatatype_t)dns_rdatatype_mailb) diff --git a/lib/bind/dns/dns/rdatastruct.h b/lib/bind/dns/dns/rdatastruct.h index e7075c0..880beee 100644 --- a/lib/bind/dns/dns/rdatastruct.h +++ b/lib/bind/dns/dns/rdatastruct.h @@ -43,7 +43,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rdatastructpre.h,v 1.16 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: rdatastructpre.h,v 1.16 2007-06-19 23:47:17 tbox Exp $ */ #ifndef DNS_RDATASTRUCT_H #define DNS_RDATASTRUCT_H 1 @@ -89,7 +89,7 @@ typedef struct dns_rdatacommon { #ifndef IN_1_A_1_H #define IN_1_A_1_H 1 -/* $Id: a_1.h,v 1.28 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: a_1.h,v 1.28 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_in_a { dns_rdatacommon_t common; @@ -113,7 +113,7 @@ typedef struct dns_rdata_in_a { * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: a_1.h,v 1.5 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: a_1.h,v 1.5 2007-06-19 23:47:17 tbox Exp $ */ /* by Bjorn.Victor@it.uu.se, 2005-05-07 */ /* Based on generic/mx_15.h */ @@ -152,7 +152,7 @@ typedef struct dns_rdata_ch_a { #ifndef HS_4_A_1_H #define HS_4_A_1_H 1 -/* $Id: a_1.h,v 1.12 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: a_1.h,v 1.12 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_hs_a { dns_rdatacommon_t common; @@ -181,7 +181,7 @@ typedef struct dns_rdata_hs_a { #ifndef GENERIC_NS_2_H #define GENERIC_NS_2_H 1 -/* $Id: ns_2.h,v 1.27 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: ns_2.h,v 1.27 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_ns { dns_rdatacommon_t common; @@ -212,7 +212,7 @@ typedef struct dns_rdata_ns { #ifndef GENERIC_MD_3_H #define GENERIC_MD_3_H 1 -/* $Id: md_3.h,v 1.28 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: md_3.h,v 1.28 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_md { dns_rdatacommon_t common; @@ -243,7 +243,7 @@ typedef struct dns_rdata_md { #ifndef GENERIC_MF_4_H #define GENERIC_MF_4_H 1 -/* $Id: mf_4.h,v 1.26 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: mf_4.h,v 1.26 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_mf { dns_rdatacommon_t common; @@ -269,7 +269,7 @@ typedef struct dns_rdata_mf { * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: cname_5.h,v 1.26 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: cname_5.h,v 1.26 2007-06-19 23:47:17 tbox Exp $ */ #ifndef GENERIC_CNAME_5_H #define GENERIC_CNAME_5_H 1 @@ -302,7 +302,7 @@ typedef struct dns_rdata_cname { #ifndef GENERIC_SOA_6_H #define GENERIC_SOA_6_H 1 -/* $Id: soa_6.h,v 1.32 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: soa_6.h,v 1.32 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_soa { dns_rdatacommon_t common; @@ -339,7 +339,7 @@ typedef struct dns_rdata_soa { #ifndef GENERIC_MB_7_H #define GENERIC_MB_7_H 1 -/* $Id: mb_7.h,v 1.27 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: mb_7.h,v 1.27 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_mb { dns_rdatacommon_t common; @@ -369,7 +369,7 @@ typedef struct dns_rdata_mb { #ifndef GENERIC_MG_8_H #define GENERIC_MG_8_H 1 -/* $Id: mg_8.h,v 1.26 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: mg_8.h,v 1.26 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_mg { dns_rdatacommon_t common; @@ -399,7 +399,7 @@ typedef struct dns_rdata_mg { #ifndef GENERIC_MR_9_H #define GENERIC_MR_9_H 1 -/* $Id: mr_9.h,v 1.26 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: mr_9.h,v 1.26 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_mr { dns_rdatacommon_t common; @@ -429,7 +429,7 @@ typedef struct dns_rdata_mr { #ifndef GENERIC_NULL_10_H #define GENERIC_NULL_10_H 1 -/* $Id: null_10.h,v 1.25 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: null_10.h,v 1.25 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_null { dns_rdatacommon_t common; @@ -460,7 +460,7 @@ typedef struct dns_rdata_null { #ifndef IN_1_WKS_11_H #define IN_1_WKS_11_H 1 -/* $Id: wks_11.h,v 1.22 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: wks_11.h,v 1.22 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_in_wks { dns_rdatacommon_t common; @@ -493,7 +493,7 @@ typedef struct dns_rdata_in_wks { #ifndef GENERIC_PTR_12_H #define GENERIC_PTR_12_H 1 -/* $Id: ptr_12.h,v 1.27 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: ptr_12.h,v 1.27 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_ptr { dns_rdatacommon_t common; @@ -522,7 +522,7 @@ typedef struct dns_rdata_ptr { #ifndef GENERIC_HINFO_13_H #define GENERIC_HINFO_13_H 1 -/* $Id: hinfo_13.h,v 1.25 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: hinfo_13.h,v 1.25 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_hinfo { dns_rdatacommon_t common; @@ -555,7 +555,7 @@ typedef struct dns_rdata_hinfo { #ifndef GENERIC_MINFO_14_H #define GENERIC_MINFO_14_H 1 -/* $Id: minfo_14.h,v 1.27 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: minfo_14.h,v 1.27 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_minfo { dns_rdatacommon_t common; @@ -586,7 +586,7 @@ typedef struct dns_rdata_minfo { #ifndef GENERIC_MX_15_H #define GENERIC_MX_15_H 1 -/* $Id: mx_15.h,v 1.29 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: mx_15.h,v 1.29 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_mx { dns_rdatacommon_t common; @@ -617,7 +617,7 @@ typedef struct dns_rdata_mx { #ifndef GENERIC_TXT_16_H #define GENERIC_TXT_16_H 1 -/* $Id: txt_16.h,v 1.28 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: txt_16.h,v 1.28 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_txt_string { isc_uint8_t length; @@ -668,7 +668,7 @@ dns_rdata_txt_current(dns_rdata_txt_t *, dns_rdata_txt_string_t *); #ifndef GENERIC_RP_17_H #define GENERIC_RP_17_H 1 -/* $Id: rp_17.h,v 1.21 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: rp_17.h,v 1.21 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief Per RFC1183 */ @@ -702,7 +702,7 @@ typedef struct dns_rdata_rp { #ifndef GENERIC_AFSDB_18_H #define GENERIC_AFSDB_18_H 1 -/* $Id: afsdb_18.h,v 1.20 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: afsdb_18.h,v 1.20 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief Per RFC1183 */ @@ -736,7 +736,7 @@ typedef struct dns_rdata_afsdb { #ifndef GENERIC_X25_19_H #define GENERIC_X25_19_H 1 -/* $Id: x25_19.h,v 1.18 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: x25_19.h,v 1.18 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief Per RFC1183 */ @@ -769,7 +769,7 @@ typedef struct dns_rdata_x25 { #ifndef GENERIC_ISDN_20_H #define GENERIC_ISDN_20_H 1 -/* $Id: isdn_20.h,v 1.18 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: isdn_20.h,v 1.18 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief Per RFC1183 */ @@ -804,7 +804,7 @@ typedef struct dns_rdata_isdn { #ifndef GENERIC_RT_21_H #define GENERIC_RT_21_H 1 -/* $Id: rt_21.h,v 1.21 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: rt_21.h,v 1.21 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief Per RFC1183 */ @@ -837,7 +837,7 @@ typedef struct dns_rdata_rt { #ifndef IN_1_NSAP_22_H #define IN_1_NSAP_22_H 1 -/* $Id: nsap_22.h,v 1.18 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: nsap_22.h,v 1.18 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief Per RFC1706 */ @@ -870,7 +870,7 @@ typedef struct dns_rdata_in_nsap { #ifndef IN_1_NSAP_PTR_23_H #define IN_1_NSAP_PTR_23_H 1 -/* $Id: nsap-ptr_23.h,v 1.19 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: nsap-ptr_23.h,v 1.19 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief Per RFC1348. Obsoleted in RFC 1706 - use PTR instead. */ @@ -902,7 +902,7 @@ typedef struct dns_rdata_in_nsap_ptr { #ifndef GENERIC_SIG_24_H #define GENERIC_SIG_24_H 1 -/* $Id: sig_24.h,v 1.26 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: sig_24.h,v 1.26 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief Per RFC2535 */ @@ -944,7 +944,7 @@ typedef struct dns_rdata_sig_t { #ifndef GENERIC_KEY_25_H #define GENERIC_KEY_25_H 1 -/* $Id: key_25.h,v 1.19 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: key_25.h,v 1.19 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief Per RFC2535 */ @@ -981,7 +981,7 @@ typedef struct dns_rdata_key_t { #ifndef IN_1_PX_26_H #define IN_1_PX_26_H 1 -/* $Id: px_26.h,v 1.19 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: px_26.h,v 1.19 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief Per RFC2163 */ @@ -1015,7 +1015,7 @@ typedef struct dns_rdata_in_px { #ifndef GENERIC_GPOS_27_H #define GENERIC_GPOS_27_H 1 -/* $Id: gpos_27.h,v 1.17 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: gpos_27.h,v 1.17 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief per RFC1712 */ @@ -1052,7 +1052,7 @@ typedef struct dns_rdata_gpos { #ifndef IN_1_AAAA_28_H #define IN_1_AAAA_28_H 1 -/* $Id: aaaa_28.h,v 1.21 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: aaaa_28.h,v 1.21 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief Per RFC1886 */ @@ -1083,7 +1083,7 @@ typedef struct dns_rdata_in_aaaa { #ifndef GENERIC_LOC_29_H #define GENERIC_LOC_29_H 1 -/* $Id: loc_29.h,v 1.19 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: loc_29.h,v 1.19 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief Per RFC1876 */ @@ -1126,7 +1126,7 @@ typedef struct dns_rdata_loc { #ifndef GENERIC_NXT_30_H #define GENERIC_NXT_30_H 1 -/* $Id: nxt_30.h,v 1.25 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: nxt_30.h,v 1.25 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief RFC2535 */ @@ -1160,7 +1160,7 @@ typedef struct dns_rdata_nxt { #ifndef IN_1_SRV_33_H #define IN_1_SRV_33_H 1 -/* $Id: srv_33.h,v 1.19 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: srv_33.h,v 1.19 2007-06-19 23:47:17 tbox Exp $ */ /* Reviewed: Fri Mar 17 13:01:00 PST 2000 by bwelling */ @@ -1197,7 +1197,7 @@ typedef struct dns_rdata_in_srv { #ifndef IN_1_NAPTR_35_H #define IN_1_NAPTR_35_H 1 -/* $Id: naptr_35.h,v 1.23 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: naptr_35.h,v 1.23 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief Per RFC2915 */ @@ -1237,7 +1237,7 @@ typedef struct dns_rdata_in_naptr { #ifndef IN_1_KX_36_H #define IN_1_KX_36_H 1 -/* $Id: kx_36.h,v 1.20 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: kx_36.h,v 1.20 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief Per RFC2230 */ @@ -1267,7 +1267,7 @@ typedef struct dns_rdata_in_kx { * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: cert_37.h,v 1.20 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: cert_37.h,v 1.20 2007-06-19 23:47:17 tbox Exp $ */ #ifndef GENERIC_CERT_37_H #define GENERIC_CERT_37_H 1 @@ -1304,7 +1304,7 @@ typedef struct dns_rdata_cert { #ifndef IN_1_A6_38_H #define IN_1_A6_38_H 1 -/* $Id: a6_38.h,v 1.24 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: a6_38.h,v 1.24 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief Per RFC2874 */ @@ -1338,7 +1338,7 @@ typedef struct dns_rdata_in_a6 { #ifndef GENERIC_DNAME_39_H #define GENERIC_DNAME_39_H 1 -/* $Id: dname_39.h,v 1.21 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: dname_39.h,v 1.21 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief per RFC2672 */ @@ -1370,7 +1370,7 @@ typedef struct dns_rdata_dname { #ifndef GENERIC_OPT_41_H #define GENERIC_OPT_41_H 1 -/* $Id: opt_41.h,v 1.18 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: opt_41.h,v 1.18 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief Per RFC2671 */ @@ -1426,7 +1426,7 @@ dns_rdata_opt_current(dns_rdata_opt_t *, dns_rdata_opt_opcode_t *); #ifndef IN_1_APL_42_H #define IN_1_APL_42_H 1 -/* $Id: apl_42.h,v 1.6 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: apl_42.h,v 1.6 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_apl_ent { isc_boolean_t negative; @@ -1478,7 +1478,7 @@ dns_rdata_apl_current(dns_rdata_in_apl_t *, dns_rdata_apl_ent_t *); * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ds_43.h,v 1.7 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: ds_43.h,v 1.7 2007-06-19 23:47:17 tbox Exp $ */ #ifndef GENERIC_DS_43_H #define GENERIC_DS_43_H 1 @@ -1513,7 +1513,7 @@ typedef struct dns_rdata_ds { * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sshfp_44.h,v 1.8 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: sshfp_44.h,v 1.8 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief Per RFC 4255 */ @@ -1547,7 +1547,7 @@ typedef struct dns_rdata_sshfp { * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ipseckey_45.h,v 1.4 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: ipseckey_45.h,v 1.4 2007-06-19 23:47:17 tbox Exp $ */ #ifndef GENERIC_IPSECKEY_45_H #define GENERIC_IPSECKEY_45_H 1 @@ -1586,7 +1586,7 @@ typedef struct dns_rdata_ipseckey { #ifndef GENERIC_DNSSIG_46_H #define GENERIC_DNSSIG_46_H 1 -/* $Id: rrsig_46.h,v 1.7 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: rrsig_46.h,v 1.7 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief Per RFC2535 */ @@ -1627,7 +1627,7 @@ typedef struct dns_rdata_rrsig { #ifndef GENERIC_NSEC_47_H #define GENERIC_NSEC_47_H 1 -/* $Id: nsec_47.h,v 1.10 2008/07/15 23:47:21 tbox Exp $ */ +/* $Id: nsec_47.h,v 1.10 2008-07-15 23:47:21 tbox Exp $ */ /*! * \brief Per RFC 3845 */ @@ -1661,7 +1661,7 @@ typedef struct dns_rdata_nsec { #ifndef GENERIC_DNSKEY_48_H #define GENERIC_DNSKEY_48_H 1 -/* $Id: dnskey_48.h,v 1.7 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: dnskey_48.h,v 1.7 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief per RFC2535 */ @@ -1698,7 +1698,7 @@ typedef struct dns_rdata_dnskey { #ifndef IN_1_DHCID_49_H #define IN_1_DHCID_49_H 1 -/* $Id: dhcid_49.h,v 1.5 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: dhcid_49.h,v 1.5 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_in_dhcid { dns_rdatacommon_t common; @@ -1728,7 +1728,7 @@ typedef struct dns_rdata_in_dhcid { #ifndef GENERIC_NSEC3_50_H #define GENERIC_NSEC3_50_H 1 -/* $Id: nsec3_50.h,v 1.4 2008/09/25 04:02:39 tbox Exp $ */ +/* $Id: nsec3_50.h,v 1.4 2008-09-25 04:02:39 tbox Exp $ */ /*! * \brief Per RFC 5155 */ @@ -1821,7 +1821,7 @@ typedef struct dns_rdata_nsec3 { #ifndef GENERIC_NSEC3PARAM_51_H #define GENERIC_NSEC3PARAM_51_H 1 -/* $Id: nsec3param_51.h,v 1.4 2008/09/25 04:02:39 tbox Exp $ */ +/* $Id: nsec3param_51.h,v 1.4 2008-09-25 04:02:39 tbox Exp $ */ /*! * \brief Per RFC 5155 */ @@ -1840,6 +1840,53 @@ typedef struct dns_rdata_nsec3param { #endif /* GENERIC_NSEC3PARAM_51_H */ /* + * Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC") + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: hip_55.h,v 1.2 2009-02-26 06:09:19 marka Exp $ */ + +#ifndef GENERIC_HIP_5_H +#define GENERIC_HIP_5_H 1 + +/* RFC 5205 */ + +typedef struct dns_rdata_hip { + dns_rdatacommon_t common; + isc_mem_t * mctx; + unsigned char * hit; + unsigned char * key; + unsigned char * servers; + isc_uint8_t algorithm; + isc_uint8_t hit_len; + isc_uint16_t key_len; + isc_uint16_t servers_len; + /* Private */ + isc_uint16_t offset; +} dns_rdata_hip_t; + +isc_result_t +dns_rdata_hip_first(dns_rdata_hip_t *); + +isc_result_t +dns_rdata_hip_next(dns_rdata_hip_t *); + +void +dns_rdata_hip_current(dns_rdata_hip_t *, dns_name_t *); + +#endif /* GENERIC_HIP_5_H */ +/* * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1998-2001 Internet Software Consortium. * @@ -1859,7 +1906,7 @@ typedef struct dns_rdata_nsec3param { #ifndef GENERIC_SPF_99_H #define GENERIC_SPF_99_H 1 -/* $Id: spf_99.h,v 1.4 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: spf_99.h,v 1.4 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_spf_string { isc_uint8_t length; @@ -1911,7 +1958,7 @@ dns_rdata_spf_current(dns_rdata_spf_t *, dns_rdata_spf_string_t *); #ifndef GENERIC_UNSPEC_103_H #define GENERIC_UNSPEC_103_H 1 -/* $Id: unspec_103.h,v 1.17 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: unspec_103.h,v 1.17 2007-06-19 23:47:17 tbox Exp $ */ typedef struct dns_rdata_unspec_t { dns_rdatacommon_t common; @@ -1941,7 +1988,7 @@ typedef struct dns_rdata_unspec_t { #ifndef GENERIC_TKEY_249_H #define GENERIC_TKEY_249_H 1 -/* $Id: tkey_249.h,v 1.24 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: tkey_249.h,v 1.24 2007-06-19 23:47:17 tbox Exp $ */ /*! * \brief Per draft-ietf-dnsind-tkey-00.txt */ @@ -1979,7 +2026,7 @@ typedef struct dns_rdata_tkey { * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: tsig_250.h,v 1.25 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: tsig_250.h,v 1.25 2007-06-19 23:47:17 tbox Exp $ */ #ifndef ANY_255_TSIG_250_H #define ANY_255_TSIG_250_H 1 @@ -2016,7 +2063,7 @@ typedef struct dns_rdata_any_tsig { * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dlv_32769.h,v 1.5 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: dlv_32769.h,v 1.5 2007-06-19 23:47:17 tbox Exp $ */ /* draft-ietf-dnsext-delegation-signer-05.txt */ #ifndef GENERIC_DLV_32769_H @@ -2034,6 +2081,41 @@ typedef struct dns_rdata_dlv { #endif /* GENERIC_DLV_32769_H */ /* + * Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC") + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef GENERIC_KEYDATA_65533_H +#define GENERIC_KEYDATA_65533_H 1 + +/* $Id: keydata_65533.h,v 1.2 2009-06-30 02:52:32 each Exp $ */ + +typedef struct dns_rdata_keydata { + dns_rdatacommon_t common; + isc_mem_t * mctx; + isc_uint32_t refresh; /* Timer for refreshing data */ + isc_uint32_t addhd; /* Hold-down timer for adding */ + isc_uint32_t removehd; /* Hold-down timer for removing */ + isc_uint16_t flags; /* Copy of DNSKEY_48 */ + isc_uint8_t protocol; + isc_uint8_t algorithm; + isc_uint16_t datalen; + unsigned char * data; +} dns_rdata_keydata_t; + +#endif /* GENERIC_KEYDATA_65533_H */ +/* * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2001 Internet Software Consortium. * @@ -2050,7 +2132,7 @@ typedef struct dns_rdata_dlv { * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rdatastructsuf.h,v 1.10 2007/06/19 23:47:17 tbox Exp $ */ +/* $Id: rdatastructsuf.h,v 1.10 2007-06-19 23:47:17 tbox Exp $ */ ISC_LANG_ENDDECLS diff --git a/lib/bind/isc/Makefile b/lib/bind/isc/Makefile index 7648da5..f41f604 100644 --- a/lib/bind/isc/Makefile +++ b/lib/bind/isc/Makefile @@ -27,18 +27,26 @@ SRCS+= condition.c mutex.c \ .PATH: ${SRCDIR} SRCS+= inet_pton.c \ - assertions.c base32.c base64.c bitstring.c buffer.c \ - bufferlist.c commandline.c entropy.c error.c event.c \ - fsaccess.c hash.c heap.c hex.c hmacmd5.c hmacsha.c \ - httpd.c inet_aton.c inet_ntop.c iterated_hash.c \ + assertions.c backtrace.c base32.c base64.c bitstring.c \ + buffer.c bufferlist.c commandline.c error.c event.c \ + fsaccess.c hash.c \ + heap.c hex.c hmacmd5.c hmacsha.c \ + httpd.c inet_aton.c \ + inet_ntop.c \ + iterated_hash.c \ lex.c lfsr.c lib.c log.c \ md5.c mem.c mutexblock.c \ netaddr.c netscope.c ondestroy.c \ - parseint.c portset.c print.c quota.c radix.c random.c \ + parseint.c portset.c \ + print.c \ + quota.c radix.c random.c \ ratelimiter.c refcount.c region.c result.c rwlock.c \ serial.c sha1.c sha2.c sockaddr.c stats.c string.c strtoul.c \ symtab.c task.c taskpool.c timer.c version.c +.PATH: ${.CURDIR} +SRCS+= backtrace-emptytbl.c + CFLAGS+= -I${SRCDIR}/unix/include -I${SRCDIR}/pthreads/include CFLAGS+= -I${SRCDIR}/include -I${.CURDIR} CFLAGS+= -I${SRCDIR}/${ISC_ATOMIC_ARCH}/include @@ -51,6 +59,7 @@ INCS= ${SRCDIR}/include/isc/app.h \ ${SRCDIR}/include/isc/assertions.h \ ${SRCDIR}/include/isc/base32.h \ ${SRCDIR}/include/isc/base64.h \ + ${SRCDIR}/include/isc/bind9.h \ ${SRCDIR}/include/isc/bitstring.h \ ${SRCDIR}/include/isc/boolean.h \ ${SRCDIR}/include/isc/buffer.h \ @@ -84,6 +93,7 @@ INCS= ${SRCDIR}/include/isc/app.h \ ${SRCDIR}/include/isc/msgcat.h \ ${SRCDIR}/include/isc/msgs.h \ ${SRCDIR}/include/isc/mutexblock.h \ + ${SRCDIR}/include/isc/namespace.h \ ${SRCDIR}/include/isc/netaddr.h \ ${SRCDIR}/include/isc/netscope.h \ ${SRCDIR}/include/isc/ondestroy.h \ diff --git a/lib/bind/isc/backtrace-emptytbl.c b/lib/bind/isc/backtrace-emptytbl.c new file mode 100644 index 0000000..9c50d95 --- /dev/null +++ b/lib/bind/isc/backtrace-emptytbl.c @@ -0,0 +1,36 @@ +/* $FreeBSD$ */ + +/* + * Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC") + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* $Id: backtrace-emptytbl.c,v 1.3 2009-09-01 20:13:44 each Exp $ */ + +/*! \file */ + +/* + * This file defines an empty (default) symbol table used in backtrace.c + * If the application wants to have a complete symbol table, it should redefine + * isc__backtrace_symtable with the complete table in some way, and link the + * version of the library not including this definition + * (e.g. libisc-nosymbol.a). + */ + +#include <config.h> + +#include <isc/backtrace.h> + +const int isc__backtrace_nsymbols = 0; +const isc_backtrace_symmap_t isc__backtrace_symtable[] = { { NULL, "" } }; diff --git a/lib/bind/isc/isc/platform.h b/lib/bind/isc/isc/platform.h index 2ac5042..7dab495 100644 --- a/lib/bind/isc/isc/platform.h +++ b/lib/bind/isc/isc/platform.h @@ -1,6 +1,5 @@ /* $FreeBSD$ */ - /* * Copyright (C) 2004-2010 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. @@ -18,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: platform.h.in,v 1.48.84.4 2010-06-03 23:47:49 tbox Exp $ */ +/* $Id: platform.h.in,v 1.56 2010-12-18 01:56:23 each Exp $ */ #ifndef ISC_PLATFORM_H #define ISC_PLATFORM_H 1 @@ -149,6 +148,11 @@ */ #undef ISC_PLATFORM_HAVEDEVPOLL +/*! \brief + * Define if we want to log backtrace + */ +#define ISC_PLATFORM_USEBACKTRACE 1 + /* *** Printing. ***/ @@ -218,6 +222,12 @@ /* + * Defined to <gssapi_krb5.h> or <gssapi/gssapi_krb5.h> for how to + * include the GSSAPI KRB5 header. + */ + + +/* * Defined to <krb5.h> or <krb5/krb5.h> for how to include * the KRB5 header. */ @@ -253,7 +263,14 @@ * If the "xadd" operation is available on this architecture, * ISC_PLATFORM_HAVEXADD will be defined. */ +/* + * FreeBSD local modification, preserve this over upgrades + */ +#if defined (__i386__) || defined (__amd64__) || defined (__ia64__) #define ISC_PLATFORM_HAVEXADD 1 +#else +#undef ISC_PLATFORM_HAVEXADD +#endif /* * If the "xaddq" operation (64bit xadd) is available on this architecture, @@ -272,18 +289,39 @@ * If the "atomic swap" operation is available on this architecture, * ISC_PLATFORM_HAVEATOMICSTORE" will be defined. */ +/* + * FreeBSD local modification, preserve this over upgrades + */ +#if defined (__i386__) || defined (__amd64__) || defined (__ia64__) #define ISC_PLATFORM_HAVEATOMICSTORE 1 +#else +#undef ISC_PLATFORM_HAVEATOMICSTORE +#endif /* * If the "compare-and-exchange" operation is available on this architecture, * ISC_PLATFORM_HAVECMPXCHG will be defined. */ +/* + * FreeBSD local modification, preserve this over upgrades + */ +#if defined (__i386__) || defined (__amd64__) || defined (__ia64__) #define ISC_PLATFORM_HAVECMPXCHG 1 +#else +#undef ISC_PLATFORM_HAVECMPXCHG +#endif /* * Define if gcc ASM extension is available */ +/* + * FreeBSD local modification, preserve this over upgrades + */ +#if defined (__i386__) || defined (__amd64__) || defined (__ia64__) #define ISC_PLATFORM_USEGCCASM 1 +#else +#undef ISC_PLATFORM_USEGCCASM +#endif /* * Define if Tru64 style ASM syntax must be used. @@ -300,6 +338,17 @@ */ #define ISC_PLATFORM_HAVESTRINGSH 1 +/* + * Define if the hash functions must be provided by OpenSSL. + */ +#undef ISC_PLATFORM_OPENSSLHASH + +/* + * Defines for the noreturn attribute. + */ +#define ISC_PLATFORM_NORETURN_PRE +#define ISC_PLATFORM_NORETURN_POST __attribute__((noreturn)) + /*** *** Windows dll support. ***/ diff --git a/lib/bind/lwres/lwres/netdb.h b/lib/bind/lwres/lwres/netdb.h index cb5cc28..59ad93a 100644 --- a/lib/bind/lwres/lwres/netdb.h +++ b/lib/bind/lwres/lwres/netdb.h @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: netdb.h.in,v 1.39.332.2 2009/01/18 23:47:41 tbox Exp $ */ +/* $Id: netdb.h.in,v 1.41 2009-01-18 23:48:14 tbox Exp $ */ /*! \file */ diff --git a/lib/bind/lwres/lwres/platform.h b/lib/bind/lwres/lwres/platform.h index 608bb72..9f207db 100644 --- a/lib/bind/lwres/lwres/platform.h +++ b/lib/bind/lwres/lwres/platform.h @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: platform.h.in,v 1.21 2007/06/19 23:47:23 tbox Exp $ */ +/* $Id: platform.h.in,v 1.21 2007-06-19 23:47:23 tbox Exp $ */ /*! \file */ diff --git a/lib/clang/Makefile b/lib/clang/Makefile index 212c7c8b..abcc113 100644 --- a/lib/clang/Makefile +++ b/lib/clang/Makefile @@ -2,6 +2,7 @@ .if !make(install) SUBDIR= libclanganalysis \ + libclangarcmigrate \ libclangast \ libclangbasic \ libclangcodegen \ @@ -39,16 +40,21 @@ SUBDIR= libclanganalysis \ \ libllvmarmasmparser \ libllvmarmcodegen \ + libllvmarmdesc \ libllvmarmdisassembler \ libllvmarminfo \ libllvmarminstprinter \ libllvmmipscodegen \ + libllvmmipsdesc \ libllvmmipsinfo \ + libllvmmipsinstprinter \ libllvmpowerpccodegen \ + libllvmpowerpcdesc \ libllvmpowerpcinfo \ libllvmpowerpcinstprinter \ libllvmx86asmparser \ libllvmx86codegen \ + libllvmx86desc \ libllvmx86disassembler \ libllvmx86info \ libllvmx86instprinter \ diff --git a/lib/clang/clang.build.mk b/lib/clang/clang.build.mk index f443f1d..17b47c3 100644 --- a/lib/clang/clang.build.mk +++ b/lib/clang/clang.build.mk @@ -34,11 +34,12 @@ CFLAGS+=-DCLANG_PREFIX=\"${TOOLS_PREFIX}\" .PATH: ${LLVM_SRCS}/${SRCDIR} -TBLGEN=tblgen ${CFLAGS:M-I*} +TBLGEN?=tblgen +TBLINC+=-I ${LLVM_SRCS}/include -I ${LLVM_SRCS}/lib/Target Intrinsics.inc.h: ${LLVM_SRCS}/include/llvm/Intrinsics.td - ${TBLGEN} -gen-intrinsic \ - ${LLVM_SRCS}/include/llvm/Intrinsics.td > ${.TARGET} + ${TBLGEN} -I ${LLVM_SRCS}/lib/VMCore ${TBLINC} -gen-intrinsic \ + -o ${.TARGET} ${LLVM_SRCS}/include/llvm/Intrinsics.td .for arch in \ ARM/ARM Mips/Mips PowerPC/PPC X86/X86 . for hdr in \ @@ -51,79 +52,97 @@ Intrinsics.inc.h: ${LLVM_SRCS}/include/llvm/Intrinsics.td DisassemblerTables/-gen-disassembler \ EDInfo/-gen-enhanced-disassembly-info \ FastISel/-gen-fast-isel \ - InstrInfo/-gen-instr-desc \ - InstrNames/-gen-instr-enums \ + InstrInfo/-gen-instr-info \ MCCodeEmitter/-gen-emitter,-mc-emitter \ - RegisterInfo.h/-gen-register-desc-header \ - RegisterInfo/-gen-register-desc \ - RegisterNames/-gen-register-enums \ - Subtarget/-gen-subtarget + MCPseudoLowering/-gen-pseudo-lowering \ + RegisterInfo/-gen-register-info \ + SubtargetInfo/-gen-subtarget ${arch:T}Gen${hdr:H:C/$/.inc.h/}: ${LLVM_SRCS}/lib/Target/${arch:H}/${arch:T}.td - ${TBLGEN} ${hdr:T:C/,/ /g} \ - ${LLVM_SRCS}/lib/Target/${arch:H}/${arch:T}.td > ${.TARGET} + ${TBLGEN} -I ${LLVM_SRCS}/lib/Target/${arch:H} ${TBLINC} \ + ${hdr:T:C/,/ /g} -o ${.TARGET} \ + ${LLVM_SRCS}/lib/Target/${arch:H}/${arch:T}.td . endfor .endfor ARMGenDecoderTables.inc.h: ${LLVM_SRCS}/lib/Target/ARM/ARM.td - ${TBLGEN} -gen-arm-decoder ${.ALLSRC} > ${.TARGET} + ${TBLGEN} -I ${LLVM_SRCS}/lib/Target/ARM ${TBLINC} \ + -gen-arm-decoder -o ${.TARGET} ${.ALLSRC} Attrs.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td - ${TBLGEN} -gen-clang-attr-classes ${.ALLSRC} > ${.TARGET} + ${TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \ + -gen-clang-attr-classes -o ${.TARGET} \ + -I ${CLANG_SRCS}/include ${.ALLSRC} AttrImpl.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td - ${TBLGEN} -gen-clang-attr-impl ${.ALLSRC} > ${.TARGET} + ${TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \ + -gen-clang-attr-impl -o ${.TARGET} \ + -I ${CLANG_SRCS}/include ${.ALLSRC} AttrList.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td - ${TBLGEN} -gen-clang-attr-list ${.ALLSRC} > ${.TARGET} + ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \ + -gen-clang-attr-list -o ${.TARGET} \ + -I ${CLANG_SRCS}/include ${.ALLSRC} AttrPCHRead.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td - ${TBLGEN} -gen-clang-attr-pch-read ${.ALLSRC} > ${.TARGET} + ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Serialization \ + ${TBLINC} -gen-clang-attr-pch-read -o ${.TARGET} \ + -I ${CLANG_SRCS}/include ${.ALLSRC} AttrPCHWrite.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td - ${TBLGEN} -gen-clang-attr-pch-write ${.ALLSRC} > ${.TARGET} + ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Serialization \ + ${TBLINC} -gen-clang-attr-pch-write -o ${.TARGET} \ + -I ${CLANG_SRCS}/include ${.ALLSRC} AttrSpellings.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td - ${TBLGEN} -gen-clang-attr-spelling-list ${.ALLSRC} > ${.TARGET} + ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Lex ${TBLINC} \ + -gen-clang-attr-spelling-list -o ${.TARGET} \ + -I ${CLANG_SRCS}/include ${.ALLSRC} DeclNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/DeclNodes.td - ${TBLGEN} -gen-clang-decl-nodes ${.ALLSRC} > ${.TARGET} + ${TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \ + -gen-clang-decl-nodes -o ${.TARGET} ${.ALLSRC} StmtNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/StmtNodes.td - ${TBLGEN} -gen-clang-stmt-nodes ${.ALLSRC} > ${.TARGET} + ${TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \ + -gen-clang-stmt-nodes -o ${.TARGET} ${.ALLSRC} arm_neon.inc.h: ${CLANG_SRCS}/include/clang/Basic/arm_neon.td - ${TBLGEN} -gen-arm-neon-sema ${.ALLSRC} > ${.TARGET} + ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \ + -gen-arm-neon-sema -o ${.TARGET} ${.ALLSRC} DiagnosticGroups.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td - ${TBLGEN} -gen-clang-diag-groups -I${CLANG_SRCS}/include/clang/Basic \ - ${.ALLSRC} > ${.TARGET} + ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \ + -gen-clang-diag-groups -o ${.TARGET} ${.ALLSRC} DiagnosticIndexName.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td - ${TBLGEN} -gen-clang-diags-index-name \ - -I${CLANG_SRCS}/include/clang/Basic ${.ALLSRC} > ${.TARGET} + ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \ + -gen-clang-diags-index-name -o ${.TARGET} ${.ALLSRC} .for hdr in AST Analysis Common Driver Frontend Lex Parse Sema Diagnostic${hdr}Kinds.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td - ${TBLGEN} -gen-clang-diags-defs -clang-component=${hdr} \ - -I${CLANG_SRCS}/include/clang/Basic ${.ALLSRC} > ${.TARGET} + ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \ + -gen-clang-diags-defs -clang-component=${hdr} \ + -o ${.TARGET} ${.ALLSRC} .endfor Options.inc.h: ${CLANG_SRCS}/include/clang/Driver/Options.td - ${TBLGEN} -gen-opt-parser-defs -I${CLANG_SRCS}/include/clang/Driver \ - ${.ALLSRC} > ${.TARGET} + ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Driver ${TBLINC} \ + -gen-opt-parser-defs -o ${.TARGET} ${.ALLSRC} CC1Options.inc.h: ${CLANG_SRCS}/include/clang/Driver/CC1Options.td - ${TBLGEN} -gen-opt-parser-defs -I${CLANG_SRCS}/include/clang/Driver \ - ${.ALLSRC} > ${.TARGET} + ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Driver ${TBLINC} \ + -gen-opt-parser-defs -o ${.TARGET} ${.ALLSRC} CC1AsOptions.inc.h: ${CLANG_SRCS}/include/clang/Driver/CC1AsOptions.td - ${TBLGEN} -gen-opt-parser-defs -I${CLANG_SRCS}/include/clang/Driver \ - ${.ALLSRC} > ${.TARGET} + ${TBLGEN} -I ${CLANG_SRCS}/include/clang/Driver ${TBLINC} \ + -gen-opt-parser-defs -o ${.TARGET} ${.ALLSRC} Checkers.inc.h: ${CLANG_SRCS}/lib/StaticAnalyzer/Checkers/Checkers.td \ ${CLANG_SRCS}/include/clang/StaticAnalyzer/Checkers/CheckerBase.td - ${TBLGEN} -gen-clang-sa-checkers -I${CLANG_SRCS}/include \ - ${CLANG_SRCS}/lib/StaticAnalyzer/Checkers/Checkers.td > ${.TARGET} + ${TBLGEN} -I ${CLANG_SRCS}/lib/StaticAnalyzer/Checkers \ + ${TBLINC} -gen-clang-sa-checkers -o ${.TARGET} \ + -I ${CLANG_SRCS}/include \ + ${CLANG_SRCS}/lib/StaticAnalyzer/Checkers/Checkers.td SRCS+= ${TGHDRS:C/$/.inc.h/} DPADD+= ${TGHDRS:C/$/.inc.h/} diff --git a/lib/clang/include/ARMGenInstrNames.inc b/lib/clang/include/ARMGenInstrNames.inc deleted file mode 100644 index 9ecc271..0000000 --- a/lib/clang/include/ARMGenInstrNames.inc +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -#include "ARMGenInstrNames.inc.h" diff --git a/lib/clang/include/ARMGenMCPseudoLowering.inc b/lib/clang/include/ARMGenMCPseudoLowering.inc new file mode 100644 index 0000000..aa3b617 --- /dev/null +++ b/lib/clang/include/ARMGenMCPseudoLowering.inc @@ -0,0 +1,2 @@ +/* $FreeBSD$ */ +#include "ARMGenMCPseudoLowering.inc.h" diff --git a/lib/clang/include/ARMGenRegisterInfo.h.inc b/lib/clang/include/ARMGenRegisterInfo.h.inc deleted file mode 100644 index 03bd3a2..0000000 --- a/lib/clang/include/ARMGenRegisterInfo.h.inc +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -#include "ARMGenRegisterInfo.h.inc.h" diff --git a/lib/clang/include/ARMGenRegisterNames.inc b/lib/clang/include/ARMGenRegisterNames.inc deleted file mode 100644 index 7eb6a0d..0000000 --- a/lib/clang/include/ARMGenRegisterNames.inc +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -#include "ARMGenRegisterNames.inc.h" diff --git a/lib/clang/include/ARMGenSubtarget.inc b/lib/clang/include/ARMGenSubtarget.inc deleted file mode 100644 index 55d5e8e..0000000 --- a/lib/clang/include/ARMGenSubtarget.inc +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -#include "ARMGenSubtarget.inc.h" diff --git a/lib/clang/include/ARMGenSubtargetInfo.inc b/lib/clang/include/ARMGenSubtargetInfo.inc new file mode 100644 index 0000000..6579d9f --- /dev/null +++ b/lib/clang/include/ARMGenSubtargetInfo.inc @@ -0,0 +1,2 @@ +/* $FreeBSD$ */ +#include "ARMGenSubtargetInfo.inc.h" diff --git a/lib/clang/include/IA64GenInstrNames.inc b/lib/clang/include/IA64GenInstrNames.inc deleted file mode 100644 index 6b2c58e..0000000 --- a/lib/clang/include/IA64GenInstrNames.inc +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -#include "IA64GenInstrNames.inc.h" diff --git a/lib/clang/include/IA64GenRegisterInfo.h.inc b/lib/clang/include/IA64GenRegisterInfo.h.inc deleted file mode 100644 index 38086d4..0000000 --- a/lib/clang/include/IA64GenRegisterInfo.h.inc +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -#include "IA64GenRegisterInfo.h.inc.h" diff --git a/lib/clang/include/IA64GenRegisterNames.inc b/lib/clang/include/IA64GenRegisterNames.inc deleted file mode 100644 index d1f0970..0000000 --- a/lib/clang/include/IA64GenRegisterNames.inc +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -#include "IA64GenRegisterNames.inc.h" diff --git a/lib/clang/include/MipsGenInstrNames.inc b/lib/clang/include/MipsGenInstrNames.inc deleted file mode 100644 index 78759ee..0000000 --- a/lib/clang/include/MipsGenInstrNames.inc +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -#include "MipsGenInstrNames.inc.h" diff --git a/lib/clang/include/MipsGenRegisterInfo.h.inc b/lib/clang/include/MipsGenRegisterInfo.h.inc deleted file mode 100644 index af66c5f..0000000 --- a/lib/clang/include/MipsGenRegisterInfo.h.inc +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -#include "MipsGenRegisterInfo.h.inc.h" diff --git a/lib/clang/include/MipsGenRegisterNames.inc b/lib/clang/include/MipsGenRegisterNames.inc deleted file mode 100644 index 3b00971..0000000 --- a/lib/clang/include/MipsGenRegisterNames.inc +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -#include "MipsGenRegisterNames.inc.h" diff --git a/lib/clang/include/MipsGenSubtarget.inc b/lib/clang/include/MipsGenSubtarget.inc deleted file mode 100644 index 9fb4a70..0000000 --- a/lib/clang/include/MipsGenSubtarget.inc +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -#include "MipsGenSubtarget.inc.h" diff --git a/lib/clang/include/MipsGenSubtargetInfo.inc b/lib/clang/include/MipsGenSubtargetInfo.inc new file mode 100644 index 0000000..2c069f4 --- /dev/null +++ b/lib/clang/include/MipsGenSubtargetInfo.inc @@ -0,0 +1,2 @@ +/* $FreeBSD$ */ +#include "MipsGenSubtargetInfo.inc.h" diff --git a/lib/clang/include/PPCGenInstrNames.inc b/lib/clang/include/PPCGenInstrNames.inc deleted file mode 100644 index 67ae90d..0000000 --- a/lib/clang/include/PPCGenInstrNames.inc +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -#include "PPCGenInstrNames.inc.h" diff --git a/lib/clang/include/PPCGenRegisterInfo.h.inc b/lib/clang/include/PPCGenRegisterInfo.h.inc deleted file mode 100644 index bce5f45..0000000 --- a/lib/clang/include/PPCGenRegisterInfo.h.inc +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -#include "PPCGenRegisterInfo.h.inc.h" diff --git a/lib/clang/include/PPCGenRegisterNames.inc b/lib/clang/include/PPCGenRegisterNames.inc deleted file mode 100644 index 09e7a2d..0000000 --- a/lib/clang/include/PPCGenRegisterNames.inc +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -#include "PPCGenRegisterNames.inc.h" diff --git a/lib/clang/include/PPCGenSubtarget.inc b/lib/clang/include/PPCGenSubtarget.inc deleted file mode 100644 index 7032e52..0000000 --- a/lib/clang/include/PPCGenSubtarget.inc +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -#include "PPCGenSubtarget.inc.h" diff --git a/lib/clang/include/PPCGenSubtargetInfo.inc b/lib/clang/include/PPCGenSubtargetInfo.inc new file mode 100644 index 0000000..a348630 --- /dev/null +++ b/lib/clang/include/PPCGenSubtargetInfo.inc @@ -0,0 +1,2 @@ +/* $FreeBSD$ */ +#include "PPCGenSubtargetInfo.inc.h" diff --git a/lib/clang/include/X86GenInstrNames.inc b/lib/clang/include/X86GenInstrNames.inc deleted file mode 100644 index 9c856f4..0000000 --- a/lib/clang/include/X86GenInstrNames.inc +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -#include "X86GenInstrNames.inc.h" diff --git a/lib/clang/include/X86GenRegisterInfo.h.inc b/lib/clang/include/X86GenRegisterInfo.h.inc deleted file mode 100644 index 4a76e0d..0000000 --- a/lib/clang/include/X86GenRegisterInfo.h.inc +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -#include "X86GenRegisterInfo.h.inc.h" diff --git a/lib/clang/include/X86GenRegisterNames.inc b/lib/clang/include/X86GenRegisterNames.inc deleted file mode 100644 index ad3d722..0000000 --- a/lib/clang/include/X86GenRegisterNames.inc +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -#include "X86GenRegisterNames.inc.h" diff --git a/lib/clang/include/X86GenSubtarget.inc b/lib/clang/include/X86GenSubtarget.inc deleted file mode 100644 index 1e8907d..0000000 --- a/lib/clang/include/X86GenSubtarget.inc +++ /dev/null @@ -1,2 +0,0 @@ -/* $FreeBSD$ */ -#include "X86GenSubtarget.inc.h" diff --git a/lib/clang/include/X86GenSubtargetInfo.inc b/lib/clang/include/X86GenSubtargetInfo.inc new file mode 100644 index 0000000..a64b3a4 --- /dev/null +++ b/lib/clang/include/X86GenSubtargetInfo.inc @@ -0,0 +1,2 @@ +/* $FreeBSD$ */ +#include "X86GenSubtargetInfo.inc.h" diff --git a/lib/clang/include/clang/Basic/Version.inc b/lib/clang/include/clang/Basic/Version.inc index 144a920..3e3b44c 100644 --- a/lib/clang/include/clang/Basic/Version.inc +++ b/lib/clang/include/clang/Basic/Version.inc @@ -5,6 +5,6 @@ #define CLANG_VERSION_MINOR 0 #define CLANG_VENDOR "FreeBSD " -#define CLANG_VENDOR_SUFFIX " 20110612" +#define CLANG_VENDOR_SUFFIX " 20110717" -#define SVN_REVISION "132879" +#define SVN_REVISION "135360" diff --git a/lib/clang/include/llvm/Config/config.h b/lib/clang/include/llvm/Config/config.h index 229b705..f264571 100644 --- a/lib/clang/include/llvm/Config/config.h +++ b/lib/clang/include/llvm/Config/config.h @@ -569,9 +569,15 @@ /* LLVM architecture name for the native architecture, if available */ #define LLVM_NATIVE_ARCH X86 +/* LLVM name for the native AsmParser init function, if available */ +#define LLVM_NATIVE_ASMPARSER LLVMInitializeX86AsmParser + /* LLVM name for the native AsmPrinter init function, if available */ #define LLVM_NATIVE_ASMPRINTER LLVMInitializeX86AsmPrinter +/* LLVM name for the native MCAsmInfo init function, if available */ +#define LLVM_NATIVE_MCASMINFO LLVMInitializeX86MCAsmInfo + /* LLVM name for the native Target init function, if available */ #define LLVM_NATIVE_TARGET LLVMInitializeX86Target @@ -674,6 +680,9 @@ /* Define if use udis86 library */ #define USE_UDIS86 0 +/* Type of 1st arg on ELM Callback */ +/* #undef WIN32_ELMCB_PCSTR */ + /* Define to empty if `const' does not conform to ANSI C. */ /* #undef const */ diff --git a/lib/clang/include/llvm/Config/llvm-config.h b/lib/clang/include/llvm/Config/llvm-config.h index fc3ec97..e76d10f 100644 --- a/lib/clang/include/llvm/Config/llvm-config.h +++ b/lib/clang/include/llvm/Config/llvm-config.h @@ -60,9 +60,15 @@ /* LLVM name for the native TargetInfo init function, if available */ #define LLVM_NATIVE_TARGETINFO LLVMInitializeX86TargetInfo +/* LLVM name for the native MCAsmInfo init function, if available */ +#define LLVM_NATIVE_MCASMINFO LLVMInitializeX86MCAsmInfo + /* LLVM name for the native AsmPrinter init function, if available */ #define LLVM_NATIVE_ASMPRINTER LLVMInitializeX86AsmPrinter +/* LLVM name for the native AsmPrinter init function, if available */ +#define LLVM_NATIVE_ASMPARSER LLVMInitializeX86AsmParser + /* Define if this is Unixish platform */ #define LLVM_ON_UNIX 1 diff --git a/lib/clang/libclangarcmigrate/Makefile b/lib/clang/libclangarcmigrate/Makefile new file mode 100644 index 0000000..c1e4511 --- /dev/null +++ b/lib/clang/libclangarcmigrate/Makefile @@ -0,0 +1,29 @@ +# $FreeBSD$ + +LIB= clangarcmigrate + +SRCDIR= tools/clang/lib/ARCMigrate +SRCS= ARCMT.cpp \ + ARCMTActions.cpp \ + FileRemapper.cpp \ + TransARCAssign.cpp \ + TransAutoreleasePool.cpp \ + TransBlockObjCVariable.cpp \ + TransEmptyStatementsAndDealloc.cpp \ + TransformActions.cpp \ + Transforms.cpp \ + TransProperties.cpp \ + TransRetainReleaseDealloc.cpp \ + TransUnbridgedCasts.cpp \ + TransUnusedInitDelegate.cpp \ + TransZeroOutPropsInDealloc.cpp + +TGHDRS= AttrList \ + Attrs \ + DeclNodes \ + DiagnosticCommonKinds \ + DiagnosticGroups \ + DiagnosticSemaKinds \ + StmtNodes + +.include "../clang.lib.mk" diff --git a/lib/clang/libclangfrontend/Makefile b/lib/clang/libclangfrontend/Makefile index ff32c08..2087900 100644 --- a/lib/clang/libclangfrontend/Makefile +++ b/lib/clang/libclangfrontend/Makefile @@ -6,7 +6,6 @@ SRCDIR= tools/clang/lib/Frontend SRCS= ASTConsumers.cpp \ ASTMerge.cpp \ ASTUnit.cpp \ - BoostConAction.cpp \ CacheTokens.cpp \ CompilerInstance.cpp \ CompilerInvocation.cpp \ diff --git a/lib/clang/libclangsema/Makefile b/lib/clang/libclangsema/Makefile index d2c7e34..3c03773 100644 --- a/lib/clang/libclangsema/Makefile +++ b/lib/clang/libclangsema/Makefile @@ -21,6 +21,7 @@ SRCS= AnalysisBasedWarnings.cpp \ SemaDecl.cpp \ SemaDeclAttr.cpp \ SemaDeclCXX.cpp \ + SemaExprMember.cpp \ SemaDeclObjC.cpp \ SemaExceptionSpec.cpp \ SemaExpr.cpp \ diff --git a/lib/clang/libllvmanalysis/Makefile b/lib/clang/libllvmanalysis/Makefile index 5436631..2b0bccf 100644 --- a/lib/clang/libllvmanalysis/Makefile +++ b/lib/clang/libllvmanalysis/Makefile @@ -10,6 +10,7 @@ SRCS= AliasAnalysis.cpp \ AliasSetTracker.cpp \ Analysis.cpp \ BasicAliasAnalysis.cpp \ + BranchProbabilityInfo.cpp \ CFGPrinter.cpp \ CaptureTracking.cpp \ ConstantFolding.cpp \ diff --git a/lib/clang/libllvmarmasmparser/Makefile b/lib/clang/libllvmarmasmparser/Makefile index 95dfc5b..c3d0d89 100644 --- a/lib/clang/libllvmarmasmparser/Makefile +++ b/lib/clang/libllvmarmasmparser/Makefile @@ -8,8 +8,8 @@ SRCS= ARMAsmLexer.cpp \ ARMAsmParser.cpp TGHDRS= ARMGenAsmMatcher \ - ARMGenInstrNames \ - ARMGenRegisterInfo.h \ - ARMGenRegisterNames + ARMGenInstrInfo \ + ARMGenRegisterInfo \ + ARMGenSubtargetInfo .include "../clang.lib.mk" diff --git a/lib/clang/libllvmarmcodegen/Makefile b/lib/clang/libllvmarmcodegen/Makefile index c19a451..0110781 100644 --- a/lib/clang/libllvmarmcodegen/Makefile +++ b/lib/clang/libllvmarmcodegen/Makefile @@ -20,11 +20,11 @@ SRCS= ARMAsmBackend.cpp \ ARMISelLowering.cpp \ ARMInstrInfo.cpp \ ARMJITInfo.cpp \ + ARMLoadStoreOptimizer.cpp \ ARMMCCodeEmitter.cpp \ ARMMCExpr.cpp \ - ARMLoadStoreOptimizer.cpp \ - ARMMCAsmInfo.cpp \ ARMMCInstLower.cpp \ + ARMMachObjectWriter.cpp \ ARMRegisterInfo.cpp \ ARMSelectionDAGInfo.cpp \ ARMSubtarget.cpp \ @@ -46,12 +46,10 @@ TGHDRS= ARMGenAsmWriter \ ARMGenDAGISel \ ARMGenFastISel \ ARMGenInstrInfo \ - ARMGenInstrNames \ ARMGenMCCodeEmitter \ + ARMGenMCPseudoLowering \ ARMGenRegisterInfo \ - ARMGenRegisterInfo.h \ - ARMGenRegisterNames \ - ARMGenSubtarget \ + ARMGenSubtargetInfo \ Intrinsics .include "../clang.lib.mk" diff --git a/lib/clang/libllvmarmdesc/Makefile b/lib/clang/libllvmarmdesc/Makefile new file mode 100644 index 0000000..0074ec2 --- /dev/null +++ b/lib/clang/libllvmarmdesc/Makefile @@ -0,0 +1,13 @@ +# $FreeBSD$ + +LIB= llvmarmdesc + +SRCDIR= lib/Target/ARM/MCTargetDesc +SRCS= ARMMCAsmInfo.cpp \ + ARMMCTargetDesc.cpp + +TGHDRS= ARMGenInstrInfo \ + ARMGenRegisterInfo \ + ARMGenSubtargetInfo + +.include "../clang.lib.mk" diff --git a/lib/clang/libllvmarmdisassembler/Makefile b/lib/clang/libllvmarmdisassembler/Makefile index c824560..c0648bb 100644 --- a/lib/clang/libllvmarmdisassembler/Makefile +++ b/lib/clang/libllvmarmdisassembler/Makefile @@ -9,8 +9,7 @@ SRCS= ARMDisassemblerCore.cpp TGHDRS= ARMGenDecoderTables \ ARMGenEDInfo \ ARMGenInstrInfo \ - ARMGenInstrNames \ - ARMGenRegisterInfo.h \ - ARMGenRegisterNames + ARMGenRegisterInfo \ + ARMGenSubtargetInfo .include "../clang.lib.mk" diff --git a/lib/clang/libllvmarminfo/Makefile b/lib/clang/libllvmarminfo/Makefile index 2f17454..43b9f83 100644 --- a/lib/clang/libllvmarminfo/Makefile +++ b/lib/clang/libllvmarminfo/Makefile @@ -6,7 +6,8 @@ SRCDIR= lib/Target/ARM/TargetInfo/ INCDIR= lib/Target/ARM SRCS= ARMTargetInfo.cpp -TGHDRS= ARMGenInstrNames \ - ARMGenRegisterNames +TGHDRS= ARMGenInstrInfo \ + ARMGenRegisterInfo \ + ARMGenSubtargetInfo .include "../clang.lib.mk" diff --git a/lib/clang/libllvmarminstprinter/Makefile b/lib/clang/libllvmarminstprinter/Makefile index 630f12a..ca7e7d4 100644 --- a/lib/clang/libllvmarminstprinter/Makefile +++ b/lib/clang/libllvmarminstprinter/Makefile @@ -7,7 +7,8 @@ INCDIR= lib/Target/ARM SRCS= ARMInstPrinter.cpp TGHDRS= ARMGenAsmWriter \ - ARMGenInstrNames \ - ARMGenRegisterNames + ARMGenInstrInfo \ + ARMGenRegisterInfo \ + ARMGenSubtargetInfo .include "../clang.lib.mk" diff --git a/lib/clang/libllvmcodegen/Makefile b/lib/clang/libllvmcodegen/Makefile index c657316..702c476 100644 --- a/lib/clang/libllvmcodegen/Makefile +++ b/lib/clang/libllvmcodegen/Makefile @@ -62,7 +62,6 @@ SRCS= AggressiveAntiDepBreaker.cpp \ Passes.cpp \ PeepholeOptimizer.cpp \ PostRASchedulerList.cpp \ - PreAllocSplitting.cpp \ ProcessImplicitDefs.cpp \ PrologEpilogInserter.cpp \ PseudoSourceValue.cpp \ @@ -82,7 +81,6 @@ SRCS= AggressiveAntiDepBreaker.cpp \ ScoreboardHazardRecognizer.cpp \ ShadowStackGC.cpp \ ShrinkWrapping.cpp \ - SimpleRegisterCoalescing.cpp \ SjLjEHPrepare.cpp \ SlotIndexes.cpp \ Spiller.cpp \ diff --git a/lib/clang/libllvmcore/Makefile b/lib/clang/libllvmcore/Makefile index 4e3adde..c37d45a 100644 --- a/lib/clang/libllvmcore/Makefile +++ b/lib/clang/libllvmcore/Makefile @@ -31,7 +31,6 @@ SRCS= AsmWriter.cpp \ PassRegistry.cpp \ PrintModulePass.cpp \ Type.cpp \ - TypeSymbolTable.cpp \ Use.cpp \ User.cpp \ Value.cpp \ diff --git a/lib/clang/libllvmipo/Makefile b/lib/clang/libllvmipo/Makefile index f919dd1..062ba5b 100644 --- a/lib/clang/libllvmipo/Makefile +++ b/lib/clang/libllvmipo/Makefile @@ -6,7 +6,6 @@ SRCDIR= lib/Transforms/IPO SRCS= ArgumentPromotion.cpp \ ConstantMerge.cpp \ DeadArgumentElimination.cpp \ - DeadTypeElimination.cpp \ ExtractGV.cpp \ FunctionAttrs.cpp \ GlobalDCE.cpp \ diff --git a/lib/clang/libllvmmc/Makefile b/lib/clang/libllvmmc/Makefile index 07b91ad..435cdf4 100644 --- a/lib/clang/libllvmmc/Makefile +++ b/lib/clang/libllvmmc/Makefile @@ -30,9 +30,11 @@ SRCS= ELFObjectWriter.cpp \ MCSectionELF.cpp \ MCSectionMachO.cpp \ MCStreamer.cpp \ + MCSubtargetInfo.cpp \ MCSymbol.cpp \ MCWin64EH.cpp \ MachObjectWriter.cpp \ + SubtargetFeature.cpp \ TargetAsmBackend.cpp \ WinCOFFObjectWriter.cpp \ WinCOFFStreamer.cpp diff --git a/lib/clang/libllvmmipscodegen/Makefile b/lib/clang/libllvmmipscodegen/Makefile index 63e9e0e..1651831 100644 --- a/lib/clang/libllvmmipscodegen/Makefile +++ b/lib/clang/libllvmmipscodegen/Makefile @@ -11,7 +11,8 @@ SRCS= MipsAsmPrinter.cpp \ MipsISelDAGToDAG.cpp \ MipsISelLowering.cpp \ MipsInstrInfo.cpp \ - MipsMCAsmInfo.cpp \ + MipsMCInstLower.cpp \ + MipsMCSymbolRefExpr.cpp \ MipsRegisterInfo.cpp \ MipsSelectionDAGInfo.cpp \ MipsSubtarget.cpp \ @@ -23,10 +24,7 @@ TGHDRS= Intrinsics \ MipsGenCallingConv \ MipsGenDAGISel \ MipsGenInstrInfo \ - MipsGenInstrNames \ MipsGenRegisterInfo \ - MipsGenRegisterInfo.h \ - MipsGenRegisterNames \ - MipsGenSubtarget + MipsGenSubtargetInfo .include "../clang.lib.mk" diff --git a/lib/clang/libllvmmipsdesc/Makefile b/lib/clang/libllvmmipsdesc/Makefile new file mode 100644 index 0000000..4147209 --- /dev/null +++ b/lib/clang/libllvmmipsdesc/Makefile @@ -0,0 +1,13 @@ +# $FreeBSD$ + +LIB= llvmmipsdesc + +SRCDIR= lib/Target/Mips/MCTargetDesc +SRCS= MipsMCAsmInfo.cpp \ + MipsMCTargetDesc.cpp + +TGHDRS= MipsGenInstrInfo \ + MipsGenRegisterInfo \ + MipsGenSubtargetInfo + +.include "../clang.lib.mk" diff --git a/lib/clang/libllvmmipsinfo/Makefile b/lib/clang/libllvmmipsinfo/Makefile index faa6f6f..abf6d8e 100644 --- a/lib/clang/libllvmmipsinfo/Makefile +++ b/lib/clang/libllvmmipsinfo/Makefile @@ -6,7 +6,8 @@ SRCDIR= lib/Target/Mips/TargetInfo/ INCDIR= lib/Target/Mips SRCS= MipsTargetInfo.cpp -TGHDRS= MipsGenRegisterNames \ - MipsGenInstrNames +TGHDRS= MipsGenInstrInfo \ + MipsGenRegisterInfo \ + MipsGenSubtargetInfo .include "../clang.lib.mk" diff --git a/lib/clang/libllvmmipsinstprinter/Makefile b/lib/clang/libllvmmipsinstprinter/Makefile new file mode 100644 index 0000000..357320e --- /dev/null +++ b/lib/clang/libllvmmipsinstprinter/Makefile @@ -0,0 +1,13 @@ +# $FreeBSD$ + +LIB= llvmmipsinstprinter + +SRCDIR= lib/Target/Mips/InstPrinter +INCDIR= lib/Target/Mips +SRCS= MipsInstPrinter.cpp + +TGHDRS= MipsGenAsmWriter \ + MipsGenInstrInfo \ + MipsGenRegisterInfo + +.include "../clang.lib.mk" diff --git a/lib/clang/libllvmpowerpccodegen/Makefile b/lib/clang/libllvmpowerpccodegen/Makefile index 7d43ae1..08663e8 100644 --- a/lib/clang/libllvmpowerpccodegen/Makefile +++ b/lib/clang/libllvmpowerpccodegen/Makefile @@ -13,7 +13,6 @@ SRCS= PPCAsmBackend.cpp \ PPCISelLowering.cpp \ PPCInstrInfo.cpp \ PPCJITInfo.cpp \ - PPCMCAsmInfo.cpp \ PPCMCCodeEmitter.cpp \ PPCMCInstLower.cpp \ PPCPredicates.cpp \ @@ -27,11 +26,8 @@ TGHDRS= Intrinsics \ PPCGenCodeEmitter \ PPCGenDAGISel \ PPCGenInstrInfo \ - PPCGenInstrNames \ PPCGenMCCodeEmitter \ PPCGenRegisterInfo \ - PPCGenRegisterInfo.h \ - PPCGenRegisterNames \ - PPCGenSubtarget + PPCGenSubtargetInfo .include "../clang.lib.mk" diff --git a/lib/clang/libllvmpowerpcdesc/Makefile b/lib/clang/libllvmpowerpcdesc/Makefile new file mode 100644 index 0000000..9207da2 --- /dev/null +++ b/lib/clang/libllvmpowerpcdesc/Makefile @@ -0,0 +1,13 @@ +# $FreeBSD$ + +LIB= llvmpowerpcdesc + +SRCDIR= lib/Target/PowerPC/MCTargetDesc +SRCS= PPCMCAsmInfo.cpp \ + PPCMCTargetDesc.cpp + +TGHDRS= PPCGenInstrInfo \ + PPCGenRegisterInfo \ + PPCGenSubtargetInfo + +.include "../clang.lib.mk" diff --git a/lib/clang/libllvmpowerpcinfo/Makefile b/lib/clang/libllvmpowerpcinfo/Makefile index 5142ce1..8cdaa5a5 100644 --- a/lib/clang/libllvmpowerpcinfo/Makefile +++ b/lib/clang/libllvmpowerpcinfo/Makefile @@ -6,7 +6,8 @@ SRCDIR= lib/Target/PowerPC/TargetInfo/ INCDIR= lib/Target/PowerPC SRCS= PowerPCTargetInfo.cpp -TGHDRS= PPCGenRegisterNames \ - PPCGenInstrNames +TGHDRS= PPCGenInstrInfo \ + PPCGenRegisterInfo \ + PPCGenSubtargetInfo .include "../clang.lib.mk" diff --git a/lib/clang/libllvmpowerpcinstprinter/Makefile b/lib/clang/libllvmpowerpcinstprinter/Makefile index 8be81c4..c1528ae 100644 --- a/lib/clang/libllvmpowerpcinstprinter/Makefile +++ b/lib/clang/libllvmpowerpcinstprinter/Makefile @@ -7,8 +7,8 @@ INCDIR= lib/Target/PowerPC SRCS= PPCInstPrinter.cpp TGHDRS= PPCGenAsmWriter \ - PPCGenInstrNames \ - PPCGenRegisterInfo.h \ - PPCGenRegisterNames + PPCGenInstrInfo \ + PPCGenRegisterInfo \ + PPCGenSubtargetInfo .include "../clang.lib.mk" diff --git a/lib/clang/libllvmscalaropts/Makefile b/lib/clang/libllvmscalaropts/Makefile index 757b8e0..81998a4 100644 --- a/lib/clang/libllvmscalaropts/Makefile +++ b/lib/clang/libllvmscalaropts/Makefile @@ -22,6 +22,7 @@ SRCS= ADCE.cpp \ LoopUnrollPass.cpp \ LoopUnswitch.cpp \ MemCpyOptimizer.cpp \ + ObjCARC.cpp \ Reassociate.cpp \ SCCP.cpp \ ScalarReplAggregates.cpp \ diff --git a/lib/clang/libllvmsupport/Makefile b/lib/clang/libllvmsupport/Makefile index 72f5c57..e1a16c4 100644 --- a/lib/clang/libllvmsupport/Makefile +++ b/lib/clang/libllvmsupport/Makefile @@ -8,6 +8,7 @@ SRCS= APFloat.cpp \ APSInt.cpp \ Allocator.cpp \ Atomic.cpp \ + BranchProbability.cpp \ CommandLine.cpp \ ConstantRange.cpp \ CrashRecoveryContext.cpp \ diff --git a/lib/clang/libllvmtarget/Makefile b/lib/clang/libllvmtarget/Makefile index 56544d1..493b7c1 100644 --- a/lib/clang/libllvmtarget/Makefile +++ b/lib/clang/libllvmtarget/Makefile @@ -4,7 +4,6 @@ LIB= llvmtarget SRCDIR= lib/Target SRCS= Mangler.cpp \ - SubtargetFeature.cpp \ Target.cpp \ TargetAsmInfo.cpp \ TargetAsmLexer.cpp \ @@ -16,6 +15,6 @@ SRCS= Mangler.cpp \ TargetLoweringObjectFile.cpp \ TargetMachine.cpp \ TargetRegisterInfo.cpp \ - TargetSubtarget.cpp + TargetSubtargetInfo.cpp .include "../clang.lib.mk" diff --git a/lib/clang/libllvmtransformutils/Makefile b/lib/clang/libllvmtransformutils/Makefile index 0fa0c96..50dae17 100644 --- a/lib/clang/libllvmtransformutils/Makefile +++ b/lib/clang/libllvmtransformutils/Makefile @@ -9,7 +9,6 @@ SRCS= AddrModeMatcher.cpp \ BreakCriticalEdges.cpp \ BuildLibCalls.cpp \ CloneFunction.cpp \ - CloneLoop.cpp \ CloneModule.cpp \ CodeExtractor.cpp \ DemoteRegToStack.cpp \ @@ -19,6 +18,7 @@ SRCS= AddrModeMatcher.cpp \ Local.cpp \ LoopSimplify.cpp \ LoopUnroll.cpp \ + LowerExpectIntrinsic.cpp \ LowerInvoke.cpp \ LowerSwitch.cpp \ Mem2Reg.cpp \ diff --git a/lib/clang/libllvmx86asmparser/Makefile b/lib/clang/libllvmx86asmparser/Makefile index c6bdab7..c140268 100644 --- a/lib/clang/libllvmx86asmparser/Makefile +++ b/lib/clang/libllvmx86asmparser/Makefile @@ -8,7 +8,8 @@ SRCS= X86AsmLexer.cpp \ X86AsmParser.cpp TGHDRS= X86GenAsmMatcher \ - X86GenInstrNames \ - X86GenRegisterNames + X86GenInstrInfo \ + X86GenRegisterInfo \ + X86GenSubtargetInfo .include "../clang.lib.mk" diff --git a/lib/clang/libllvmx86codegen/Makefile b/lib/clang/libllvmx86codegen/Makefile index 300ad9a..6964501 100644 --- a/lib/clang/libllvmx86codegen/Makefile +++ b/lib/clang/libllvmx86codegen/Makefile @@ -16,7 +16,6 @@ SRCS= SSEDomainFix.cpp \ X86ISelLowering.cpp \ X86InstrInfo.cpp \ X86JITInfo.cpp \ - X86MCAsmInfo.cpp \ X86MCCodeEmitter.cpp \ X86MCInstLower.cpp \ X86MachObjectWriter.cpp \ @@ -31,10 +30,7 @@ TGHDRS= Intrinsics \ X86GenDAGISel \ X86GenFastISel \ X86GenInstrInfo \ - X86GenInstrNames \ X86GenRegisterInfo \ - X86GenRegisterInfo.h \ - X86GenRegisterNames \ - X86GenSubtarget + X86GenSubtargetInfo .include "../clang.lib.mk" diff --git a/lib/clang/libllvmx86desc/Makefile b/lib/clang/libllvmx86desc/Makefile new file mode 100644 index 0000000..44b20a5 --- /dev/null +++ b/lib/clang/libllvmx86desc/Makefile @@ -0,0 +1,13 @@ +# $FreeBSD$ + +LIB= llvmx86desc + +SRCDIR= lib/Target/X86/MCTargetDesc +SRCS= X86MCAsmInfo.cpp \ + X86MCTargetDesc.cpp + +TGHDRS= X86GenInstrInfo \ + X86GenRegisterInfo \ + X86GenSubtargetInfo + +.include "../clang.lib.mk" diff --git a/lib/clang/libllvmx86disassembler/Makefile b/lib/clang/libllvmx86disassembler/Makefile index 0b88643..b9055fc 100644 --- a/lib/clang/libllvmx86disassembler/Makefile +++ b/lib/clang/libllvmx86disassembler/Makefile @@ -8,6 +8,6 @@ SRCS= X86Disassembler.cpp TGHDRS= X86GenDisassemblerTables \ X86GenEDInfo \ - X86GenRegisterNames + X86GenRegisterInfo .include "../clang.lib.mk" diff --git a/lib/clang/libllvmx86info/Makefile b/lib/clang/libllvmx86info/Makefile index 8e92b62..62b506e 100644 --- a/lib/clang/libllvmx86info/Makefile +++ b/lib/clang/libllvmx86info/Makefile @@ -6,7 +6,8 @@ SRCDIR= lib/Target/X86/TargetInfo/ INCDIR= lib/Target/X86 SRCS= X86TargetInfo.cpp -TGHDRS= X86GenInstrNames \ - X86GenRegisterNames +TGHDRS= X86GenInstrInfo \ + X86GenRegisterInfo \ + X86GenSubtargetInfo .include "../clang.lib.mk" diff --git a/lib/clang/libllvmx86instprinter/Makefile b/lib/clang/libllvmx86instprinter/Makefile index eb30daa..a44006c 100644 --- a/lib/clang/libllvmx86instprinter/Makefile +++ b/lib/clang/libllvmx86instprinter/Makefile @@ -10,7 +10,8 @@ SRCS= X86ATTInstPrinter.cpp \ TGHDRS= X86GenAsmWriter \ X86GenAsmWriter1 \ - X86GenInstrNames \ - X86GenRegisterNames + X86GenInstrInfo \ + X86GenRegisterInfo \ + X86GenSubtargetInfo .include "../clang.lib.mk" diff --git a/lib/libarchive/Makefile b/lib/libarchive/Makefile index edb0915..8d889c8 100644 --- a/lib/libarchive/Makefile +++ b/lib/libarchive/Makefile @@ -13,6 +13,9 @@ DPADD+= ${LIBLZMA} LDADD+= -llzma CFLAGS+= -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1 +DPADD+= ${LIBBSDXML} +LDADD+= -lbsdxml + # FreeBSD SHLIB_MAJOR value is managed as part of the FreeBSD system. # It has no real relation to the libarchive version number. SHLIB_MAJOR= 5 @@ -56,6 +59,7 @@ SRCS= archive_check_magic.c \ archive_read_support_compression_gzip.c \ archive_read_support_compression_none.c \ archive_read_support_compression_program.c \ + archive_read_support_compression_rpm.c \ archive_read_support_compression_uu.c \ archive_read_support_compression_xz.c \ archive_read_support_format_all.c \ @@ -66,6 +70,7 @@ SRCS= archive_check_magic.c \ archive_read_support_format_mtree.c \ archive_read_support_format_raw.c \ archive_read_support_format_tar.c \ + archive_read_support_format_xar.c \ archive_read_support_format_zip.c \ archive_string.c \ archive_string_sprintf.c \ diff --git a/lib/libarchive/README b/lib/libarchive/README index 3157108..0c4758a 100644 --- a/lib/libarchive/README +++ b/lib/libarchive/README @@ -21,6 +21,7 @@ Currently, the library automatically detects and reads the following: * gzip compression * bzip2 compression * compress/LZW compression + * lzma and xz compression * GNU tar format (including GNU long filenames, long link names, and sparse files) * Solaris 9 extended tar format (including ACLs) @@ -30,18 +31,26 @@ Currently, the library automatically detects and reads the following: * POSIX octet-oriented cpio * SVR4 ASCII cpio * Binary cpio (big-endian or little-endian) - * ISO9660 CD-ROM images (with optional Rockridge extensions) + * ISO9660 CD-ROM images (with optional Rockridge or Joliet extensions) * ZIP archives (with uncompressed or "deflate" compressed entries) + * GNU and BSD 'ar' archives + * 'mtree' format The library can write: * gzip compression * bzip2 compression + * compress/LZW compression + * lzma and xz compression * POSIX ustar * POSIX pax interchange format * "restricted" pax format, which will create ustar archives except for entries that require pax extensions (for long filenames, ACLs, etc). * POSIX octet-oriented cpio + * SVR4 "newc" cpio * shar archives + * ZIP archives (with uncompressed or "deflate" compressed entries) + * GNU and BSD 'ar' archives + * 'mtree' format Notes: * This is a heavily stream-oriented system. There is no direct diff --git a/lib/libarchive/archive.h b/lib/libarchive/archive.h index f97af73..7075e26 100644 --- a/lib/libarchive/archive.h +++ b/lib/libarchive/archive.h @@ -52,7 +52,9 @@ /* These should match the types used in 'struct stat' */ #if defined(_WIN32) && !defined(__CYGWIN__) #define __LA_INT64_T __int64 -# if defined(_WIN64) +# if defined(_SSIZE_T_DEFINED) +# define __LA_SSIZE_T ssize_t +# elif defined(_WIN64) # define __LA_SSIZE_T __int64 # else # define __LA_SSIZE_T long @@ -127,13 +129,13 @@ extern "C" { * (ARCHIVE_API_VERSION * 1000000 + ARCHIVE_API_FEATURE * 1000) * #endif */ -#define ARCHIVE_VERSION_NUMBER 2007901 +#define ARCHIVE_VERSION_NUMBER 2008004 __LA_DECL int archive_version_number(void); /* * Textual name/version of the library, useful for version displays. */ -#define ARCHIVE_VERSION_STRING "libarchive 2.7.901a" +#define ARCHIVE_VERSION_STRING "libarchive 2.8.4" __LA_DECL const char * archive_version_string(void); #if ARCHIVE_VERSION_NUMBER < 3000000 @@ -319,6 +321,7 @@ __LA_DECL int archive_read_support_compression_program_signature (struct archive *, const char *, const void * /* match */, size_t); +__LA_DECL int archive_read_support_compression_rpm(struct archive *); __LA_DECL int archive_read_support_compression_uu(struct archive *); __LA_DECL int archive_read_support_compression_xz(struct archive *); @@ -331,6 +334,7 @@ __LA_DECL int archive_read_support_format_iso9660(struct archive *); __LA_DECL int archive_read_support_format_mtree(struct archive *); __LA_DECL int archive_read_support_format_raw(struct archive *); __LA_DECL int archive_read_support_format_tar(struct archive *); +__LA_DECL int archive_read_support_format_xar(struct archive *); __LA_DECL int archive_read_support_format_zip(struct archive *); diff --git a/lib/libarchive/archive_hash.h b/lib/libarchive/archive_hash.h index 3e10e8d..dc63d94 100644 --- a/lib/libarchive/archive_hash.h +++ b/lib/libarchive/archive_hash.h @@ -29,6 +29,10 @@ #error This header is only to be used internally to libarchive. #endif +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif + /* * Hash function support in various Operating Systems: * @@ -41,43 +45,71 @@ * - OpenBSD 4.4 and earlier have SHA2 in libc with _ after algorithm name * * DragonFly and FreeBSD (XXX not used yet): - * - MD5 in libmd: without _ after algorithm name - * - SHA{1,256,512} in libmd: with _ after algorithm name (conflicts w/OpenSSL!) + * - MD5 and SHA1 in libmd: without _ after algorithm name + * - SHA256: with _ after algorithm name + * + * Mac OS X (10.4 and later): + * - MD5, SHA1 and SHA2 in libSystem: with CC_ prefix and _ after algorithm name * * OpenSSL: - * - MD5, SHA1, SHA2, SHA{256,384,512} in libcrypto: with _ after algorithm name + * - MD5, SHA1 and SHA2 in libcrypto: with _ after algorithm name + * + * Windows: + * - MD5, SHA1 and SHA2 in archive_windows.c: without algorithm name + * and with __la_ prefix. */ +#if defined(ARCHIVE_HASH_MD5_WIN) ||\ + defined(ARCHIVE_HASH_SHA1_WIN) || defined(ARCHIVE_HASH_SHA256_WIN) ||\ + defined(ARCHIVE_HASH_SHA384_WIN) || defined(ARCHIVE_HASH_SHA512_WIN) +#include <wincrypt.h> +typedef struct { + int valid; + HCRYPTPROV cryptProv; + HCRYPTHASH hash; +} Digest_CTX; +extern void __la_hash_Init(Digest_CTX *, ALG_ID); +extern void __la_hash_Final(unsigned char *, size_t, Digest_CTX *); +extern void __la_hash_Update(Digest_CTX *, const unsigned char *, size_t); +#endif -#if defined(HAVE_MD5_H) && defined(HAVE_MD5INIT) +#if defined(ARCHIVE_HASH_MD5_LIBC) # include <md5.h> # define ARCHIVE_HAS_MD5 typedef MD5_CTX archive_md5_ctx; # define archive_md5_init(ctx) MD5Init(ctx) # define archive_md5_final(ctx, buf) MD5Final(buf, ctx) # define archive_md5_update(ctx, buf, n) MD5Update(ctx, buf, n) -#elif defined(HAVE_OPENSSL_MD5_H) +#elif defined(ARCHIVE_HASH_MD5_LIBSYSTEM) +# include <CommonCrypto/CommonDigest.h> +# define ARCHIVE_HAS_MD5 +typedef CC_MD5_CTX archive_md5_ctx; +# define archive_md5_init(ctx) CC_MD5_Init(ctx) +# define archive_md5_final(ctx, buf) CC_MD5_Final(buf, ctx) +# define archive_md5_update(ctx, buf, n) CC_MD5_Update(ctx, buf, n) +#elif defined(ARCHIVE_HASH_MD5_OPENSSL) # include <openssl/md5.h> # define ARCHIVE_HAS_MD5 typedef MD5_CTX archive_md5_ctx; # define archive_md5_init(ctx) MD5_Init(ctx) # define archive_md5_final(ctx, buf) MD5_Final(buf, ctx) # define archive_md5_update(ctx, buf, n) MD5_Update(ctx, buf, n) -#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_MD5) +#elif defined(ARCHIVE_HASH_MD5_WIN) # define ARCHIVE_HAS_MD5 -typedef MD5_CTX archive_md5_ctx; -# define archive_md5_init(ctx) MD5_Init(ctx) -# define archive_md5_final(ctx, buf) MD5_Final(buf, ctx) -# define archive_md5_update(ctx, buf, n) MD5_Update(ctx, buf, n) +# define MD5_DIGEST_LENGTH 16 +typedef Digest_CTX archive_md5_ctx; +# define archive_md5_init(ctx) __la_hash_Init(ctx, CALG_MD5) +# define archive_md5_final(ctx, buf) __la_hash_Final(buf, MD5_DIGEST_LENGTH, ctx) +# define archive_md5_update(ctx, buf, n) __la_hash_Update(ctx, buf, n) #endif -#if defined(HAVE_RMD160_H) && defined(HAVE_RMD160INIT) +#if defined(ARCHIVE_HASH_RMD160_LIBC) # include <rmd160.h> # define ARCHIVE_HAS_RMD160 typedef RMD160_CTX archive_rmd160_ctx; # define archive_rmd160_init(ctx) RMD160Init(ctx) # define archive_rmd160_final(ctx, buf) RMD160Final(buf, ctx) # define archive_rmd160_update(ctx, buf, n) RMD160Update(ctx, buf, n) -#elif defined(HAVE_OPENSSL_RIPEMD_H) +#elif defined(ARCHIVE_HASH_RMD160_OPENSSL) # include <openssl/ripemd.h> # define ARCHIVE_HAS_RMD160 typedef RIPEMD160_CTX archive_rmd160_ctx; @@ -86,111 +118,164 @@ typedef RIPEMD160_CTX archive_rmd160_ctx; # define archive_rmd160_update(ctx, buf, n) RIPEMD160_Update(ctx, buf, n) #endif -#if defined(HAVE_SHA1_H) && defined(HAVE_SHA1INIT) +#if defined(ARCHIVE_HASH_SHA1_LIBC) # include <sha1.h> # define ARCHIVE_HAS_SHA1 typedef SHA1_CTX archive_sha1_ctx; # define archive_sha1_init(ctx) SHA1Init(ctx) # define archive_sha1_final(ctx, buf) SHA1Final(buf, ctx) # define archive_sha1_update(ctx, buf, n) SHA1Update(ctx, buf, n) -#elif defined(HAVE_OPENSSL_SHA_H) +#elif defined(ARCHIVE_HASH_SHA1_LIBSYSTEM) +# include <CommonCrypto/CommonDigest.h> +# define ARCHIVE_HAS_SHA1 +typedef CC_SHA1_CTX archive_sha1_ctx; +# define archive_sha1_init(ctx) CC_SHA1_Init(ctx) +# define archive_sha1_final(ctx, buf) CC_SHA1_Final(buf, ctx) +# define archive_sha1_update(ctx, buf, n) CC_SHA1_Update(ctx, buf, n) +#elif defined(ARCHIVE_HASH_SHA1_OPENSSL) # include <openssl/sha.h> # define ARCHIVE_HAS_SHA1 typedef SHA_CTX archive_sha1_ctx; # define archive_sha1_init(ctx) SHA1_Init(ctx) # define archive_sha1_final(ctx, buf) SHA1_Final(buf, ctx) # define archive_sha1_update(ctx, buf, n) SHA1_Update(ctx, buf, n) -#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_SHA1) +#elif defined(ARCHIVE_HASH_SHA1_WIN) # define ARCHIVE_HAS_SHA1 -typedef SHA1_CTX archive_sha1_ctx; -# define archive_sha1_init(ctx) SHA1_Init(ctx) -# define archive_sha1_final(ctx, buf) SHA1_Final(buf, ctx) -# define archive_sha1_update(ctx, buf, n) SHA1_Update(ctx, buf, n) +# define SHA1_DIGEST_LENGTH 20 +typedef Digest_CTX archive_sha1_ctx; +# define archive_sha1_init(ctx) __la_hash_Init(ctx, CALG_SHA1) +# define archive_sha1_final(ctx, buf) __la_hash_Final(buf, SHA1_DIGEST_LENGTH, ctx) +# define archive_sha1_update(ctx, buf, n) __la_hash_Update(ctx, buf, n) #endif -#if defined(HAVE_SHA2_H) && defined(HAVE_SHA256_INIT) +#if defined(ARCHIVE_HASH_SHA256_LIBC) # include <sha2.h> # define ARCHIVE_HAS_SHA256 typedef SHA256_CTX archive_sha256_ctx; # define archive_sha256_init(ctx) SHA256_Init(ctx) # define archive_sha256_final(ctx, buf) SHA256_Final(buf, ctx) # define archive_sha256_update(ctx, buf, n) SHA256_Update(ctx, buf, n) -#elif defined(HAVE_SHA2_H) && defined(HAVE_SHA256INIT) +#elif defined(ARCHIVE_HASH_SHA256_LIBC2) # include <sha2.h> # define ARCHIVE_HAS_SHA256 typedef SHA256_CTX archive_sha256_ctx; # define archive_sha256_init(ctx) SHA256Init(ctx) # define archive_sha256_final(ctx, buf) SHA256Final(buf, ctx) # define archive_sha256_update(ctx, buf, n) SHA256Update(ctx, buf, n) -#elif defined(HAVE_OPENSSL_SHA_H) && defined(HAVE_OPENSSL_SHA256_INIT) +#elif defined(ARCHIVE_HASH_SHA256_LIBC3) +# include <sha2.h> +# define ARCHIVE_HAS_SHA256 +typedef SHA2_CTX archive_sha256_ctx; +# define archive_sha256_init(ctx) SHA256Init(ctx) +# define archive_sha256_final(ctx, buf) SHA256Final(buf, ctx) +# define archive_sha256_update(ctx, buf, n) SHA256Update(ctx, buf, n) +#elif defined(ARCHIVE_HASH_SHA256_LIBSYSTEM) +# include <CommonCrypto/CommonDigest.h> +# define ARCHIVE_HAS_SHA256 +typedef CC_SHA256_CTX archive_shs256_ctx; +# define archive_shs256_init(ctx) CC_SHA256_Init(ctx) +# define archive_shs256_final(ctx, buf) CC_SHA256_Final(buf, ctx) +# define archive_shs256_update(ctx, buf, n) CC_SHA256_Update(ctx, buf, n) +#elif defined(ARCHIVE_HASH_SHA256_OPENSSL) # include <openssl/sha.h> # define ARCHIVE_HAS_SHA256 typedef SHA256_CTX archive_sha256_ctx; # define archive_sha256_init(ctx) SHA256_Init(ctx) # define archive_sha256_final(ctx, buf) SHA256_Final(buf, ctx) # define archive_sha256_update(ctx, buf, n) SHA256_Update(ctx, buf, n) -#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_SHA_256) +#elif defined(ARCHIVE_HASH_SHA256_WIN) # define ARCHIVE_HAS_SHA256 -typedef SHA256_CTX archive_sha256_ctx; -# define archive_sha256_init(ctx) SHA256_Init(ctx) -# define archive_sha256_final(ctx, buf) SHA256_Final(buf, ctx) -# define archive_sha256_update(ctx, buf, n) SHA256_Update(ctx, buf, n) +# define SHA256_DIGEST_LENGTH 32 +typedef Digest_CTX archive_sha256_ctx; +# define archive_sha256_init(ctx) __la_hash_Init(ctx, CALG_SHA_256) +# define archive_sha256_final(ctx, buf) __la_hash_Final(buf, SHA256_DIGEST_LENGTH, ctx) +# define archive_sha256_update(ctx, buf, n) __la_hash_Update(ctx, buf, n) #endif -#if defined(HAVE_SHA2_H) && defined(HAVE_SHA384_INIT) +#if defined(ARCHIVE_HASH_SHA384_LIBC) # include <sha2.h> # define ARCHIVE_HAS_SHA384 typedef SHA384_CTX archive_sha384_ctx; # define archive_sha384_init(ctx) SHA384_Init(ctx) # define archive_sha384_final(ctx, buf) SHA384_Final(buf, ctx) # define archive_sha384_update(ctx, buf, n) SHA384_Update(ctx, buf, n) -#elif defined(HAVE_SHA2_H) && defined(HAVE_SHA384INIT) +#elif defined(ARCHIVE_HASH_SHA384_LIBC2) # include <sha2.h> # define ARCHIVE_HAS_SHA384 typedef SHA384_CTX archive_sha384_ctx; # define archive_sha384_init(ctx) SHA384Init(ctx) # define archive_sha384_final(ctx, buf) SHA384Final(buf, ctx) # define archive_sha384_update(ctx, buf, n) SHA384Update(ctx, buf, n) -#elif defined(HAVE_OPENSSL_SHA_H) && defined(HAVE_OPENSSL_SHA384_INIT) +#elif defined(ARCHIVE_HASH_SHA384_LIBC3) +# include <sha2.h> +# define ARCHIVE_HAS_SHA384 +typedef SHA2_CTX archive_sha384_ctx; +# define archive_sha384_init(ctx) SHA384Init(ctx) +# define archive_sha384_final(ctx, buf) SHA384Final(buf, ctx) +# define archive_sha384_update(ctx, buf, n) SHA384Update(ctx, buf, n) +#elif defined(ARCHIVE_HASH_SHA384_LIBSYSTEM) +# include <CommonCrypto/CommonDigest.h> +# define ARCHIVE_HAS_SHA384 +typedef CC_SHA512_CTX archive_shs384_ctx; +# define archive_shs384_init(ctx) CC_SHA384_Init(ctx) +# define archive_shs384_final(ctx, buf) CC_SHA384_Final(buf, ctx) +# define archive_shs384_update(ctx, buf, n) CC_SHA384_Update(ctx, buf, n) +#elif defined(ARCHIVE_HASH_SHA384_OPENSSL) # include <openssl/sha.h> # define ARCHIVE_HAS_SHA384 typedef SHA512_CTX archive_sha384_ctx; # define archive_sha384_init(ctx) SHA384_Init(ctx) # define archive_sha384_final(ctx, buf) SHA384_Final(buf, ctx) # define archive_sha384_update(ctx, buf, n) SHA384_Update(ctx, buf, n) -#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_SHA_384) +#elif defined(ARCHIVE_HASH_SHA384_WIN) # define ARCHIVE_HAS_SHA384 -typedef SHA512_CTX archive_sha384_ctx; -# define archive_sha384_init(ctx) SHA384_Init(ctx) -# define archive_sha384_final(ctx, buf) SHA384_Final(buf, ctx) -# define archive_sha384_update(ctx, buf, n) SHA384_Update(ctx, buf, n) +# define SHA384_DIGEST_LENGTH 48 +typedef Digest_CTX archive_sha384_ctx; +# define archive_sha384_init(ctx) __la_hash_Init(ctx, CALG_SHA_384) +# define archive_sha384_final(ctx, buf) __la_hash_Final(buf, SHA384_DIGEST_LENGTH, ctx) +# define archive_sha384_update(ctx, buf, n) __la_hash_Update(ctx, buf, n) #endif -#if defined(HAVE_SHA2_H) && defined(HAVE_SHA512_INIT) +#if defined(ARCHIVE_HASH_SHA512_LIBC) # include <sha2.h> # define ARCHIVE_HAS_SHA512 typedef SHA512_CTX archive_sha512_ctx; # define archive_sha512_init(ctx) SHA512_Init(ctx) # define archive_sha512_final(ctx, buf) SHA512_Final(buf, ctx) # define archive_sha512_update(ctx, buf, n) SHA512_Update(ctx, buf, n) -#elif defined(HAVE_SHA2_H) && defined(HAVE_SHA512INIT) +#elif defined(ARCHIVE_HASH_SHA512_LIBC2) # include <sha2.h> # define ARCHIVE_HAS_SHA512 typedef SHA512_CTX archive_sha512_ctx; # define archive_sha512_init(ctx) SHA512Init(ctx) # define archive_sha512_final(ctx, buf) SHA512Final(buf, ctx) # define archive_sha512_update(ctx, buf, n) SHA512Update(ctx, buf, n) -#elif defined(HAVE_OPENSSL_SHA_H) && defined(HAVE_OPENSSL_SHA512_INIT) +#elif defined(ARCHIVE_HASH_SHA512_LIBC3) +# include <sha2.h> +# define ARCHIVE_HAS_SHA512 +typedef SHA2_CTX archive_sha512_ctx; +# define archive_sha512_init(ctx) SHA512Init(ctx) +# define archive_sha512_final(ctx, buf) SHA512Final(buf, ctx) +# define archive_sha512_update(ctx, buf, n) SHA512Update(ctx, buf, n) +#elif defined(ARCHIVE_HASH_SHA512_LIBSYSTEM) +# include <CommonCrypto/CommonDigest.h> +# define ARCHIVE_HAS_SHA512 +typedef CC_SHA512_CTX archive_shs512_ctx; +# define archive_shs512_init(ctx) CC_SHA512_Init(ctx) +# define archive_shs512_final(ctx, buf) CC_SHA512_Final(buf, ctx) +# define archive_shs512_update(ctx, buf, n) CC_SHA512_Update(ctx, buf, n) +#elif defined(ARCHIVE_HASH_SHA512_OPENSSL) # include <openssl/sha.h> # define ARCHIVE_HAS_SHA512 typedef SHA512_CTX archive_sha512_ctx; # define archive_sha512_init(ctx) SHA512_Init(ctx) # define archive_sha512_final(ctx, buf) SHA512_Final(buf, ctx) # define archive_sha512_update(ctx, buf, n) SHA512_Update(ctx, buf, n) -#elif defined(_WIN32) && !defined(__CYGWIN__) && defined(CALG_SHA_512) +#elif defined(ARCHIVE_HASH_SHA512_WIN) # define ARCHIVE_HAS_SHA512 -typedef SHA512_CTX archive_sha512_ctx; -# define archive_sha512_init(ctx) SHA512_Init(ctx) -# define archive_sha512_final(ctx, buf) SHA512_Final(buf, ctx) -# define archive_sha512_update(ctx, buf, n) SHA512_Update(ctx, buf, n) +# define SHA512_DIGEST_LENGTH 64 +typedef Digest_CTX archive_sha512_ctx; +# define archive_sha512_init(ctx) __la_hash_Init(ctx, CALG_SHA_512) +# define archive_sha512_final(ctx, buf) __la_hash_Final(buf, SHA512_DIGEST_LENGTH, ctx) +# define archive_sha512_update(ctx, buf, n) __la_hash_Update(ctx, buf, n) #endif diff --git a/lib/libarchive/archive_read.3 b/lib/libarchive/archive_read.3 index 850deb6..4df0db6 100644 --- a/lib/libarchive/archive_read.3 +++ b/lib/libarchive/archive_read.3 @@ -597,7 +597,7 @@ list_archive(const char *name) archive_read_support_format_all(a); archive_read_open(a, mydata, myopen, myread, myclose); while (archive_read_next_header(a, &entry) == ARCHIVE_OK) { - printf("%s\\n",archive_entry_pathname(entry)); + printf("%s\en",archive_entry_pathname(entry)); archive_read_data_skip(a); } archive_read_free(a); diff --git a/lib/libarchive/archive_read_disk_entry_from_file.c b/lib/libarchive/archive_read_disk_entry_from_file.c index dbb7d75..957e4ee 100644 --- a/lib/libarchive/archive_read_disk_entry_from_file.c +++ b/lib/libarchive/archive_read_disk_entry_from_file.c @@ -208,6 +208,12 @@ setup_acls_posix1e(struct archive_read_disk *a, #if HAVE_ACL_GET_LINK_NP else if (!a->follow_symlinks) acl = acl_get_link_np(accpath, ACL_TYPE_ACCESS); +#else + else if ((!a->follow_symlinks) + && (archive_entry_filetype(entry) == AE_IFLNK)) + /* We can't get the ACL of a symlink, so we assume it can't + have one. */ + acl = NULL; #endif else acl = acl_get_file(accpath, ACL_TYPE_ACCESS); @@ -419,7 +425,8 @@ setup_xattrs(struct archive_read_disk *a, return (ARCHIVE_OK); } -#elif HAVE_EXTATTR_GET_FILE && HAVE_EXTATTR_LIST_FILE +#elif HAVE_EXTATTR_GET_FILE && HAVE_EXTATTR_LIST_FILE && \ + HAVE_DECL_EXTATTR_NAMESPACE_USER /* * FreeBSD extattr interface. @@ -430,11 +437,11 @@ setup_xattrs(struct archive_read_disk *a, * to not include the system extattrs that hold ACLs; we handle * those separately. */ -int +static int setup_xattr(struct archive_read_disk *a, struct archive_entry *entry, int namespace, const char *name, const char *fullname, int fd); -int +static int setup_xattr(struct archive_read_disk *a, struct archive_entry *entry, int namespace, const char *name, const char *fullname, int fd) { diff --git a/lib/libarchive/archive_read_disk_set_standard_lookup.c b/lib/libarchive/archive_read_disk_set_standard_lookup.c index dc2f67f..45f8b43 100644 --- a/lib/libarchive/archive_read_disk_set_standard_lookup.c +++ b/lib/libarchive/archive_read_disk_set_standard_lookup.c @@ -182,6 +182,7 @@ lookup_uname(void *data, uid_t uid) &lookup_uname_helper, (id_t)uid)); } +#if HAVE_GETPWUID_R static const char * lookup_uname_helper(struct name_cache *cache, id_t id) { @@ -222,6 +223,20 @@ lookup_uname_helper(struct name_cache *cache, id_t id) return strdup(result->pw_name); } +#else +static const char * +lookup_uname_helper(struct name_cache *cache, id_t id) +{ + struct passwd *result; + + result = getpwuid((uid_t)id); + + if (result == NULL) + return (NULL); + + return strdup(result->pw_name); +} +#endif static const char * lookup_gname(void *data, gid_t gid) @@ -231,6 +246,7 @@ lookup_gname(void *data, gid_t gid) &lookup_gname_helper, (id_t)gid)); } +#if HAVE_GETGRGID_R static const char * lookup_gname_helper(struct name_cache *cache, id_t id) { @@ -269,4 +285,19 @@ lookup_gname_helper(struct name_cache *cache, id_t id) return strdup(result->gr_name); } +#else +static const char * +lookup_gname_helper(struct name_cache *cache, id_t id) +{ + struct group *result; + + result = getgrgid((gid_t)id); + + if (result == NULL) + return (NULL); + + return strdup(result->gr_name); +} +#endif + #endif /* ! (_WIN32 && !__CYGWIN__) */ diff --git a/lib/libarchive/archive_read_support_compression_all.c b/lib/libarchive/archive_read_support_compression_all.c index bb7b66c..484e557 100644 --- a/lib/libarchive/archive_read_support_compression_all.c +++ b/lib/libarchive/archive_read_support_compression_all.c @@ -46,6 +46,8 @@ archive_read_support_compression_all(struct archive *a) archive_read_support_compression_xz(a); /* The decode code doesn't use an outside library. */ archive_read_support_compression_uu(a); + /* The decode code doesn't use an outside library. */ + archive_read_support_compression_rpm(a); /* Note: We always return ARCHIVE_OK here, even if some of the * above return ARCHIVE_WARN. The intent here is to enable diff --git a/lib/libarchive/archive_read_support_compression_bzip2.c b/lib/libarchive/archive_read_support_compression_bzip2.c index e72e1c5..fc419d4 100644 --- a/lib/libarchive/archive_read_support_compression_bzip2.c +++ b/lib/libarchive/archive_read_support_compression_bzip2.c @@ -48,7 +48,7 @@ __FBSDID("$FreeBSD$"); #include "archive_private.h" #include "archive_read_private.h" -#if HAVE_BZLIB_H +#if defined(HAVE_BZLIB_H) && defined(BZ_CONFIG_ERROR) struct private_data { bz_stream stream; char *out_block; @@ -86,7 +86,7 @@ archive_read_support_compression_bzip2(struct archive *_a) reader->init = bzip2_reader_init; reader->options = NULL; reader->free = bzip2_reader_free; -#if HAVE_BZLIB_H +#if defined(HAVE_BZLIB_H) && defined(BZ_CONFIG_ERROR) return (ARCHIVE_OK); #else archive_set_error(_a, ARCHIVE_ERRNO_MISC, @@ -146,7 +146,7 @@ bzip2_reader_bid(struct archive_read_filter_bidder *self, struct archive_read_fi return (bits_checked); } -#ifndef HAVE_BZLIB_H +#if !defined(HAVE_BZLIB_H) || !defined(BZ_CONFIG_ERROR) /* * If we don't have the library on this system, we can't actually do the diff --git a/lib/libarchive/archive_read_support_compression_rpm.c b/lib/libarchive/archive_read_support_compression_rpm.c new file mode 100644 index 0000000..f8bd878 --- /dev/null +++ b/lib/libarchive/archive_read_support_compression_rpm.c @@ -0,0 +1,288 @@ +/*- + * Copyright (c) 2009 Michihiro NAKAJIMA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "archive_platform.h" +__FBSDID("$FreeBSD$"); + +#ifdef HAVE_ERRNO_H +#include <errno.h> +#endif +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif + +#include "archive.h" +#include "archive_endian.h" +#include "archive_private.h" +#include "archive_read_private.h" + +struct rpm { + int64_t total_in; + size_t hpos; + size_t hlen; + unsigned char header[16]; + enum { + ST_LEAD, /* Skipping 'Lead' section. */ + ST_HEADER, /* Reading 'Header' section; + * first 16 bytes. */ + ST_HEADER_DATA, /* Skipping 'Header' section. */ + ST_PADDING, /* Skipping padding data after the + * 'Header' section. */ + ST_ARCHIVE /* Reading 'Archive' section. */ + } state; + int first_header; +}; +#define RPM_LEAD_SIZE 96 /* Size of 'Lead' section. */ + +static int rpm_bidder_bid(struct archive_read_filter_bidder *, + struct archive_read_filter *); +static int rpm_bidder_init(struct archive_read_filter *); + +static ssize_t rpm_filter_read(struct archive_read_filter *, + const void **); +static int rpm_filter_close(struct archive_read_filter *); + +int +archive_read_support_compression_rpm(struct archive *_a) +{ + struct archive_read *a = (struct archive_read *)_a; + struct archive_read_filter_bidder *bidder; + + bidder = __archive_read_get_bidder(a); + archive_clear_error(_a); + if (bidder == NULL) + return (ARCHIVE_FATAL); + + bidder->data = NULL; + bidder->bid = rpm_bidder_bid; + bidder->init = rpm_bidder_init; + bidder->options = NULL; + bidder->free = NULL; + return (ARCHIVE_OK); +} + +static int +rpm_bidder_bid(struct archive_read_filter_bidder *self, + struct archive_read_filter *filter) +{ + const unsigned char *b; + ssize_t avail; + int bits_checked; + + (void)self; /* UNUSED */ + + b = __archive_read_filter_ahead(filter, 8, &avail); + if (b == NULL) + return (0); + + bits_checked = 0; + /* + * Verify Header Magic Bytes : 0xed 0xab 0xee 0xdb + */ + if (b[0] != 0xed) + return (0); + bits_checked += 8; + if (b[1] != 0xab) + return (0); + bits_checked += 8; + if (b[2] != 0xee) + return (0); + bits_checked += 8; + if (b[3] != 0xdb) + return (0); + bits_checked += 8; + /* + * Check major version. + */ + if (b[4] != 3 && b[4] != 4) + return (0); + bits_checked += 8; + /* + * Check package type; binary or source. + */ + if (b[6] != 0) + return (0); + bits_checked += 8; + if (b[7] != 0 && b[7] != 1) + return (0); + bits_checked += 8; + + return (bits_checked); +} + +static int +rpm_bidder_init(struct archive_read_filter *self) +{ + struct rpm *rpm; + + self->code = ARCHIVE_COMPRESSION_RPM; + self->name = "rpm"; + self->read = rpm_filter_read; + self->skip = NULL; /* not supported */ + self->close = rpm_filter_close; + + rpm = (struct rpm *)calloc(sizeof(*rpm), 1); + if (rpm == NULL) { + archive_set_error(&self->archive->archive, ENOMEM, + "Can't allocate data for rpm"); + return (ARCHIVE_FATAL); + } + + self->data = rpm; + rpm->state = ST_LEAD; + + return (ARCHIVE_OK); +} + +static ssize_t +rpm_filter_read(struct archive_read_filter *self, const void **buff) +{ + struct rpm *rpm; + const unsigned char *b; + ssize_t avail_in, total; + size_t used, n; + uint32_t section; + uint32_t bytes; + + rpm = (struct rpm *)self->data; + *buff = NULL; + total = avail_in = 0; + b = NULL; + used = 0; + do { + if (b == NULL) { + b = __archive_read_filter_ahead(self->upstream, 1, + &avail_in); + if (b == NULL) { + if (avail_in < 0) + return (ARCHIVE_FATAL); + else + break; + } + } + + switch (rpm->state) { + case ST_LEAD: + if (rpm->total_in + avail_in < RPM_LEAD_SIZE) + used += avail_in; + else { + n = RPM_LEAD_SIZE - rpm->total_in; + used += n; + b += n; + rpm->state = ST_HEADER; + rpm->hpos = 0; + rpm->hlen = 0; + rpm->first_header = 1; + } + break; + case ST_HEADER: + n = 16 - rpm->hpos; + if (n > avail_in - used) + n = avail_in - used; + memcpy(rpm->header+rpm->hpos, b, n); + b += n; + used += n; + rpm->hpos += n; + + if (rpm->hpos == 16) { + if (rpm->header[0] != 0x8e || + rpm->header[1] != 0xad || + rpm->header[2] != 0xe8 || + rpm->header[3] != 0x01) { + if (rpm->first_header) { + archive_set_error( + &self->archive->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + "Unrecoginized rpm header"); + return (ARCHIVE_FATAL); + } + rpm->state = ST_ARCHIVE; + *buff = rpm->header; + total = rpm->hpos; + break; + } + /* Calculate 'Header' length. */ + section = archive_be32dec(rpm->header+8); + bytes = archive_be32dec(rpm->header+12); + rpm->hlen = 16 + section * 16 + bytes; + rpm->state = ST_HEADER_DATA; + rpm->first_header = 0; + } + break; + case ST_HEADER_DATA: + n = rpm->hlen - rpm->hpos; + if (n > avail_in - used) + n = avail_in - used; + b += n; + used += n; + rpm->hpos += n; + if (rpm->hpos == rpm->hlen) + rpm->state = ST_PADDING; + break; + case ST_PADDING: + while (used < (size_t)avail_in) { + if (*b != 0) { + /* Read next header. */ + rpm->state = ST_HEADER; + rpm->hpos = 0; + rpm->hlen = 0; + break; + } + b++; + used++; + } + break; + case ST_ARCHIVE: + *buff = b; + total = avail_in; + used = avail_in; + break; + } + if (used == (size_t)avail_in) { + rpm->total_in += used; + __archive_read_filter_consume(self->upstream, used); + b = NULL; + used = 0; + } + } while (total == 0 && avail_in > 0); + + if (used > 0 && b != NULL) { + rpm->total_in += used; + __archive_read_filter_consume(self->upstream, used); + } + return (total); +} + +static int +rpm_filter_close(struct archive_read_filter *self) +{ + struct rpm *rpm; + + rpm = (struct rpm *)self->data; + free(rpm); + + return (ARCHIVE_OK); +} + diff --git a/lib/libarchive/archive_read_support_compression_uu.c b/lib/libarchive/archive_read_support_compression_uu.c index 5f397d6..c3c37d6 100644 --- a/lib/libarchive/archive_read_support_compression_uu.c +++ b/lib/libarchive/archive_read_support_compression_uu.c @@ -325,7 +325,7 @@ uudecode_bidder_bid(struct archive_read_filter_bidder *self, --len; } b += nl; - + if (avail >= 5 && memcmp(b, "====\n", 5) == 0) return (firstline+40); if (avail >= 6 && memcmp(b, "====\r\n", 6) == 0) diff --git a/lib/libarchive/archive_read_support_format_all.c b/lib/libarchive/archive_read_support_format_all.c index 753a105..69d16fc 100644 --- a/lib/libarchive/archive_read_support_format_all.c +++ b/lib/libarchive/archive_read_support_format_all.c @@ -37,6 +37,7 @@ archive_read_support_format_all(struct archive *a) archive_read_support_format_iso9660(a); archive_read_support_format_mtree(a); archive_read_support_format_tar(a); + archive_read_support_format_xar(a); archive_read_support_format_zip(a); return (ARCHIVE_OK); } diff --git a/lib/libarchive/archive_read_support_format_mtree.c b/lib/libarchive/archive_read_support_format_mtree.c index 5efe4a8..bb231fa 100644 --- a/lib/libarchive/archive_read_support_format_mtree.c +++ b/lib/libarchive/archive_read_support_format_mtree.c @@ -370,7 +370,7 @@ process_add_entry(struct archive_read *a, struct mtree *mtree, line = next; next = line + strcspn(line, " \t\r\n"); eq = strchr(line, '='); - if (eq > next) + if (eq == NULL || eq > next) len = next - line; else len = eq - line; diff --git a/lib/libarchive/archive_read_support_format_xar.c b/lib/libarchive/archive_read_support_format_xar.c new file mode 100644 index 0000000..7194fa5 --- /dev/null +++ b/lib/libarchive/archive_read_support_format_xar.c @@ -0,0 +1,3151 @@ +/*- + * Copyright (c) 2009 Michihiro NAKAJIMA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "archive_platform.h" +__FBSDID("$FreeBSD$"); + +#ifdef HAVE_ERRNO_H +#include <errno.h> +#endif +#include <stdio.h> +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif +#if HAVE_LIBXML_XMLREADER_H +#include <libxml/xmlreader.h> +#elif HAVE_BSDXML_H +#include <bsdxml.h> +#elif HAVE_EXPAT_H +#include <expat.h> +#endif +#ifdef HAVE_BZLIB_H +#include <bzlib.h> +#endif +#if HAVE_LZMA_H +#include <lzma.h> +#elif HAVE_LZMADEC_H +#include <lzmadec.h> +#endif +#ifdef HAVE_ZLIB_H +#include <zlib.h> +#endif + +#include "archive.h" +#include "archive_endian.h" +#include "archive_entry.h" +#include "archive_hash.h" +#include "archive_private.h" +#include "archive_read_private.h" + +#if (!defined(HAVE_LIBXML_XMLREADER_H) && \ + !defined(HAVE_BSDXML_H) && !defined(HAVE_EXPAT_H)) ||\ + !defined(HAVE_ZLIB_H) || \ + !defined(ARCHIVE_HAS_MD5) || !defined(ARCHIVE_HAS_SHA1) +/* + * xar needs several external libraries. + * o libxml2 or expat --- XML parser + * o openssl or MD5/SHA1 hash function + * o zlib + * o bzlib2 (option) + * o liblzma (option) + */ +int +archive_read_support_format_xar(struct archive *_a) +{ + struct archive_read *a = (struct archive_read *)_a; + + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "Xar not supported on this platform"); + return (ARCHIVE_WARN); +} + +#else /* Support xar format */ + +//#define DEBUG 1 +//#define DEBUG_PRINT_TOC 1 +#if DEBUG_PRINT_TOC +#define PRINT_TOC(d, outbytes) do { \ + unsigned char *x = (unsigned char *)(uintptr_t)d; \ + unsigned char c = x[outbytes-1]; \ + x[outbytes - 1] = 0; \ + fprintf(stderr, "%s", x); \ + fprintf(stderr, "%c", c); \ + x[outbytes - 1] = c; \ +} while (0) +#else +#define PRINT_TOC(d, outbytes) +#endif + +#define HEADER_MAGIC 0x78617221 +#define HEADER_SIZE 28 +#define HEADER_VERSION 1 +#define CKSUM_NONE 0 +#define CKSUM_SHA1 1 +#define CKSUM_MD5 2 + +#define MD5_SIZE 16 +#define SHA1_SIZE 20 +#define MAX_SUM_SIZE 20 + +enum enctype { + NONE, + GZIP, + BZIP2, + LZMA, + XZ, +}; + +struct chksumval { + int alg; + size_t len; + unsigned char val[MAX_SUM_SIZE]; +}; + +struct chksumwork { + int alg; +#ifdef ARCHIVE_HAS_MD5 + archive_md5_ctx md5ctx; +#endif +#ifdef ARCHIVE_HAS_SHA1 + archive_sha1_ctx sha1ctx; +#endif +}; + +struct xattr { + struct xattr *next; + struct archive_string name; + uint64_t id; + uint64_t length; + uint64_t offset; + uint64_t size; + enum enctype encoding; + struct chksumval a_sum; + struct chksumval e_sum; + struct archive_string fstype; +}; + +struct xar_file { + struct xar_file *next; + struct xar_file *hdnext; + struct xar_file *parent; + int subdirs; + + unsigned int has; +#define HAS_DATA 0x00001 +#define HAS_PATHNAME 0x00002 +#define HAS_SYMLINK 0x00004 +#define HAS_TIME 0x00008 +#define HAS_UID 0x00010 +#define HAS_GID 0x00020 +#define HAS_MODE 0x00040 +#define HAS_TYPE 0x00080 +#define HAS_DEV 0x00100 +#define HAS_DEVMAJOR 0x00200 +#define HAS_DEVMINOR 0x00400 +#define HAS_INO 0x00800 +#define HAS_FFLAGS 0x01000 +#define HAS_XATTR 0x02000 +#define HAS_ACL 0x04000 + + uint64_t id; + uint64_t length; + uint64_t offset; + uint64_t size; + enum enctype encoding; + struct chksumval a_sum; + struct chksumval e_sum; + struct archive_string pathname; + struct archive_string symlink; + time_t ctime; + time_t mtime; + time_t atime; + struct archive_string uname; + uid_t uid; + struct archive_string gname; + gid_t gid; + mode_t mode; + dev_t dev; + dev_t devmajor; + dev_t devminor; + int64_t ino64; + struct archive_string fflags_text; + unsigned int link; + unsigned int nlink; + struct archive_string hardlink; + struct xattr *xattr_list; +}; + +struct hdlink { + struct hdlink *next; + + unsigned int id; + int cnt; + struct xar_file *files; +}; + +struct heap_queue { + struct xar_file **files; + int allocated; + int used; +}; + +enum xmlstatus { + INIT, + XAR, + TOC, + TOC_CREATION_TIME, + TOC_CHECKSUM, + TOC_CHECKSUM_OFFSET, + TOC_CHECKSUM_SIZE, + TOC_FILE, + FILE_DATA, + FILE_DATA_LENGTH, + FILE_DATA_OFFSET, + FILE_DATA_SIZE, + FILE_DATA_ENCODING, + FILE_DATA_A_CHECKSUM, + FILE_DATA_E_CHECKSUM, + FILE_DATA_CONTENT, + FILE_EA, + FILE_EA_LENGTH, + FILE_EA_OFFSET, + FILE_EA_SIZE, + FILE_EA_ENCODING, + FILE_EA_A_CHECKSUM, + FILE_EA_E_CHECKSUM, + FILE_EA_NAME, + FILE_EA_FSTYPE, + FILE_CTIME, + FILE_MTIME, + FILE_ATIME, + FILE_GROUP, + FILE_GID, + FILE_USER, + FILE_UID, + FILE_MODE, + FILE_DEVICE, + FILE_DEVICE_MAJOR, + FILE_DEVICE_MINOR, + FILE_DEVICENO, + FILE_INODE, + FILE_LINK, + FILE_TYPE, + FILE_NAME, + FILE_ACL, + FILE_ACL_DEFAULT, + FILE_ACL_ACCESS, + FILE_ACL_APPLEEXTENDED, + /* BSD file flags. */ + FILE_FLAGS, + FILE_FLAGS_USER_NODUMP, + FILE_FLAGS_USER_IMMUTABLE, + FILE_FLAGS_USER_APPEND, + FILE_FLAGS_USER_OPAQUE, + FILE_FLAGS_USER_NOUNLINK, + FILE_FLAGS_SYS_ARCHIVED, + FILE_FLAGS_SYS_IMMUTABLE, + FILE_FLAGS_SYS_APPEND, + FILE_FLAGS_SYS_NOUNLINK, + FILE_FLAGS_SYS_SNAPSHOT, + /* Linux file flags. */ + FILE_EXT2, + FILE_EXT2_SecureDeletion, + FILE_EXT2_Undelete, + FILE_EXT2_Compress, + FILE_EXT2_Synchronous, + FILE_EXT2_Immutable, + FILE_EXT2_AppendOnly, + FILE_EXT2_NoDump, + FILE_EXT2_NoAtime, + FILE_EXT2_CompDirty, + FILE_EXT2_CompBlock, + FILE_EXT2_NoCompBlock, + FILE_EXT2_CompError, + FILE_EXT2_BTree, + FILE_EXT2_HashIndexed, + FILE_EXT2_iMagic, + FILE_EXT2_Journaled, + FILE_EXT2_NoTail, + FILE_EXT2_DirSync, + FILE_EXT2_TopDir, + FILE_EXT2_Reserved, + UNKNOWN, +}; + +struct unknown_tag { + struct unknown_tag *next; + struct archive_string name; +}; + +struct xar { + uint64_t offset; /* Current position in the file. */ + int64_t total; + uint64_t h_base; + int end_of_file; + unsigned char buff[1024*32]; + + enum xmlstatus xmlsts; + enum xmlstatus xmlsts_unknown; + struct unknown_tag *unknowntags; + int base64text; + + /* + * TOC + */ + uint64_t toc_remaining; + uint64_t toc_total; + uint64_t toc_chksum_offset; + uint64_t toc_chksum_size; + + /* + * For Decoding data. + */ + enum enctype rd_encoding; + z_stream stream; + int stream_valid; +#if defined(HAVE_BZLIB_H) && defined(BZ_CONFIG_ERROR) + bz_stream bzstream; + int bzstream_valid; +#endif +#if HAVE_LZMA_H && HAVE_LIBLZMA + lzma_stream lzstream; + int lzstream_valid; +#elif HAVE_LZMADEC_H && HAVE_LIBLZMADEC + lzmadec_stream lzstream; + int lzstream_valid; +#endif + /* + * For Checksum data. + */ + struct chksumwork a_sumwrk; + struct chksumwork e_sumwrk; + + struct xar_file *file; /* current reading file. */ + struct xattr *xattr; /* current reading extended attribute. */ + struct heap_queue file_queue; + struct xar_file *hdlink_orgs; + struct hdlink *hdlink_list; + + int entry_init; + uint64_t entry_total; + uint64_t entry_remaining; + uint64_t entry_size; + enum enctype entry_encoding; + struct chksumval entry_a_sum; + struct chksumval entry_e_sum; +}; + +struct xmlattr { + struct xmlattr *next; + char *name; + char *value; +}; + +struct xmlattr_list { + struct xmlattr *first; + struct xmlattr **last; +}; + +static int xar_bid(struct archive_read *); +static int xar_read_header(struct archive_read *, + struct archive_entry *); +static int xar_read_data(struct archive_read *, + const void **, size_t *, off_t *); +static int xar_read_data_skip(struct archive_read *); +static int xar_cleanup(struct archive_read *); +static int move_reading_point(struct archive_read *, uint64_t); +static int rd_contents_init(struct archive_read *, + enum enctype, int, int); +static int rd_contents(struct archive_read *, const void **, + size_t *, size_t *, uint64_t); +static uint64_t atol10(const char *, size_t); +static int64_t atol8(const char *, size_t); +static size_t atohex(unsigned char *, size_t, const char *, size_t); +static time_t parse_time(const char *p, size_t n); +static void heap_add_entry(struct heap_queue *, struct xar_file *); +static struct xar_file *heap_get_entry(struct heap_queue *); +static void add_link(struct xar *, struct xar_file *); +static void checksum_init(struct archive_read *, int, int); +static void checksum_update(struct archive_read *, const void *, + size_t, const void *, size_t); +static int checksum_final(struct archive_read *, const void *, + size_t, const void *, size_t); +static int decompression_init(struct archive_read *, enum enctype); +static int decompress(struct archive_read *, const void **, + size_t *, const void *, size_t *); +static int decompression_cleanup(struct archive_read *); +static void xmlattr_cleanup(struct xmlattr_list *); +static void file_new(struct xar *, struct xmlattr_list *); +static void file_free(struct xar_file *); +static void xattr_new(struct xar *, struct xmlattr_list *); +static void xattr_free(struct xattr *); +static int getencoding(struct xmlattr_list *); +static int getsumalgorithm(struct xmlattr_list *); +static void unknowntag_start(struct xar *, const char *); +static void unknowntag_end(struct xar *, const char *); +static void xml_start(void *, const char *, struct xmlattr_list *); +static void xml_end(void *, const char *); +static void xml_data(void *, const char *, int); +static int xml_parse_file_flags(struct xar *, const char *); +static int xml_parse_file_ext2(struct xar *, const char *); +#if defined(HAVE_LIBXML_XMLREADER_H) +static int xml2_xmlattr_setup(struct xmlattr_list *, xmlTextReaderPtr); +static int xml2_read_cb(void *, char *, int); +static int xml2_close_cb(void *); +static void xml2_error_hdr(void *, const char *, xmlParserSeverities, + xmlTextReaderLocatorPtr); +static int xml2_read_toc(struct archive_read *); +#elif defined(HAVE_BSDXML_H) || defined(HAVE_EXPAT_H) +static void expat_xmlattr_setup(struct xmlattr_list *, const XML_Char **); +static void expat_start_cb(void *, const XML_Char *, const XML_Char **); +static void expat_end_cb(void *, const XML_Char *); +static void expat_data_cb(void *, const XML_Char *, int); +static int expat_read_toc(struct archive_read *); +#endif + +int +archive_read_support_format_xar(struct archive *_a) +{ + struct xar *xar; + struct archive_read *a = (struct archive_read *)_a; + int r; + + xar = (struct xar *)calloc(1, sizeof(*xar)); + if (xar == NULL) { + archive_set_error(&a->archive, ENOMEM, + "Can't allocate xar data"); + return (ARCHIVE_FATAL); + } + + r = __archive_read_register_format(a, + xar, + "xar", + xar_bid, + NULL, + xar_read_header, + xar_read_data, + xar_read_data_skip, + xar_cleanup); + if (r != ARCHIVE_OK) + free(xar); + return (r); +} + +static int +xar_bid(struct archive_read *a) +{ + const unsigned char *b; + int bid; + + b = __archive_read_ahead(a, HEADER_SIZE, NULL); + if (b == NULL) + return (-1); + + bid = 0; + /* + * Verify magic code + */ + if (archive_be32dec(b) != HEADER_MAGIC) + return (0); + bid += 32; + /* + * Verify header size + */ + if (archive_be16dec(b+4) != HEADER_SIZE) + return (0); + bid += 16; + /* + * Verify header version + */ + if (archive_be16dec(b+6) != HEADER_VERSION) + return (0); + bid += 16; + /* + * Verify type of checksum + */ + switch (archive_be32dec(b+24)) { + case CKSUM_NONE: + case CKSUM_SHA1: + case CKSUM_MD5: + bid += 32; + break; + default: + return (0); + } + + return (bid); +} + +static int +read_toc(struct archive_read *a) +{ + struct xar *xar; + struct xar_file *file; + const unsigned char *b; + uint64_t toc_compressed_size; + uint64_t toc_uncompressed_size; + uint32_t toc_chksum_alg; + ssize_t bytes; + int r; + + xar = (struct xar *)(a->format->data); + + /* + * Read xar header. + */ + b = __archive_read_ahead(a, HEADER_SIZE, &bytes); + if (bytes < 0) + return ((int)bytes); + if (bytes < HEADER_SIZE) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + "Truncated archive header"); + return (ARCHIVE_FATAL); + } + + if (archive_be32dec(b) != HEADER_MAGIC) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + "Invalid header magic"); + return (ARCHIVE_FATAL); + } + if (archive_be16dec(b+6) != HEADER_VERSION) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + "Unsupported header version(%d)", + archive_be16dec(b+6)); + return (ARCHIVE_FATAL); + } + toc_compressed_size = archive_be64dec(b+8); + xar->toc_remaining = toc_compressed_size; + toc_uncompressed_size = archive_be64dec(b+16); + toc_chksum_alg = archive_be32dec(b+24); + __archive_read_consume(a, HEADER_SIZE); + xar->offset += HEADER_SIZE; + xar->toc_total = 0; + + /* + * Read TOC(Table of Contents). + */ + /* Initialize reading contents. */ + r = move_reading_point(a, HEADER_SIZE); + if (r != ARCHIVE_OK) + return (r); + r = rd_contents_init(a, GZIP, toc_chksum_alg, CKSUM_NONE); + if (r != ARCHIVE_OK) + return (r); + +#ifdef HAVE_LIBXML_XMLREADER_H + r = xml2_read_toc(a); +#elif defined(HAVE_BSDXML_H) || defined(HAVE_EXPAT_H) + r = expat_read_toc(a); +#endif + if (r != ARCHIVE_OK) + return (r); + + /* Set 'The HEAP' base. */ + xar->h_base = xar->offset; + if (xar->toc_total != toc_uncompressed_size) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "TOC uncompressed size error"); + return (ARCHIVE_FATAL); + } + + /* + * Checksum TOC + */ + if (toc_chksum_alg != CKSUM_NONE) { + r = move_reading_point(a, xar->toc_chksum_offset); + if (r != ARCHIVE_OK) + return (r); + b = __archive_read_ahead(a, xar->toc_chksum_size, &bytes); + if (bytes < 0) + return ((int)bytes); + if ((uint64_t)bytes < xar->toc_chksum_size) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + "Truncated archive file"); + return (ARCHIVE_FATAL); + } + r = checksum_final(a, b, xar->toc_chksum_size, NULL, 0); + __archive_read_consume(a, xar->toc_chksum_size); + xar->offset += xar->toc_chksum_size; + if (r != ARCHIVE_OK) + return (ARCHIVE_FATAL); + } + + /* + * Connect hardlinked files. + */ + for (file = xar->hdlink_orgs; file != NULL; file = file->hdnext) { + struct hdlink **hdlink; + + for (hdlink = &(xar->hdlink_list); *hdlink != NULL; + hdlink = &((*hdlink)->next)) { + if ((*hdlink)->id == file->id) { + struct hdlink *hltmp; + struct xar_file *f2; + int nlink = (*hdlink)->cnt + 1; + + file->nlink = nlink; + for (f2 = (*hdlink)->files; f2 != NULL; + f2 = f2->hdnext) { + f2->nlink = nlink; + archive_string_copy( + &(f2->hardlink), &(file->pathname)); + } + /* Remove resolved files from hdlist_list. */ + hltmp = *hdlink; + *hdlink = hltmp->next; + free(hltmp); + break; + } + } + } + a->archive.archive_format = ARCHIVE_FORMAT_XAR; + a->archive.archive_format_name = "xar"; + + return (ARCHIVE_OK); +} + +static int +xar_read_header(struct archive_read *a, struct archive_entry *entry) +{ + struct xar *xar; + struct xar_file *file; + struct xattr *xattr; + int r; + + xar = (struct xar *)(a->format->data); + + if (xar->offset == 0) { + /* Read TOC. */ + r = read_toc(a); + if (r != ARCHIVE_OK) + return (r); + } + + for (;;) { + file = xar->file = heap_get_entry(&(xar->file_queue)); + if (file == NULL) { + xar->end_of_file = 1; + return (ARCHIVE_EOF); + } + if ((file->mode & AE_IFMT) != AE_IFDIR) + break; + if (file->has != (HAS_PATHNAME | HAS_TYPE)) + break; + /* + * If a file type is a directory and it does not have + * any metadata, do not export. + */ + file_free(file); + } + archive_entry_set_atime(entry, file->atime, 0); + archive_entry_set_ctime(entry, file->ctime, 0); + archive_entry_set_mtime(entry, file->mtime, 0); + archive_entry_set_gid(entry, file->gid); + if (file->gname.length > 0) + archive_entry_update_gname_utf8(entry, file->gname.s); + archive_entry_set_uid(entry, file->uid); + if (file->uname.length > 0) + archive_entry_update_uname_utf8(entry, file->uname.s); + archive_entry_set_mode(entry, file->mode); + archive_entry_update_pathname_utf8(entry, file->pathname.s); + if (file->symlink.length > 0) + archive_entry_update_symlink_utf8(entry, file->symlink.s); + /* Set proper nlink. */ + if ((file->mode & AE_IFMT) == AE_IFDIR) + archive_entry_set_nlink(entry, file->subdirs + 2); + else + archive_entry_set_nlink(entry, file->nlink); + archive_entry_set_size(entry, file->size); + if (archive_strlen(&(file->hardlink)) > 0) + archive_entry_update_hardlink_utf8(entry, + file->hardlink.s); + archive_entry_set_ino64(entry, file->ino64); + if (file->has & HAS_DEV) + archive_entry_set_dev(entry, file->dev); + if (file->has & HAS_DEVMAJOR) + archive_entry_set_devmajor(entry, file->devmajor); + if (file->has & HAS_DEVMINOR) + archive_entry_set_devminor(entry, file->devminor); + if (archive_strlen(&(file->fflags_text)) > 0) + archive_entry_copy_fflags_text(entry, file->fflags_text.s); + + xar->entry_init = 1; + xar->entry_total = 0; + xar->entry_remaining = file->length; + xar->entry_size = file->size; + xar->entry_encoding = file->encoding; + xar->entry_a_sum = file->a_sum; + xar->entry_e_sum = file->e_sum; + /* + * Read extended attributes. + */ + r = ARCHIVE_OK; + xattr = file->xattr_list; + while (xattr != NULL) { + const void *d; + size_t outbytes, used; + + r = move_reading_point(a, xattr->offset); + if (r != ARCHIVE_OK) + break; + r = rd_contents_init(a, xattr->encoding, + xattr->a_sum.alg, xattr->e_sum.alg); + if (r != ARCHIVE_OK) + break; + d = NULL; + r = rd_contents(a, &d, &outbytes, &used, xattr->length); + if (r != ARCHIVE_OK) + break; + if (outbytes != xattr->size) { + archive_set_error(&(a->archive), ARCHIVE_ERRNO_MISC, + "Decompressed size error"); + r = ARCHIVE_FATAL; + break; + } + r = checksum_final(a, + xattr->a_sum.val, xattr->a_sum.len, + xattr->e_sum.val, xattr->e_sum.len); + if (r != ARCHIVE_OK) + break; + archive_entry_xattr_add_entry(entry, + xattr->name.s, d, outbytes); + xattr = xattr->next; + } + if (r != ARCHIVE_OK) { + file_free(file); + return (r); + } + + if (xar->entry_remaining > 0) + /* Move reading point to the beginning of current + * file contents. */ + r = move_reading_point(a, file->offset); + else + r = ARCHIVE_OK; + + file_free(file); + return (r); +} + +static int +xar_read_data(struct archive_read *a, + const void **buff, size_t *size, off_t *offset) +{ + struct xar *xar; + size_t used; + int r; + + xar = (struct xar *)(a->format->data); + if (xar->end_of_file || xar->entry_remaining <= 0) { + r = ARCHIVE_EOF; + goto abort_read_data; + } + + if (xar->entry_init) { + r = rd_contents_init(a, xar->entry_encoding, + xar->entry_a_sum.alg, xar->entry_e_sum.alg); + if (r != ARCHIVE_OK) { + xar->entry_remaining = 0; + return (r); + } + xar->entry_init = 0; + } + + *buff = NULL; + r = rd_contents(a, buff, size, &used, xar->entry_remaining); + if (r != ARCHIVE_OK) + goto abort_read_data; + + *offset = xar->entry_total; + xar->entry_total += *size; + xar->total += *size; + xar->offset += used; + xar->entry_remaining -= used; + __archive_read_consume(a, used); + + if (xar->entry_remaining == 0) { + if (xar->entry_total != xar->entry_size) { + archive_set_error(&(a->archive), ARCHIVE_ERRNO_MISC, + "Decompressed size error"); + r = ARCHIVE_FATAL; + goto abort_read_data; + } + r = checksum_final(a, + xar->entry_a_sum.val, xar->entry_a_sum.len, + xar->entry_e_sum.val, xar->entry_e_sum.len); + if (r != ARCHIVE_OK) + goto abort_read_data; + } + + return (ARCHIVE_OK); +abort_read_data: + *buff = NULL; + *size = 0; + *offset = xar->total; + return (r); +} + +static int +xar_read_data_skip(struct archive_read *a) +{ + struct xar *xar; + int64_t bytes_skipped; + + xar = (struct xar *)(a->format->data); + if (xar->end_of_file) + return (ARCHIVE_EOF); + bytes_skipped = __archive_read_skip(a, xar->entry_remaining); + if (bytes_skipped < 0) + return (ARCHIVE_FATAL); + xar->offset += bytes_skipped; + return (ARCHIVE_OK); +} + +static int +xar_cleanup(struct archive_read *a) +{ + struct xar *xar; + struct hdlink *hdlink; + int i; + int r; + + xar = (struct xar *)(a->format->data); + r = decompression_cleanup(a); + hdlink = xar->hdlink_list; + while (hdlink != NULL) { + struct hdlink *next = hdlink->next; + + free(hdlink); + hdlink = next; + } + for (i = 0; i < xar->file_queue.used; i++) + file_free(xar->file_queue.files[i]); + while (xar->unknowntags != NULL) { + struct unknown_tag *tag; + + tag = xar->unknowntags; + xar->unknowntags = tag->next; + archive_string_free(&(tag->name)); + free(tag); + } + free(xar); + a->format->data = NULL; + return (r); +} + +static int +move_reading_point(struct archive_read *a, uint64_t offset) +{ + struct xar *xar; + + xar = (struct xar *)(a->format->data); + if (xar->offset - xar->h_base != offset) { + /* Seek forward to the start of file contents. */ + int64_t step; + + step = offset - (xar->offset - xar->h_base); + if (step > 0) { + step = __archive_read_skip(a, step); + if (step < 0) + return ((int)step); + xar->offset += step; + } else { + archive_set_error(&(a->archive), + ARCHIVE_ERRNO_MISC, + "Cannot seek."); + return (ARCHIVE_FAILED); + } + } + return (ARCHIVE_OK); +} + +static int +rd_contents_init(struct archive_read *a, enum enctype encoding, + int a_sum_alg, int e_sum_alg) +{ + int r; + + /* Init decompress library. */ + if ((r = decompression_init(a, encoding)) != ARCHIVE_OK) + return (r); + /* Init checksum library. */ + checksum_init(a, a_sum_alg, e_sum_alg); + return (ARCHIVE_OK); +} + +static int +rd_contents(struct archive_read *a, const void **buff, size_t *size, + size_t *used, uint64_t remaining) +{ + const unsigned char *b; + ssize_t bytes; + + /* Get whatever bytes are immediately available. */ + b = __archive_read_ahead(a, 1, &bytes); + if (bytes < 0) + return ((int)bytes); + if (bytes == 0) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "Truncated archive file"); + return (ARCHIVE_FATAL); + } + if ((uint64_t)bytes > remaining) + bytes = (ssize_t)remaining; + + /* + * Decompress contents of file. + */ + *used = bytes; + if (decompress(a, buff, size, b, used) != ARCHIVE_OK) + return (ARCHIVE_FATAL); + + /* + * Update checksum of a compressed data and a extracted data. + */ + checksum_update(a, b, *used, *buff, *size); + + return (ARCHIVE_OK); +} + +/* + * Note that this implementation does not (and should not!) obey + * locale settings; you cannot simply substitute strtol here, since + * it does obey locale. + */ + +static uint64_t +atol10(const char *p, size_t char_cnt) +{ + uint64_t l; + int digit; + + l = 0; + digit = *p - '0'; + while (digit >= 0 && digit < 10 && char_cnt-- > 0) { + l = (l * 10) + digit; + digit = *++p - '0'; + } + return (l); +} + +static int64_t +atol8(const char *p, size_t char_cnt) +{ + int64_t l; + int digit; + + l = 0; + while (char_cnt-- > 0) { + if (*p >= '0' && *p <= '7') + digit = *p - '0'; + else + break; + p++; + l <<= 3; + l |= digit; + } + return (l); +} + +static size_t +atohex(unsigned char *b, size_t bsize, const char *p, size_t psize) +{ + size_t fbsize = bsize; + + while (bsize && psize > 1) { + unsigned char x; + + if (p[0] >= 'a' && p[0] <= 'z') + x = (p[0] - 'a' + 0x0a) << 4; + else if (p[0] >= 'A' && p[0] <= 'Z') + x = (p[0] - 'A' + 0x0a) << 4; + else if (p[0] >= '0' && p[0] <= '9') + x = (p[0] - '0') << 4; + else + return (-1); + if (p[1] >= 'a' && p[1] <= 'z') + x |= p[1] - 'a' + 0x0a; + else if (p[1] >= 'A' && p[1] <= 'Z') + x |= p[1] - 'A' + 0x0a; + else if (p[1] >= '0' && p[1] <= '9') + x |= p[1] - '0'; + else + return (-1); + + *b++ = x; + bsize--; + p += 2; + psize -= 2; + } + return (fbsize - bsize); +} + +static time_t +time_from_tm(struct tm *t) +{ +#if HAVE_TIMEGM + /* Use platform timegm() if available. */ + return (timegm(t)); +#else + /* Else use direct calculation using POSIX assumptions. */ + /* First, fix up tm_yday based on the year/month/day. */ + mktime(t); + /* Then we can compute timegm() from first principles. */ + return (t->tm_sec + t->tm_min * 60 + t->tm_hour * 3600 + + t->tm_yday * 86400 + (t->tm_year - 70) * 31536000 + + ((t->tm_year - 69) / 4) * 86400 - + ((t->tm_year - 1) / 100) * 86400 + + ((t->tm_year + 299) / 400) * 86400); +#endif +} + +static time_t +parse_time(const char *p, size_t n) +{ + struct tm tm; + time_t t = 0; + int64_t data; + + memset(&tm, 0, sizeof(tm)); + if (n != 20) + return (t); + data = atol10(p, 4); + if (data < 1900) + return (t); + tm.tm_year = (int)data - 1900; + p += 4; + if (*p++ != '-') + return (t); + data = atol10(p, 2); + if (data < 1 || data > 12) + return (t); + tm.tm_mon = (int)data -1; + p += 2; + if (*p++ != '-') + return (t); + data = atol10(p, 2); + if (data < 1 || data > 31) + return (t); + tm.tm_mday = (int)data; + p += 2; + if (*p++ != 'T') + return (t); + data = atol10(p, 2); + if (data < 0 || data > 23) + return (t); + tm.tm_hour = (int)data; + p += 2; + if (*p++ != ':') + return (t); + data = atol10(p, 2); + if (data < 0 || data > 59) + return (t); + tm.tm_min = (int)data; + p += 2; + if (*p++ != ':') + return (t); + data = atol10(p, 2); + if (data < 0 || data > 60) + return (t); + tm.tm_sec = (int)data; +#if 0 + p += 2; + if (*p != 'Z') + return (t); +#endif + + t = time_from_tm(&tm); + + return (t); +} + +static void +heap_add_entry(struct heap_queue *heap, struct xar_file *file) +{ + uint64_t file_id, parent_id; + int hole, parent; + + /* Expand our pending files list as necessary. */ + if (heap->used >= heap->allocated) { + struct xar_file **new_pending_files; + int new_size = heap->allocated * 2; + + if (heap->allocated < 1024) + new_size = 1024; + /* Overflow might keep us from growing the list. */ + if (new_size <= heap->allocated) + __archive_errx(1, "Out of memory"); + new_pending_files = (struct xar_file **) + malloc(new_size * sizeof(new_pending_files[0])); + if (new_pending_files == NULL) + __archive_errx(1, "Out of memory"); + memcpy(new_pending_files, heap->files, + heap->allocated * sizeof(new_pending_files[0])); + if (heap->files != NULL) + free(heap->files); + heap->files = new_pending_files; + heap->allocated = new_size; + } + + file_id = file->id; + + /* + * Start with hole at end, walk it up tree to find insertion point. + */ + hole = heap->used++; + while (hole > 0) { + parent = (hole - 1)/2; + parent_id = heap->files[parent]->id; + if (file_id >= parent_id) { + heap->files[hole] = file; + return; + } + // Move parent into hole <==> move hole up tree. + heap->files[hole] = heap->files[parent]; + hole = parent; + } + heap->files[0] = file; +} + +static struct xar_file * +heap_get_entry(struct heap_queue *heap) +{ + uint64_t a_id, b_id, c_id; + int a, b, c; + struct xar_file *r, *tmp; + + if (heap->used < 1) + return (NULL); + + /* + * The first file in the list is the earliest; we'll return this. + */ + r = heap->files[0]; + + /* + * Move the last item in the heap to the root of the tree + */ + heap->files[0] = heap->files[--(heap->used)]; + + /* + * Rebalance the heap. + */ + a = 0; // Starting element and its heap key + a_id = heap->files[a]->id; + for (;;) { + b = a + a + 1; // First child + if (b >= heap->used) + return (r); + b_id = heap->files[b]->id; + c = b + 1; // Use second child if it is smaller. + if (c < heap->used) { + c_id = heap->files[c]->id; + if (c_id < b_id) { + b = c; + b_id = c_id; + } + } + if (a_id <= b_id) + return (r); + tmp = heap->files[a]; + heap->files[a] = heap->files[b]; + heap->files[b] = tmp; + a = b; + } +} + +static void +add_link(struct xar *xar, struct xar_file *file) +{ + struct hdlink *hdlink; + + for (hdlink = xar->hdlink_list; hdlink != NULL; hdlink = hdlink->next) { + if (hdlink->id == file->link) { + file->hdnext = hdlink->files; + hdlink->cnt++; + hdlink->files = file; + return; + } + } + hdlink = malloc(sizeof(*hdlink)); + if (hdlink == NULL) + __archive_errx(1, "No memory for add_link()"); + file->hdnext = NULL; + hdlink->id = file->link; + hdlink->cnt = 1; + hdlink->files = file; + hdlink->next = xar->hdlink_list; + xar->hdlink_list = hdlink; +} + +static void +_checksum_init(struct chksumwork *sumwrk, int sum_alg) +{ + sumwrk->alg = sum_alg; + switch (sum_alg) { + case CKSUM_NONE: + break; + case CKSUM_SHA1: + archive_sha1_init(&(sumwrk->sha1ctx)); + break; + case CKSUM_MD5: + archive_md5_init(&(sumwrk->md5ctx)); + break; + } +} + +static void +_checksum_update(struct chksumwork *sumwrk, const void *buff, size_t size) +{ + + switch (sumwrk->alg) { + case CKSUM_NONE: + break; + case CKSUM_SHA1: + archive_sha1_update(&(sumwrk->sha1ctx), buff, size); + break; + case CKSUM_MD5: + archive_md5_update(&(sumwrk->md5ctx), buff, size); + break; + } +} + +static int +_checksum_final(struct chksumwork *sumwrk, const void *val, size_t len) +{ + unsigned char sum[MAX_SUM_SIZE]; + int r = ARCHIVE_OK; + + switch (sumwrk->alg) { + case CKSUM_NONE: + break; + case CKSUM_SHA1: + archive_sha1_final(&(sumwrk->sha1ctx), sum); + if (len != SHA1_SIZE || + memcmp(val, sum, SHA1_SIZE) != 0) + r = ARCHIVE_FAILED; + break; + case CKSUM_MD5: + archive_md5_final(&(sumwrk->md5ctx), sum); + if (len != MD5_SIZE || + memcmp(val, sum, MD5_SIZE) != 0) + r = ARCHIVE_FAILED; + break; + } + return (r); +} + +static void +checksum_init(struct archive_read *a, int a_sum_alg, int e_sum_alg) +{ + struct xar *xar; + + xar = (struct xar *)(a->format->data); + _checksum_init(&(xar->a_sumwrk), a_sum_alg); + _checksum_init(&(xar->e_sumwrk), e_sum_alg); +} + +static void +checksum_update(struct archive_read *a, const void *abuff, size_t asize, + const void *ebuff, size_t esize) +{ + struct xar *xar; + + xar = (struct xar *)(a->format->data); + _checksum_update(&(xar->a_sumwrk), abuff, asize); + _checksum_update(&(xar->e_sumwrk), ebuff, esize); +} + +static int +checksum_final(struct archive_read *a, const void *a_sum_val, + size_t a_sum_len, const void *e_sum_val, size_t e_sum_len) +{ + struct xar *xar; + int r; + + xar = (struct xar *)(a->format->data); + r = _checksum_final(&(xar->a_sumwrk), a_sum_val, a_sum_len); + if (r == ARCHIVE_OK) + r = _checksum_final(&(xar->e_sumwrk), e_sum_val, e_sum_len); + if (r != ARCHIVE_OK) + archive_set_error(&(a->archive), ARCHIVE_ERRNO_MISC, + "Sumcheck error"); + return (r); +} + +static int +decompression_init(struct archive_read *a, enum enctype encoding) +{ + struct xar *xar; + const char *detail; + int r; + + xar = (struct xar *)(a->format->data); + xar->rd_encoding = encoding; + switch (encoding) { + case NONE: + break; + case GZIP: + if (xar->stream_valid) + r = inflateReset(&(xar->stream)); + else + r = inflateInit(&(xar->stream)); + if (r != Z_OK) { + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "Couldn't initialize zlib stream."); + return (ARCHIVE_FATAL); + } + xar->stream_valid = 1; + xar->stream.total_in = 0; + xar->stream.total_out = 0; + break; +#if defined(HAVE_BZLIB_H) && defined(BZ_CONFIG_ERROR) + case BZIP2: + if (xar->bzstream_valid) { + BZ2_bzDecompressEnd(&(xar->bzstream)); + xar->bzstream_valid = 0; + } + r = BZ2_bzDecompressInit(&(xar->bzstream), 0, 0); + if (r == BZ_MEM_ERROR) + r = BZ2_bzDecompressInit(&(xar->bzstream), 0, 1); + if (r != BZ_OK) { + int err = ARCHIVE_ERRNO_MISC; + detail = NULL; + switch (r) { + case BZ_PARAM_ERROR: + detail = "invalid setup parameter"; + break; + case BZ_MEM_ERROR: + err = ENOMEM; + detail = "out of memory"; + break; + case BZ_CONFIG_ERROR: + detail = "mis-compiled library"; + break; + } + archive_set_error(&a->archive, err, + "Internal error initializing decompressor: %s", + detail == NULL ? "??" : detail); + xar->bzstream_valid = 0; + return (ARCHIVE_FATAL); + } + xar->bzstream_valid = 1; + xar->bzstream.total_in_lo32 = 0; + xar->bzstream.total_in_hi32 = 0; + xar->bzstream.total_out_lo32 = 0; + xar->bzstream.total_out_hi32 = 0; + break; +#endif +#if defined(HAVE_LZMA_H) && defined(HAVE_LIBLZMA) + case XZ: + case LZMA: + if (xar->lzstream_valid) { + lzma_end(&(xar->lzstream)); + xar->lzstream_valid = 0; + } + if (xar->entry_encoding == XZ) + r = lzma_stream_decoder(&(xar->lzstream), + (1U << 30),/* memlimit */ + LZMA_CONCATENATED); + else + r = lzma_alone_decoder(&(xar->lzstream), + (1U << 30));/* memlimit */ + if (r != LZMA_OK) { + switch (r) { + case LZMA_MEM_ERROR: + archive_set_error(&a->archive, + ENOMEM, + "Internal error initializing " + "compression library: " + "Cannot allocate memory"); + break; + case LZMA_OPTIONS_ERROR: + archive_set_error(&a->archive, + ARCHIVE_ERRNO_MISC, + "Internal error initializing " + "compression library: " + "Invalid or unsupported options"); + break; + default: + archive_set_error(&a->archive, + ARCHIVE_ERRNO_MISC, + "Internal error initializing " + "lzma library"); + break; + } + return (ARCHIVE_FATAL); + } + xar->lzstream_valid = 1; + xar->lzstream.total_in = 0; + xar->lzstream.total_out = 0; + break; +#elif defined(HAVE_LZMADEC_H) && defined(HAVE_LIBLZMADEC) + case LZMA: + if (xar->lzstream_valid) + lzmadec_end(&(xar->lzstream)); + r = lzmadec_init(&(xar->lzstream)); + if (r != LZMADEC_OK) { + switch (r) { + case LZMADEC_HEADER_ERROR: + archive_set_error(&a->archive, + ARCHIVE_ERRNO_MISC, + "Internal error initializing " + "compression library: " + "invalid header"); + break; + case LZMADEC_MEM_ERROR: + archive_set_error(&a->archive, + ENOMEM, + "Internal error initializing " + "compression library: " + "out of memory"); + break; + } + return (ARCHIVE_FATAL); + } + xar->lzstream_valid = 1; + xar->lzstream.total_in = 0; + xar->lzstream.total_out = 0; + break; +#endif + /* + * Unsupported compression. + */ + default: +#if !defined(HAVE_BZLIB_H) || !defined(BZ_CONFIG_ERROR) + case BZIP2: +#endif +#if !defined(HAVE_LZMA_H) || !defined(HAVE_LIBLZMA) +#if !defined(HAVE_LZMADEC_H) || !defined(HAVE_LIBLZMADEC) + case LZMA: +#endif + case XZ: +#endif + switch (xar->entry_encoding) { + case BZIP2: detail = "bzip2"; break; + case LZMA: detail = "lzma"; break; + case XZ: detail = "xz"; break; + default: detail = "??"; break; + } + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "%s compression not supported on this platform", + detail); + return (ARCHIVE_FAILED); + } + return (ARCHIVE_OK); +} + +static int +decompress(struct archive_read *a, const void **buff, size_t *outbytes, + const void *b, size_t *used) +{ + struct xar *xar; + void *outbuff; + size_t avail_in, avail_out; + int r; + + xar = (struct xar *)(a->format->data); + avail_in = *used; + outbuff = (void *)(uintptr_t)*buff; + if (outbuff == NULL) { + outbuff = xar->buff; + *buff = outbuff; + avail_out = sizeof(xar->buff); + } else + avail_out = *outbytes; + switch (xar->rd_encoding) { + case GZIP: + xar->stream.next_in = (Bytef *)(uintptr_t)b; + xar->stream.avail_in = avail_in; + xar->stream.next_out = (unsigned char *)outbuff; + xar->stream.avail_out = avail_out; + r = inflate(&(xar->stream), 0); + switch (r) { + case Z_OK: /* Decompressor made some progress.*/ + case Z_STREAM_END: /* Found end of stream. */ + break; + default: + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "File decompression failed (%d)", r); + return (ARCHIVE_FATAL); + } + *used = avail_in - xar->stream.avail_in; + *outbytes = avail_out - xar->stream.avail_out; + break; +#if defined(HAVE_BZLIB_H) && defined(BZ_CONFIG_ERROR) + case BZIP2: + xar->bzstream.next_in = (char *)(uintptr_t)b; + xar->bzstream.avail_in = avail_in; + xar->bzstream.next_out = (char *)outbuff; + xar->bzstream.avail_out = avail_out; + r = BZ2_bzDecompress(&(xar->bzstream)); + switch (r) { + case BZ_STREAM_END: /* Found end of stream. */ + switch (BZ2_bzDecompressEnd(&(xar->bzstream))) { + case BZ_OK: + break; + default: + archive_set_error(&(a->archive), + ARCHIVE_ERRNO_MISC, + "Failed to clean up decompressor"); + return (ARCHIVE_FATAL); + } + xar->bzstream_valid = 0; + /* FALLTHROUGH */ + case BZ_OK: /* Decompressor made some progress. */ + break; + default: + archive_set_error(&(a->archive), + ARCHIVE_ERRNO_MISC, + "bzip decompression failed"); + return (ARCHIVE_FATAL); + } + *used = avail_in - xar->bzstream.avail_in; + *outbytes = avail_out - xar->bzstream.avail_out; + break; +#endif +#if defined(HAVE_LZMA_H) && defined(HAVE_LIBLZMA) + case LZMA: + case XZ: + xar->lzstream.next_in = b; + xar->lzstream.avail_in = avail_in; + xar->lzstream.next_out = (unsigned char *)outbuff; + xar->lzstream.avail_out = avail_out; + r = lzma_code(&(xar->lzstream), LZMA_RUN); + switch (r) { + case LZMA_STREAM_END: /* Found end of stream. */ + lzma_end(&(xar->lzstream)); + xar->lzstream_valid = 0; + /* FALLTHROUGH */ + case LZMA_OK: /* Decompressor made some progress. */ + break; + default: + archive_set_error(&(a->archive), + ARCHIVE_ERRNO_MISC, + "%s decompression failed(%d)", + (xar->entry_encoding == XZ)?"xz":"lzma", + r); + return (ARCHIVE_FATAL); + } + *used = avail_in - xar->lzstream.avail_in; + *outbytes = avail_out - xar->lzstream.avail_out; + break; +#elif defined(HAVE_LZMADEC_H) && defined(HAVE_LIBLZMADEC) + case LZMA: + xar->lzstream.next_in = (unsigned char *)(uintptr_t)b; + xar->lzstream.avail_in = avail_in; + xar->lzstream.next_out = (unsigned char *)outbuff; + xar->lzstream.avail_out = avail_out; + r = lzmadec_decode(&(xar->lzstream), 0); + switch (r) { + case LZMADEC_STREAM_END: /* Found end of stream. */ + switch (lzmadec_end(&(xar->lzstream))) { + case LZMADEC_OK: + break; + default: + archive_set_error(&(a->archive), + ARCHIVE_ERRNO_MISC, + "Failed to clean up lzmadec decompressor"); + return (ARCHIVE_FATAL); + } + xar->lzstream_valid = 0; + /* FALLTHROUGH */ + case LZMADEC_OK: /* Decompressor made some progress. */ + break; + default: + archive_set_error(&(a->archive), + ARCHIVE_ERRNO_MISC, + "lzmadec decompression failed(%d)", + r); + return (ARCHIVE_FATAL); + } + *used = avail_in - xar->lzstream.avail_in; + *outbytes = avail_out - xar->lzstream.avail_out; + break; +#endif +#if !defined(HAVE_BZLIB_H) || !defined(BZ_CONFIG_ERROR) + case BZIP2: +#endif +#if !defined(HAVE_LZMA_H) || !defined(HAVE_LIBLZMA) +#if !defined(HAVE_LZMADEC_H) || !defined(HAVE_LIBLZMADEC) + case LZMA: +#endif + case XZ: +#endif + case NONE: + default: + if (outbuff == xar->buff) { + *buff = b; + *used = avail_in; + *outbytes = avail_in; + } else { + if (avail_out > avail_in) + avail_out = avail_in; + memcpy(outbuff, b, avail_out); + *used = avail_out; + *outbytes = avail_out; + } + break; + } + return (ARCHIVE_OK); +} + +static int +decompression_cleanup(struct archive_read *a) +{ + struct xar *xar; + int r; + + xar = (struct xar *)(a->format->data); + r = ARCHIVE_OK; + if (xar->stream_valid) { + if (inflateEnd(&(xar->stream)) != Z_OK) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_MISC, + "Failed to clean up zlib decompressor"); + r = ARCHIVE_FATAL; + } + } +#if defined(HAVE_BZLIB_H) && defined(BZ_CONFIG_ERROR) + if (xar->bzstream_valid) { + if (BZ2_bzDecompressEnd(&(xar->bzstream)) != BZ_OK) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_MISC, + "Failed to clean up bzip2 decompressor"); + r = ARCHIVE_FATAL; + } + } +#endif +#if defined(HAVE_LZMA_H) && defined(HAVE_LIBLZMA) + if (xar->lzstream_valid) + lzma_end(&(xar->lzstream)); +#elif defined(HAVE_LZMA_H) && defined(HAVE_LIBLZMA) + if (xar->lzstream_valid) { + if (lzmadec_end(&(xar->lzstream)) != LZMADEC_OK) { + archive_set_error(&a->archive, + ARCHIVE_ERRNO_MISC, + "Failed to clean up lzmadec decompressor"); + r = ARCHIVE_FATAL; + } + } +#endif + return (r); +} + +static void +xmlattr_cleanup(struct xmlattr_list *list) +{ + struct xmlattr *attr, *next; + + attr = list->first; + while (attr != NULL) { + next = attr->next; + free(attr->name); + free(attr->value); + free(attr); + attr = next; + } + list->first = NULL; + list->last = &(list->first); +} + +static void +file_new(struct xar *xar, struct xmlattr_list *list) +{ + struct xar_file *file; + struct xmlattr *attr; + + file = calloc(1, sizeof(*file)); + if (file == NULL) + __archive_errx(1, "Out of memory"); + file->parent = xar->file; + file->mode = 0777 | AE_IFREG; + file->atime = time(NULL); + file->mtime = time(NULL); + xar->file = file; + xar->xattr = NULL; + for (attr = list->first; attr != NULL; attr = attr->next) { + if (strcmp(attr->name, "id") == 0) + file->id = atol10(attr->value, strlen(attr->value)); + } + file->nlink = 1; + heap_add_entry(&(xar->file_queue), file); +} + +static void +file_free(struct xar_file *file) +{ + struct xattr *xattr; + + archive_string_free(&(file->pathname)); + archive_string_free(&(file->symlink)); + archive_string_free(&(file->uname)); + archive_string_free(&(file->gname)); + archive_string_free(&(file->hardlink)); + xattr = file->xattr_list; + while (xattr != NULL) { + struct xattr *next; + + next = xattr->next; + xattr_free(xattr); + xattr = next; + } + + free(file); +} + +static void +xattr_new(struct xar *xar, struct xmlattr_list *list) +{ + struct xattr *xattr, **nx; + struct xmlattr *attr; + + xattr = calloc(1, sizeof(*xattr)); + if (xattr == NULL) + __archive_errx(1, "Out of memory"); + xar->xattr = xattr; + for (attr = list->first; attr != NULL; attr = attr->next) { + if (strcmp(attr->name, "id") == 0) + xattr->id = atol10(attr->value, strlen(attr->value)); + } + /* Chain to xattr list. */ + for (nx = &(xar->file->xattr_list); + *nx != NULL; nx = &((*nx)->next)) { + if (xattr->id < (*nx)->id) + break; + } + xattr->next = *nx; + *nx = xattr; +} + +static void +xattr_free(struct xattr *xattr) +{ + archive_string_free(&(xattr->name)); + free(xattr); +} + +static int +getencoding(struct xmlattr_list *list) +{ + struct xmlattr *attr; + enum enctype encoding = NONE; + + for (attr = list->first; attr != NULL; attr = attr->next) { + if (strcmp(attr->name, "style") == 0) { + if (strcmp(attr->value, "application/octet-stream") == 0) + encoding = NONE; + else if (strcmp(attr->value, "application/x-gzip") == 0) + encoding = GZIP; + else if (strcmp(attr->value, "application/x-bzip2") == 0) + encoding = BZIP2; + else if (strcmp(attr->value, "application/x-lzma") == 0) + encoding = LZMA; + else if (strcmp(attr->value, "application/x-xz") == 0) + encoding = XZ; + } + } + return (encoding); +} + +static int +getsumalgorithm(struct xmlattr_list *list) +{ + struct xmlattr *attr; + int alg = CKSUM_NONE; + + for (attr = list->first; attr != NULL; attr = attr->next) { + if (strcmp(attr->name, "style") == 0) { + const char *v = attr->value; + if ((v[0] == 'S' || v[0] == 's') && + (v[1] == 'H' || v[1] == 'h') && + (v[2] == 'A' || v[2] == 'a') && + v[3] == '1' && v[4] == '\0') + alg = CKSUM_SHA1; + if ((v[0] == 'M' || v[0] == 'm') && + (v[1] == 'D' || v[1] == 'd') && + v[2] == '5' && v[3] == '\0') + alg = CKSUM_MD5; + } + } + return (alg); +} + +static void +unknowntag_start(struct xar *xar, const char *name) +{ + struct unknown_tag *tag; + +#if DEBUG + fprintf(stderr, "unknowntag_start:%s\n", name); +#endif + tag = malloc(sizeof(*tag)); + if (tag == NULL) + __archive_errx(1, "Out of memory"); + tag->next = xar->unknowntags; + archive_string_init(&(tag->name)); + archive_strcpy(&(tag->name), name); + if (xar->unknowntags == NULL) { + xar->xmlsts_unknown = xar->xmlsts; + xar->xmlsts = UNKNOWN; + } + xar->unknowntags = tag; +} + +static void +unknowntag_end(struct xar *xar, const char *name) +{ + struct unknown_tag *tag; + +#if DEBUG + fprintf(stderr, "unknowntag_end:%s\n", name); +#endif + tag = xar->unknowntags; + if (tag == NULL || name == NULL) + return; + if (strcmp(tag->name.s, name) == 0) { + xar->unknowntags = tag->next; + archive_string_free(&(tag->name)); + free(tag); + if (xar->unknowntags == NULL) + xar->xmlsts = xar->xmlsts_unknown; + } +} + +static void +xml_start(void *userData, const char *name, struct xmlattr_list *list) +{ + struct archive_read *a; + struct xar *xar; + struct xmlattr *attr; + + a = (struct archive_read *)userData; + xar = (struct xar *)(a->format->data); + +#if DEBUG + fprintf(stderr, "xml_sta:[%s]\n", name); + for (attr = list->first; attr != NULL; attr = attr->next) + fprintf(stderr, " attr:\"%s\"=\"%s\"\n", + attr->name, attr->value); +#endif + xar->base64text = 0; + switch (xar->xmlsts) { + case INIT: + if (strcmp(name, "xar") == 0) + xar->xmlsts = XAR; + else + unknowntag_start(xar, name); + break; + case XAR: + if (strcmp(name, "toc") == 0) + xar->xmlsts = TOC; + else + unknowntag_start(xar, name); + break; + case TOC: + if (strcmp(name, "creation-time") == 0) + xar->xmlsts = TOC_CREATION_TIME; + else if (strcmp(name, "checksum") == 0) + xar->xmlsts = TOC_CHECKSUM; + else if (strcmp(name, "file") == 0) { + file_new(xar, list); + xar->xmlsts = TOC_FILE; + } + else + unknowntag_start(xar, name); + break; + case TOC_CHECKSUM: + if (strcmp(name, "offset") == 0) + xar->xmlsts = TOC_CHECKSUM_OFFSET; + else if (strcmp(name, "size") == 0) + xar->xmlsts = TOC_CHECKSUM_SIZE; + else + unknowntag_start(xar, name); + break; + case TOC_FILE: + if (strcmp(name, "file") == 0) { + file_new(xar, list); + } + else if (strcmp(name, "data") == 0) + xar->xmlsts = FILE_DATA; + else if (strcmp(name, "ea") == 0) { + xattr_new(xar, list); + xar->xmlsts = FILE_EA; + } + else if (strcmp(name, "ctime") == 0) + xar->xmlsts = FILE_CTIME; + else if (strcmp(name, "mtime") == 0) + xar->xmlsts = FILE_MTIME; + else if (strcmp(name, "atime") == 0) + xar->xmlsts = FILE_ATIME; + else if (strcmp(name, "group") == 0) + xar->xmlsts = FILE_GROUP; + else if (strcmp(name, "gid") == 0) + xar->xmlsts = FILE_GID; + else if (strcmp(name, "user") == 0) + xar->xmlsts = FILE_USER; + else if (strcmp(name, "uid") == 0) + xar->xmlsts = FILE_UID; + else if (strcmp(name, "mode") == 0) + xar->xmlsts = FILE_MODE; + else if (strcmp(name, "device") == 0) + xar->xmlsts = FILE_DEVICE; + else if (strcmp(name, "deviceno") == 0) + xar->xmlsts = FILE_DEVICENO; + else if (strcmp(name, "inode") == 0) + xar->xmlsts = FILE_INODE; + else if (strcmp(name, "link") == 0) + xar->xmlsts = FILE_LINK; + else if (strcmp(name, "type") == 0) { + xar->xmlsts = FILE_TYPE; + for (attr = list->first; attr != NULL; + attr = attr->next) { + if (strcmp(attr->name, "link") != 0) + continue; + if (strcmp(attr->value, "original") == 0) { + xar->file->hdnext = xar->hdlink_orgs; + xar->hdlink_orgs = xar->file; + } else { + xar->file->link = atol10(attr->value, + strlen(attr->value)); + if (xar->file->link > 0) + add_link(xar, xar->file); + } + } + } + else if (strcmp(name, "name") == 0) { + xar->xmlsts = FILE_NAME; + for (attr = list->first; attr != NULL; + attr = attr->next) { + if (strcmp(attr->name, "enctype") == 0 && + strcmp(attr->value, "base64") == 0) + xar->base64text = 1; + } + } + else if (strcmp(name, "acl") == 0) + xar->xmlsts = FILE_ACL; + else if (strcmp(name, "flags") == 0) + xar->xmlsts = FILE_FLAGS; + else if (strcmp(name, "ext2") == 0) + xar->xmlsts = FILE_EXT2; + else + unknowntag_start(xar, name); + break; + case FILE_DATA: + if (strcmp(name, "length") == 0) + xar->xmlsts = FILE_DATA_LENGTH; + else if (strcmp(name, "offset") == 0) + xar->xmlsts = FILE_DATA_OFFSET; + else if (strcmp(name, "size") == 0) + xar->xmlsts = FILE_DATA_SIZE; + else if (strcmp(name, "encoding") == 0) { + xar->xmlsts = FILE_DATA_ENCODING; + xar->file->encoding = getencoding(list); + } + else if (strcmp(name, "archived-checksum") == 0) { + xar->xmlsts = FILE_DATA_A_CHECKSUM; + xar->file->a_sum.alg = getsumalgorithm(list); + } + else if (strcmp(name, "extracted-checksum") == 0) { + xar->xmlsts = FILE_DATA_E_CHECKSUM; + xar->file->e_sum.alg = getsumalgorithm(list); + } + else if (strcmp(name, "content") == 0) + xar->xmlsts = FILE_DATA_CONTENT; + else + unknowntag_start(xar, name); + break; + case FILE_DEVICE: + if (strcmp(name, "major") == 0) + xar->xmlsts = FILE_DEVICE_MAJOR; + else if (strcmp(name, "minor") == 0) + xar->xmlsts = FILE_DEVICE_MINOR; + else + unknowntag_start(xar, name); + break; + case FILE_DATA_CONTENT: + unknowntag_start(xar, name); + break; + case FILE_EA: + if (strcmp(name, "length") == 0) + xar->xmlsts = FILE_EA_LENGTH; + else if (strcmp(name, "offset") == 0) + xar->xmlsts = FILE_EA_OFFSET; + else if (strcmp(name, "size") == 0) + xar->xmlsts = FILE_EA_SIZE; + else if (strcmp(name, "encoding") == 0) { + xar->xmlsts = FILE_EA_ENCODING; + xar->xattr->encoding = getencoding(list); + } else if (strcmp(name, "archived-checksum") == 0) + xar->xmlsts = FILE_EA_A_CHECKSUM; + else if (strcmp(name, "extracted-checksum") == 0) + xar->xmlsts = FILE_EA_E_CHECKSUM; + else if (strcmp(name, "name") == 0) + xar->xmlsts = FILE_EA_NAME; + else if (strcmp(name, "fstype") == 0) + xar->xmlsts = FILE_EA_FSTYPE; + else + unknowntag_start(xar, name); + break; + case FILE_ACL: + if (strcmp(name, "appleextended") == 0) + xar->xmlsts = FILE_ACL_APPLEEXTENDED; + if (strcmp(name, "default") == 0) + xar->xmlsts = FILE_ACL_DEFAULT; + else if (strcmp(name, "access") == 0) + xar->xmlsts = FILE_ACL_ACCESS; + else + unknowntag_start(xar, name); + break; + case FILE_FLAGS: + if (!xml_parse_file_flags(xar, name)) + unknowntag_start(xar, name); + break; + case FILE_EXT2: + if (!xml_parse_file_ext2(xar, name)) + unknowntag_start(xar, name); + break; + case TOC_CREATION_TIME: + case TOC_CHECKSUM_OFFSET: + case TOC_CHECKSUM_SIZE: + case FILE_DATA_LENGTH: + case FILE_DATA_OFFSET: + case FILE_DATA_SIZE: + case FILE_DATA_ENCODING: + case FILE_DATA_A_CHECKSUM: + case FILE_DATA_E_CHECKSUM: + case FILE_EA_LENGTH: + case FILE_EA_OFFSET: + case FILE_EA_SIZE: + case FILE_EA_ENCODING: + case FILE_EA_A_CHECKSUM: + case FILE_EA_E_CHECKSUM: + case FILE_EA_NAME: + case FILE_EA_FSTYPE: + case FILE_CTIME: + case FILE_MTIME: + case FILE_ATIME: + case FILE_GROUP: + case FILE_GID: + case FILE_USER: + case FILE_UID: + case FILE_INODE: + case FILE_DEVICE_MAJOR: + case FILE_DEVICE_MINOR: + case FILE_DEVICENO: + case FILE_MODE: + case FILE_TYPE: + case FILE_LINK: + case FILE_NAME: + case FILE_ACL_DEFAULT: + case FILE_ACL_ACCESS: + case FILE_ACL_APPLEEXTENDED: + case FILE_FLAGS_USER_NODUMP: + case FILE_FLAGS_USER_IMMUTABLE: + case FILE_FLAGS_USER_APPEND: + case FILE_FLAGS_USER_OPAQUE: + case FILE_FLAGS_USER_NOUNLINK: + case FILE_FLAGS_SYS_ARCHIVED: + case FILE_FLAGS_SYS_IMMUTABLE: + case FILE_FLAGS_SYS_APPEND: + case FILE_FLAGS_SYS_NOUNLINK: + case FILE_FLAGS_SYS_SNAPSHOT: + case FILE_EXT2_SecureDeletion: + case FILE_EXT2_Undelete: + case FILE_EXT2_Compress: + case FILE_EXT2_Synchronous: + case FILE_EXT2_Immutable: + case FILE_EXT2_AppendOnly: + case FILE_EXT2_NoDump: + case FILE_EXT2_NoAtime: + case FILE_EXT2_CompDirty: + case FILE_EXT2_CompBlock: + case FILE_EXT2_NoCompBlock: + case FILE_EXT2_CompError: + case FILE_EXT2_BTree: + case FILE_EXT2_HashIndexed: + case FILE_EXT2_iMagic: + case FILE_EXT2_Journaled: + case FILE_EXT2_NoTail: + case FILE_EXT2_DirSync: + case FILE_EXT2_TopDir: + case FILE_EXT2_Reserved: + case UNKNOWN: + unknowntag_start(xar, name); + break; + } +} + +static void +xml_end(void *userData, const char *name) +{ + struct archive_read *a; + struct xar *xar; + + a = (struct archive_read *)userData; + xar = (struct xar *)(a->format->data); + +#if DEBUG + fprintf(stderr, "xml_end:[%s]\n", name); +#endif + switch (xar->xmlsts) { + case INIT: + break; + case XAR: + if (strcmp(name, "xar") == 0) + xar->xmlsts = INIT; + break; + case TOC: + if (strcmp(name, "toc") == 0) + xar->xmlsts = XAR; + break; + case TOC_CREATION_TIME: + if (strcmp(name, "creation-time") == 0) + xar->xmlsts = TOC; + break; + case TOC_CHECKSUM: + if (strcmp(name, "checksum") == 0) + xar->xmlsts = TOC; + break; + case TOC_CHECKSUM_OFFSET: + if (strcmp(name, "offset") == 0) + xar->xmlsts = TOC_CHECKSUM; + break; + case TOC_CHECKSUM_SIZE: + if (strcmp(name, "size") == 0) + xar->xmlsts = TOC_CHECKSUM; + break; + case TOC_FILE: + if (strcmp(name, "file") == 0) { + if (xar->file->parent != NULL && + ((xar->file->mode & AE_IFMT) == AE_IFDIR)) + xar->file->parent->subdirs++; + xar->file = xar->file->parent; + if (xar->file == NULL) + xar->xmlsts = TOC; + } + break; + case FILE_DATA: + if (strcmp(name, "data") == 0) + xar->xmlsts = TOC_FILE; + break; + case FILE_DATA_LENGTH: + if (strcmp(name, "length") == 0) + xar->xmlsts = FILE_DATA; + break; + case FILE_DATA_OFFSET: + if (strcmp(name, "offset") == 0) + xar->xmlsts = FILE_DATA; + break; + case FILE_DATA_SIZE: + if (strcmp(name, "size") == 0) + xar->xmlsts = FILE_DATA; + break; + case FILE_DATA_ENCODING: + if (strcmp(name, "encoding") == 0) + xar->xmlsts = FILE_DATA; + break; + case FILE_DATA_A_CHECKSUM: + if (strcmp(name, "archived-checksum") == 0) + xar->xmlsts = FILE_DATA; + break; + case FILE_DATA_E_CHECKSUM: + if (strcmp(name, "extracted-checksum") == 0) + xar->xmlsts = FILE_DATA; + break; + case FILE_DATA_CONTENT: + if (strcmp(name, "content") == 0) + xar->xmlsts = FILE_DATA; + break; + case FILE_EA: + if (strcmp(name, "ea") == 0) { + xar->xmlsts = TOC_FILE; + xar->xattr = NULL; + } + break; + case FILE_EA_LENGTH: + if (strcmp(name, "length") == 0) + xar->xmlsts = FILE_EA; + break; + case FILE_EA_OFFSET: + if (strcmp(name, "offset") == 0) + xar->xmlsts = FILE_EA; + break; + case FILE_EA_SIZE: + if (strcmp(name, "size") == 0) + xar->xmlsts = FILE_EA; + break; + case FILE_EA_ENCODING: + if (strcmp(name, "encoding") == 0) + xar->xmlsts = FILE_EA; + break; + case FILE_EA_A_CHECKSUM: + if (strcmp(name, "archived-checksum") == 0) + xar->xmlsts = FILE_EA; + break; + case FILE_EA_E_CHECKSUM: + if (strcmp(name, "extracted-checksum") == 0) + xar->xmlsts = FILE_EA; + break; + case FILE_EA_NAME: + if (strcmp(name, "name") == 0) + xar->xmlsts = FILE_EA; + break; + case FILE_EA_FSTYPE: + if (strcmp(name, "fstype") == 0) + xar->xmlsts = FILE_EA; + break; + case FILE_CTIME: + if (strcmp(name, "ctime") == 0) + xar->xmlsts = TOC_FILE; + break; + case FILE_MTIME: + if (strcmp(name, "mtime") == 0) + xar->xmlsts = TOC_FILE; + break; + case FILE_ATIME: + if (strcmp(name, "atime") == 0) + xar->xmlsts = TOC_FILE; + break; + case FILE_GROUP: + if (strcmp(name, "group") == 0) + xar->xmlsts = TOC_FILE; + break; + case FILE_GID: + if (strcmp(name, "gid") == 0) + xar->xmlsts = TOC_FILE; + break; + case FILE_USER: + if (strcmp(name, "user") == 0) + xar->xmlsts = TOC_FILE; + break; + case FILE_UID: + if (strcmp(name, "uid") == 0) + xar->xmlsts = TOC_FILE; + break; + case FILE_MODE: + if (strcmp(name, "mode") == 0) + xar->xmlsts = TOC_FILE; + break; + case FILE_DEVICE: + if (strcmp(name, "device") == 0) + xar->xmlsts = TOC_FILE; + break; + case FILE_DEVICE_MAJOR: + if (strcmp(name, "major") == 0) + xar->xmlsts = FILE_DEVICE; + break; + case FILE_DEVICE_MINOR: + if (strcmp(name, "minor") == 0) + xar->xmlsts = FILE_DEVICE; + break; + case FILE_DEVICENO: + if (strcmp(name, "deviceno") == 0) + xar->xmlsts = TOC_FILE; + break; + case FILE_INODE: + if (strcmp(name, "inode") == 0) + xar->xmlsts = TOC_FILE; + break; + case FILE_LINK: + if (strcmp(name, "link") == 0) + xar->xmlsts = TOC_FILE; + break; + case FILE_TYPE: + if (strcmp(name, "type") == 0) + xar->xmlsts = TOC_FILE; + break; + case FILE_NAME: + if (strcmp(name, "name") == 0) + xar->xmlsts = TOC_FILE; + break; + case FILE_ACL: + if (strcmp(name, "acl") == 0) + xar->xmlsts = TOC_FILE; + break; + case FILE_ACL_DEFAULT: + if (strcmp(name, "default") == 0) + xar->xmlsts = FILE_ACL; + break; + case FILE_ACL_ACCESS: + if (strcmp(name, "access") == 0) + xar->xmlsts = FILE_ACL; + break; + case FILE_ACL_APPLEEXTENDED: + if (strcmp(name, "appleextended") == 0) + xar->xmlsts = FILE_ACL; + break; + case FILE_FLAGS: + if (strcmp(name, "flags") == 0) + xar->xmlsts = TOC_FILE; + break; + case FILE_FLAGS_USER_NODUMP: + if (strcmp(name, "UserNoDump") == 0) + xar->xmlsts = FILE_FLAGS; + break; + case FILE_FLAGS_USER_IMMUTABLE: + if (strcmp(name, "UserImmutable") == 0) + xar->xmlsts = FILE_FLAGS; + break; + case FILE_FLAGS_USER_APPEND: + if (strcmp(name, "UserAppend") == 0) + xar->xmlsts = FILE_FLAGS; + break; + case FILE_FLAGS_USER_OPAQUE: + if (strcmp(name, "UserOpaque") == 0) + xar->xmlsts = FILE_FLAGS; + break; + case FILE_FLAGS_USER_NOUNLINK: + if (strcmp(name, "UserNoUnlink") == 0) + xar->xmlsts = FILE_FLAGS; + break; + case FILE_FLAGS_SYS_ARCHIVED: + if (strcmp(name, "SystemArchived") == 0) + xar->xmlsts = FILE_FLAGS; + break; + case FILE_FLAGS_SYS_IMMUTABLE: + if (strcmp(name, "SystemImmutable") == 0) + xar->xmlsts = FILE_FLAGS; + break; + case FILE_FLAGS_SYS_APPEND: + if (strcmp(name, "SystemAppend") == 0) + xar->xmlsts = FILE_FLAGS; + break; + case FILE_FLAGS_SYS_NOUNLINK: + if (strcmp(name, "SystemNoUnlink") == 0) + xar->xmlsts = FILE_FLAGS; + break; + case FILE_FLAGS_SYS_SNAPSHOT: + if (strcmp(name, "SystemSnapshot") == 0) + xar->xmlsts = FILE_FLAGS; + break; + case FILE_EXT2: + if (strcmp(name, "ext2") == 0) + xar->xmlsts = TOC_FILE; + break; + case FILE_EXT2_SecureDeletion: + if (strcmp(name, "SecureDeletion") == 0) + xar->xmlsts = FILE_EXT2; + break; + case FILE_EXT2_Undelete: + if (strcmp(name, "Undelete") == 0) + xar->xmlsts = FILE_EXT2; + break; + case FILE_EXT2_Compress: + if (strcmp(name, "Compress") == 0) + xar->xmlsts = FILE_EXT2; + break; + case FILE_EXT2_Synchronous: + if (strcmp(name, "Synchronous") == 0) + xar->xmlsts = FILE_EXT2; + break; + case FILE_EXT2_Immutable: + if (strcmp(name, "Immutable") == 0) + xar->xmlsts = FILE_EXT2; + break; + case FILE_EXT2_AppendOnly: + if (strcmp(name, "AppendOnly") == 0) + xar->xmlsts = FILE_EXT2; + break; + case FILE_EXT2_NoDump: + if (strcmp(name, "NoDump") == 0) + xar->xmlsts = FILE_EXT2; + break; + case FILE_EXT2_NoAtime: + if (strcmp(name, "NoAtime") == 0) + xar->xmlsts = FILE_EXT2; + break; + case FILE_EXT2_CompDirty: + if (strcmp(name, "CompDirty") == 0) + xar->xmlsts = FILE_EXT2; + break; + case FILE_EXT2_CompBlock: + if (strcmp(name, "CompBlock") == 0) + xar->xmlsts = FILE_EXT2; + break; + case FILE_EXT2_NoCompBlock: + if (strcmp(name, "NoCompBlock") == 0) + xar->xmlsts = FILE_EXT2; + break; + case FILE_EXT2_CompError: + if (strcmp(name, "CompError") == 0) + xar->xmlsts = FILE_EXT2; + break; + case FILE_EXT2_BTree: + if (strcmp(name, "BTree") == 0) + xar->xmlsts = FILE_EXT2; + break; + case FILE_EXT2_HashIndexed: + if (strcmp(name, "HashIndexed") == 0) + xar->xmlsts = FILE_EXT2; + break; + case FILE_EXT2_iMagic: + if (strcmp(name, "iMagic") == 0) + xar->xmlsts = FILE_EXT2; + break; + case FILE_EXT2_Journaled: + if (strcmp(name, "Journaled") == 0) + xar->xmlsts = FILE_EXT2; + break; + case FILE_EXT2_NoTail: + if (strcmp(name, "NoTail") == 0) + xar->xmlsts = FILE_EXT2; + break; + case FILE_EXT2_DirSync: + if (strcmp(name, "DirSync") == 0) + xar->xmlsts = FILE_EXT2; + break; + case FILE_EXT2_TopDir: + if (strcmp(name, "TopDir") == 0) + xar->xmlsts = FILE_EXT2; + break; + case FILE_EXT2_Reserved: + if (strcmp(name, "Reserved") == 0) + xar->xmlsts = FILE_EXT2; + break; + case UNKNOWN: + unknowntag_end(xar, name); + break; + } +} + +static const int base64[256] = { + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, /* 00 - 0F */ + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, /* 10 - 1F */ + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 62, -1, -1, -1, 63, /* 20 - 2F */ + 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, -1, -1, -1, -1, -1, -1, /* 30 - 3F */ + -1, 0, 1, 2, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, /* 40 - 4F */ + 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, -1, -1, -1, -1, -1, /* 50 - 5F */ + -1, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, 40, /* 60 - 6F */ + 41, 42, 43, 44, 45, 46, 47, 48, + 49, 50, 51, -1, -1, -1, -1, -1, /* 70 - 7F */ + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, /* 80 - 8F */ + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, /* 90 - 9F */ + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, /* A0 - AF */ + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, /* B0 - BF */ + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, /* C0 - CF */ + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, /* D0 - DF */ + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, /* E0 - EF */ + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, /* F0 - FF */ +}; + +static void +strappend_base64(struct archive_string *as, const char *s, size_t l) +{ + unsigned char buff[256]; + unsigned char *out; + const unsigned char *b; + size_t len; + + len = 0; + out = buff; + b = (const unsigned char *)s; + while (l > 0) { + int n = 0; + + if (l > 0) { + if (base64[b[0]] < 0 || base64[b[1]] < 0) + break; + n = base64[*b++] << 18; + n |= base64[*b++] << 12; + *out++ = n >> 16; + len++; + l -= 2; + } + if (l > 0) { + if (base64[*b] < 0) + break; + n |= base64[*b++] << 6; + *out++ = (n >> 8) & 0xFF; + len++; + --l; + } + if (l > 0) { + if (base64[*b] < 0) + break; + n |= base64[*b++]; + *out++ = n & 0xFF; + len++; + --l; + } + if (len+3 >= sizeof(buff)) { + archive_strncat(as, (const char *)buff, len); + len = 0; + out = buff; + } + } + if (len > 0) + archive_strncat(as, (const char *)buff, len); +} + +static void +xml_data(void *userData, const char *s, int len) +{ + struct archive_read *a; + struct xar *xar; + + a = (struct archive_read *)userData; + xar = (struct xar *)(a->format->data); + +#if DEBUG + { + char buff[1024]; + if (len > (int)sizeof(buff)-1) + len = (int)sizeof(buff)-1; + memcpy(buff, s, len); + buff[len] = 0; + fprintf(stderr, "\tlen=%d:\"%s\"\n", len, buff); + } +#endif + switch (xar->xmlsts) { + case TOC_CHECKSUM_OFFSET: + xar->toc_chksum_offset = atol10(s, len); + break; + case TOC_CHECKSUM_SIZE: + xar->toc_chksum_size = atol10(s, len); + break; + default: + break; + } + if (xar->file == NULL) + return; + + switch (xar->xmlsts) { + case FILE_NAME: + if (xar->file->parent != NULL) { + archive_string_concat(&(xar->file->pathname), + &(xar->file->parent->pathname)); + archive_strappend_char(&(xar->file->pathname), '/'); + } + xar->file->has |= HAS_PATHNAME; + if (xar->base64text) + strappend_base64(&(xar->file->pathname), s, len); + else + archive_strncat(&(xar->file->pathname), s, len); + break; + case FILE_LINK: + xar->file->has |= HAS_SYMLINK; + archive_strncpy(&(xar->file->symlink), s, len); + break; + case FILE_TYPE: + if (strncmp("file", s, len) == 0 || + strncmp("hardlink", s, len) == 0) + xar->file->mode = + (xar->file->mode & ~AE_IFMT) | AE_IFREG; + if (strncmp("directory", s, len) == 0) + xar->file->mode = + (xar->file->mode & ~AE_IFMT) | AE_IFDIR; + if (strncmp("symlink", s, len) == 0) + xar->file->mode = + (xar->file->mode & ~AE_IFMT) | AE_IFLNK; + if (strncmp("character special", s, len) == 0) + xar->file->mode = + (xar->file->mode & ~AE_IFMT) | AE_IFCHR; + if (strncmp("block special", s, len) == 0) + xar->file->mode = + (xar->file->mode & ~AE_IFMT) | AE_IFBLK; + if (strncmp("socket", s, len) == 0) + xar->file->mode = + (xar->file->mode & ~AE_IFMT) | AE_IFSOCK; + if (strncmp("fifo", s, len) == 0) + xar->file->mode = + (xar->file->mode & ~AE_IFMT) | AE_IFIFO; + xar->file->has |= HAS_TYPE; + break; + case FILE_INODE: + xar->file->has |= HAS_INO; + xar->file->ino64 = atol10(s, len); + break; + case FILE_DEVICE_MAJOR: + xar->file->has |= HAS_DEVMAJOR; + xar->file->devmajor = (dev_t)atol10(s, len); + break; + case FILE_DEVICE_MINOR: + xar->file->has |= HAS_DEVMINOR; + xar->file->devminor = (dev_t)atol10(s, len); + break; + case FILE_DEVICENO: + xar->file->has |= HAS_DEV; + xar->file->dev = (dev_t)atol10(s, len); + break; + case FILE_MODE: + xar->file->has |= HAS_MODE; + xar->file->mode = + (xar->file->mode & AE_IFMT) | + (atol8(s, len) & ~AE_IFMT); + break; + case FILE_GROUP: + xar->file->has |= HAS_GID; + archive_strncpy(&(xar->file->gname), s, len); + break; + case FILE_GID: + xar->file->has |= HAS_GID; + xar->file->gid = atol10(s, len); + break; + case FILE_USER: + xar->file->has |= HAS_UID; + archive_strncpy(&(xar->file->uname), s, len); + break; + case FILE_UID: + xar->file->has |= HAS_UID; + xar->file->uid = atol10(s, len); + break; + case FILE_CTIME: + xar->file->has |= HAS_TIME; + xar->file->ctime = parse_time(s, len); + break; + case FILE_MTIME: + xar->file->has |= HAS_TIME; + xar->file->mtime = parse_time(s, len); + break; + case FILE_ATIME: + xar->file->has |= HAS_TIME; + xar->file->atime = parse_time(s, len); + break; + case FILE_DATA_LENGTH: + xar->file->has |= HAS_DATA; + xar->file->length = atol10(s, len); + break; + case FILE_DATA_OFFSET: + xar->file->has |= HAS_DATA; + xar->file->offset = atol10(s, len); + break; + case FILE_DATA_SIZE: + xar->file->has |= HAS_DATA; + xar->file->size = atol10(s, len); + break; + case FILE_DATA_A_CHECKSUM: + xar->file->a_sum.len = atohex(xar->file->a_sum.val, + sizeof(xar->file->a_sum.val), s, len); + break; + case FILE_DATA_E_CHECKSUM: + xar->file->e_sum.len = atohex(xar->file->e_sum.val, + sizeof(xar->file->e_sum.val), s, len); + break; + case FILE_EA_LENGTH: + xar->file->has |= HAS_XATTR; + xar->xattr->length = atol10(s, len); + break; + case FILE_EA_OFFSET: + xar->file->has |= HAS_XATTR; + xar->xattr->offset = atol10(s, len); + break; + case FILE_EA_SIZE: + xar->file->has |= HAS_XATTR; + xar->xattr->size = atol10(s, len); + break; + case FILE_EA_A_CHECKSUM: + xar->file->has |= HAS_XATTR; + xar->xattr->a_sum.len = atohex(xar->xattr->a_sum.val, + sizeof(xar->xattr->a_sum.val), s, len); + break; + case FILE_EA_E_CHECKSUM: + xar->file->has |= HAS_XATTR; + xar->xattr->e_sum.len = atohex(xar->xattr->e_sum.val, + sizeof(xar->xattr->e_sum.val), s, len); + break; + case FILE_EA_NAME: + xar->file->has |= HAS_XATTR; + archive_strncpy(&(xar->xattr->name), s, len); + break; + case FILE_EA_FSTYPE: + xar->file->has |= HAS_XATTR; + archive_strncpy(&(xar->xattr->fstype), s, len); + break; + break; + case FILE_ACL_DEFAULT: + case FILE_ACL_ACCESS: + case FILE_ACL_APPLEEXTENDED: + xar->file->has |= HAS_ACL; + /* TODO */ + break; + case INIT: + case XAR: + case TOC: + case TOC_CREATION_TIME: + case TOC_CHECKSUM: + case TOC_CHECKSUM_OFFSET: + case TOC_CHECKSUM_SIZE: + case TOC_FILE: + case FILE_DATA: + case FILE_DATA_ENCODING: + case FILE_DATA_CONTENT: + case FILE_DEVICE: + case FILE_EA: + case FILE_EA_ENCODING: + case FILE_ACL: + case FILE_FLAGS: + case FILE_FLAGS_USER_NODUMP: + case FILE_FLAGS_USER_IMMUTABLE: + case FILE_FLAGS_USER_APPEND: + case FILE_FLAGS_USER_OPAQUE: + case FILE_FLAGS_USER_NOUNLINK: + case FILE_FLAGS_SYS_ARCHIVED: + case FILE_FLAGS_SYS_IMMUTABLE: + case FILE_FLAGS_SYS_APPEND: + case FILE_FLAGS_SYS_NOUNLINK: + case FILE_FLAGS_SYS_SNAPSHOT: + case FILE_EXT2: + case FILE_EXT2_SecureDeletion: + case FILE_EXT2_Undelete: + case FILE_EXT2_Compress: + case FILE_EXT2_Synchronous: + case FILE_EXT2_Immutable: + case FILE_EXT2_AppendOnly: + case FILE_EXT2_NoDump: + case FILE_EXT2_NoAtime: + case FILE_EXT2_CompDirty: + case FILE_EXT2_CompBlock: + case FILE_EXT2_NoCompBlock: + case FILE_EXT2_CompError: + case FILE_EXT2_BTree: + case FILE_EXT2_HashIndexed: + case FILE_EXT2_iMagic: + case FILE_EXT2_Journaled: + case FILE_EXT2_NoTail: + case FILE_EXT2_DirSync: + case FILE_EXT2_TopDir: + case FILE_EXT2_Reserved: + case UNKNOWN: + break; + } +} + +/* + * BSD file flags. + */ +static int +xml_parse_file_flags(struct xar *xar, const char *name) +{ + const char *flag = NULL; + + if (strcmp(name, "UserNoDump") == 0) { + xar->xmlsts = FILE_FLAGS_USER_NODUMP; + flag = "nodump"; + } + else if (strcmp(name, "UserImmutable") == 0) { + xar->xmlsts = FILE_FLAGS_USER_IMMUTABLE; + flag = "uimmutable"; + } + else if (strcmp(name, "UserAppend") == 0) { + xar->xmlsts = FILE_FLAGS_USER_APPEND; + flag = "uappend"; + } + else if (strcmp(name, "UserOpaque") == 0) { + xar->xmlsts = FILE_FLAGS_USER_OPAQUE; + flag = "opaque"; + } + else if (strcmp(name, "UserNoUnlink") == 0) { + xar->xmlsts = FILE_FLAGS_USER_NOUNLINK; + flag = "nouunlink"; + } + else if (strcmp(name, "SystemArchived") == 0) { + xar->xmlsts = FILE_FLAGS_SYS_ARCHIVED; + flag = "archived"; + } + else if (strcmp(name, "SystemImmutable") == 0) { + xar->xmlsts = FILE_FLAGS_SYS_IMMUTABLE; + flag = "simmutable"; + } + else if (strcmp(name, "SystemAppend") == 0) { + xar->xmlsts = FILE_FLAGS_SYS_APPEND; + flag = "sappend"; + } + else if (strcmp(name, "SystemNoUnlink") == 0) { + xar->xmlsts = FILE_FLAGS_SYS_NOUNLINK; + flag = "nosunlink"; + } + else if (strcmp(name, "SystemSnapshot") == 0) { + xar->xmlsts = FILE_FLAGS_SYS_SNAPSHOT; + flag = "snapshot"; + } + + if (flag == NULL) + return (0); + xar->file->has |= HAS_FFLAGS; + if (archive_strlen(&(xar->file->fflags_text)) > 0) + archive_strappend_char(&(xar->file->fflags_text), ','); + archive_strcat(&(xar->file->fflags_text), flag); + return (1); +} + +/* + * Linux file flags. + */ +static int +xml_parse_file_ext2(struct xar *xar, const char *name) +{ + const char *flag = NULL; + + if (strcmp(name, "SecureDeletion") == 0) { + xar->xmlsts = FILE_EXT2_SecureDeletion; + flag = "securedeletion"; + } + else if (strcmp(name, "Undelete") == 0) { + xar->xmlsts = FILE_EXT2_Undelete; + flag = "nouunlink"; + } + else if (strcmp(name, "Compress") == 0) { + xar->xmlsts = FILE_EXT2_Compress; + flag = "compress"; + } + else if (strcmp(name, "Synchronous") == 0) { + xar->xmlsts = FILE_EXT2_Synchronous; + flag = "sync"; + } + else if (strcmp(name, "Immutable") == 0) { + xar->xmlsts = FILE_EXT2_Immutable; + flag = "simmutable"; + } + else if (strcmp(name, "AppendOnly") == 0) { + xar->xmlsts = FILE_EXT2_AppendOnly; + flag = "sappend"; + } + else if (strcmp(name, "NoDump") == 0) { + xar->xmlsts = FILE_EXT2_NoDump; + flag = "nodump"; + } + else if (strcmp(name, "NoAtime") == 0) { + xar->xmlsts = FILE_EXT2_NoAtime; + flag = "noatime"; + } + else if (strcmp(name, "CompDirty") == 0) { + xar->xmlsts = FILE_EXT2_CompDirty; + flag = "compdirty"; + } + else if (strcmp(name, "CompBlock") == 0) { + xar->xmlsts = FILE_EXT2_CompBlock; + flag = "comprblk"; + } + else if (strcmp(name, "NoCompBlock") == 0) { + xar->xmlsts = FILE_EXT2_NoCompBlock; + flag = "nocomprblk"; + } + else if (strcmp(name, "CompError") == 0) { + xar->xmlsts = FILE_EXT2_CompError; + flag = "comperr"; + } + else if (strcmp(name, "BTree") == 0) { + xar->xmlsts = FILE_EXT2_BTree; + flag = "btree"; + } + else if (strcmp(name, "HashIndexed") == 0) { + xar->xmlsts = FILE_EXT2_HashIndexed; + flag = "hashidx"; + } + else if (strcmp(name, "iMagic") == 0) { + xar->xmlsts = FILE_EXT2_iMagic; + flag = "imagic"; + } + else if (strcmp(name, "Journaled") == 0) { + xar->xmlsts = FILE_EXT2_Journaled; + flag = "journal"; + } + else if (strcmp(name, "NoTail") == 0) { + xar->xmlsts = FILE_EXT2_NoTail; + flag = "notail"; + } + else if (strcmp(name, "DirSync") == 0) { + xar->xmlsts = FILE_EXT2_DirSync; + flag = "dirsync"; + } + else if (strcmp(name, "TopDir") == 0) { + xar->xmlsts = FILE_EXT2_TopDir; + flag = "topdir"; + } + else if (strcmp(name, "Reserved") == 0) { + xar->xmlsts = FILE_EXT2_Reserved; + flag = "reserved"; + } + + if (flag == NULL) + return (0); + if (archive_strlen(&(xar->file->fflags_text)) > 0) + archive_strappend_char(&(xar->file->fflags_text), ','); + archive_strcat(&(xar->file->fflags_text), flag); + return (1); +} + +#ifdef HAVE_LIBXML_XMLREADER_H + +static int +xml2_xmlattr_setup(struct xmlattr_list *list, xmlTextReaderPtr reader) +{ + struct xmlattr *attr; + int r; + + list->first = NULL; + list->last = &(list->first); + r = xmlTextReaderMoveToFirstAttribute(reader); + while (r == 1) { + attr = malloc(sizeof*(attr)); + if (attr == NULL) + __archive_errx(1, "Out of memory"); + attr->name = strdup( + (const char *)xmlTextReaderConstLocalName(reader)); + if (attr->name == NULL) + __archive_errx(1, "Out of memory"); + attr->value = strdup( + (const char *)xmlTextReaderConstValue(reader)); + if (attr->value == NULL) + __archive_errx(1, "Out of memory"); + attr->next = NULL; + *list->last = attr; + list->last = &(attr->next); + r = xmlTextReaderMoveToNextAttribute(reader); + } + return (r); +} + +static int +xml2_read_cb(void *context, char *buffer, int len) +{ + struct archive_read *a; + struct xar *xar; + const void *d; + size_t outbytes; + size_t used; + int r; + + a = (struct archive_read *)context; + xar = (struct xar *)(a->format->data); + + if (xar->toc_remaining <= 0) + return (0); + d = buffer; + outbytes = len; + r = rd_contents(a, &d, &outbytes, &used, xar->toc_remaining); + if (r != ARCHIVE_OK) + return (r); + __archive_read_consume(a, used); + xar->toc_remaining -= used; + xar->offset += used; + xar->toc_total += outbytes; + PRINT_TOC(buffer, len); + + return ((int)outbytes); +} + +static int +xml2_close_cb(void *context) +{ + + (void)context; /* UNUSED */ + return (0); +} + +static void +xml2_error_hdr(void *arg, const char *msg, xmlParserSeverities severity, + xmlTextReaderLocatorPtr locator) +{ + struct archive_read *a; + + (void)locator; /* UNUSED */ + a = (struct archive_read *)arg; + switch (severity) { + case XML_PARSER_SEVERITY_VALIDITY_WARNING: + case XML_PARSER_SEVERITY_WARNING: + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "XML Parsing error: %s", msg); + break; + case XML_PARSER_SEVERITY_VALIDITY_ERROR: + case XML_PARSER_SEVERITY_ERROR: + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "XML Parsing error: %s", msg); + break; + } +} + +static int +xml2_read_toc(struct archive_read *a) +{ + xmlTextReaderPtr reader; + struct xmlattr_list list; + int r; + + reader = xmlReaderForIO(xml2_read_cb, xml2_close_cb, a, NULL, NULL, 0); + if (reader == NULL) { + archive_set_error(&a->archive, ENOMEM, + "Couldn't allocate memory for xml parser"); + return (ARCHIVE_FATAL); + } + xmlTextReaderSetErrorHandler(reader, xml2_error_hdr, a); + + while ((r = xmlTextReaderRead(reader)) == 1) { + const char *name, *value; + int type, empty; + + type = xmlTextReaderNodeType(reader); + name = (const char *)xmlTextReaderConstLocalName(reader); + switch (type) { + case XML_READER_TYPE_ELEMENT: + empty = xmlTextReaderIsEmptyElement(reader); + r = xml2_xmlattr_setup(&list, reader); + if (r == 0) { + xml_start(a, name, &list); + xmlattr_cleanup(&list); + if (empty) + xml_end(a, name); + } + break; + case XML_READER_TYPE_END_ELEMENT: + xml_end(a, name); + break; + case XML_READER_TYPE_TEXT: + value = (const char *)xmlTextReaderConstValue(reader); + xml_data(a, value, strlen(value)); + break; + case XML_READER_TYPE_SIGNIFICANT_WHITESPACE: + default: + break; + } + if (r < 0) + break; + } + xmlFreeTextReader(reader); + xmlCleanupParser(); + + return ((r == 0)?ARCHIVE_OK:ARCHIVE_FATAL); +} + +#elif defined(HAVE_BSDXML_H) || defined(HAVE_EXPAT_H) + +static void +expat_xmlattr_setup(struct xmlattr_list *list, const XML_Char **atts) +{ + struct xmlattr *attr; + + list->first = NULL; + list->last = &(list->first); + if (atts == NULL) + return; + while (atts[0] != NULL && atts[1] != NULL) { + attr = malloc(sizeof*(attr)); + if (attr == NULL) + __archive_errx(1, "Out of memory"); + attr->name = strdup(atts[0]); + if (attr->name == NULL) + __archive_errx(1, "Out of memory"); + attr->value = strdup(atts[1]); + if (attr->value == NULL) + __archive_errx(1, "Out of memory"); + attr->next = NULL; + *list->last = attr; + list->last = &(attr->next); + atts += 2; + } +} + +static void +expat_start_cb(void *userData, const XML_Char *name, const XML_Char **atts) +{ + struct xmlattr_list list; + + expat_xmlattr_setup(&list, atts); + xml_start(userData, (const char *)name, &list); + xmlattr_cleanup(&list); +} + +static void +expat_end_cb(void *userData, const XML_Char *name) +{ + xml_end(userData, (const char *)name); +} + +static void +expat_data_cb(void *userData, const XML_Char *s, int len) +{ + xml_data(userData, s, len); +} + +static int +expat_read_toc(struct archive_read *a) +{ + struct xar *xar; + XML_Parser parser; + + xar = (struct xar *)(a->format->data); + + /* Initialize XML Parser library. */ + parser = XML_ParserCreate(NULL); + if (parser == NULL) { + archive_set_error(&a->archive, ENOMEM, + "Couldn't allocate memory for xml parser"); + return (ARCHIVE_FATAL); + } + XML_SetUserData(parser, a); + XML_SetElementHandler(parser, expat_start_cb, expat_end_cb); + XML_SetCharacterDataHandler(parser, expat_data_cb); + xar->xmlsts = INIT; + + while (xar->toc_remaining) { + enum XML_Status xr; + const void *d; + size_t outbytes; + size_t used; + int r; + + d = NULL; + r = rd_contents(a, &d, &outbytes, &used, xar->toc_remaining); + if (r != ARCHIVE_OK) + return (r); + __archive_read_consume(a, used); + xar->toc_remaining -= used; + xar->offset += used; + xar->toc_total += outbytes; + PRINT_TOC(d, outbytes); + + xr = XML_Parse(parser, d, outbytes, xar->toc_remaining == 0); + if (xr == XML_STATUS_ERROR) { + XML_ParserFree(parser); + archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, + "XML Parsing failed"); + return (ARCHIVE_FATAL); + } + } + XML_ParserFree(parser); + return (ARCHIVE_OK); +} +#endif /* defined(HAVE_BSDXML_H) || defined(HAVE_EXPAT_H) */ + +#endif /* Support xar format */ diff --git a/lib/libarchive/archive_write_disk.c b/lib/libarchive/archive_write_disk.c index f0ca525..8a4fd04 100644 --- a/lib/libarchive/archive_write_disk.c +++ b/lib/libarchive/archive_write_disk.c @@ -2477,7 +2477,7 @@ set_xattrs(struct archive_write_disk *a) } return (ret); } -#elif HAVE_EXTATTR_SET_FILE +#elif HAVE_EXTATTR_SET_FILE && HAVE_DECL_EXTATTR_NAMESPACE_USER /* * Restore extended attributes - FreeBSD implementation */ diff --git a/lib/libarchive/archive_write_disk_set_standard_lookup.c b/lib/libarchive/archive_write_disk_set_standard_lookup.c index 1842cbd..ae9c12a 100644 --- a/lib/libarchive/archive_write_disk_set_standard_lookup.c +++ b/lib/libarchive/archive_write_disk_set_standard_lookup.c @@ -117,6 +117,7 @@ lookup_gid(void *private_data, const char *gname, gid_t gid) /* Note: If strdup fails, that's okay; we just won't cache. */ b->hash = h; #if HAVE_GRP_H +# if HAVE_GETGRNAM_R { char _buffer[128]; size_t bufsize = 128; @@ -143,6 +144,15 @@ lookup_gid(void *private_data, const char *gname, gid_t gid) if (buffer != _buffer) free(buffer); } +# else /* HAVE_GETGRNAM_R */ + { + struct group *result; + + result = getgrnam(gname); + if (result != NULL) + gid = result->gr_gid; + } +# endif /* HAVE_GETGRNAM_R */ #elif defined(_WIN32) && !defined(__CYGWIN__) /* TODO: do a gname->gid lookup for Windows. */ #else @@ -177,6 +187,7 @@ lookup_uid(void *private_data, const char *uname, uid_t uid) /* Note: If strdup fails, that's okay; we just won't cache. */ b->hash = h; #if HAVE_PWD_H +# if HAVE_GETPWNAM_R { char _buffer[128]; size_t bufsize = 128; @@ -203,6 +214,15 @@ lookup_uid(void *private_data, const char *uname, uid_t uid) if (buffer != _buffer) free(buffer); } +# else /* HAVE_GETPWNAM_R */ + { + struct passwd *result; + + result = getpwnam(uname); + if (result != NULL) + uid = result->pw_uid; + } +#endif /* HAVE_GETPWNAM_R */ #elif defined(_WIN32) && !defined(__CYGWIN__) /* TODO: do a uname->uid lookup for Windows. */ #else diff --git a/lib/libarchive/archive_write_set_compression_bzip2.c b/lib/libarchive/archive_write_set_compression_bzip2.c index c8b502e..a3ed307 100644 --- a/lib/libarchive/archive_write_set_compression_bzip2.c +++ b/lib/libarchive/archive_write_set_compression_bzip2.c @@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$"); #include "archive_private.h" #include "archive_write_private.h" -#ifndef HAVE_BZLIB_H +#if !defined(HAVE_BZLIB_H) || !defined(BZ_CONFIG_ERROR) int archive_write_set_compression_bzip2(struct archive *a) { @@ -405,4 +405,4 @@ drive_compressor(struct archive_write *a, struct private_data *state, int finish } } -#endif /* HAVE_BZLIB_H */ +#endif /* HAVE_BZLIB_H && BZ_CONFIG_ERROR */ diff --git a/lib/libarchive/config_freebsd.h b/lib/libarchive/config_freebsd.h index 20d5b93..d1cb462 100644 --- a/lib/libarchive/config_freebsd.h +++ b/lib/libarchive/config_freebsd.h @@ -70,6 +70,7 @@ #define HAVE_BSDXML_H 1 #define HAVE_CHFLAGS 1 #define HAVE_CHOWN 1 +#define HAVE_DECL_EXTATTR_NAMESPACE_USER 1 #define HAVE_DECL_INT64_MAX 1 #define HAVE_DECL_INT64_MIN 1 #define HAVE_DECL_SIZE_MAX 1 @@ -92,7 +93,9 @@ #define HAVE_FTRUNCATE 1 #define HAVE_FUTIMES 1 #define HAVE_GETEUID 1 +#define HAVE_GETGRGID_R 1 #define HAVE_GETPID 1 +#define HAVE_GETPWUID_R 1 #define HAVE_GRP_H 1 #define HAVE_INTTYPES_H 1 #define HAVE_LCHFLAGS 1 @@ -149,6 +152,7 @@ #define HAVE_UTIME_H 1 #define HAVE_VFORK 1 #define HAVE_WCHAR_H 1 +#define HAVE_WCSCMP 1 #define HAVE_WCSCPY 1 #define HAVE_WCSLEN 1 #define HAVE_WCTOMB 1 @@ -162,3 +166,18 @@ #define intmax_t int64_t #define uintmax_t uint64_t #endif + +/* FreeBSD defines for archive_hash.h */ +#ifdef WITH_OPENSSL +#define ARCHIVE_HASH_MD5_OPENSSL 1 +#define ARCHIVE_HASH_RMD160_OPENSSL 1 +#define ARCHIVE_HASH_SHA1_OPENSSL +#define ARCHIVE_HASH_SHA256_OPENSSL 1 +#define ARCHIVE_HASH_SHA384_OPENSSL 1 +#define ARCHIVE_HASH_SHA512_OPENSSL 1 +#else +#define ARCHIVE_HASH_MD5_LIBC 1 +#define ARCHIVE_HASH_SHA1_LIBC 1 +#define ARCHIVE_HASH_SHA256_LIBC 1 +#define ARCHIVE_HASH_SHA512_LIBC 1 +#endif diff --git a/lib/libarchive/filter_fork.c b/lib/libarchive/filter_fork.c index a4d1a98..d2a1e88 100644 --- a/lib/libarchive/filter_fork.c +++ b/lib/libarchive/filter_fork.c @@ -31,7 +31,7 @@ __FBSDID("$FreeBSD$"); -#if defined(HAVE_POLL) +#if defined(HAVE_POLL) && (defined(HAVE_POLL_H) || defined(HAVE_SYS_POLL_H)) # if defined(HAVE_POLL_H) # include <poll.h> # elif defined(HAVE_SYS_POLL_H) @@ -121,7 +121,7 @@ state_allocated: void __archive_check_child(int in, int out) { -#if defined(HAVE_POLL) +#if defined(HAVE_POLL) && (defined(HAVE_POLL_H) || defined(HAVE_SYS_POLL_H)) struct pollfd fds[2]; int idx; diff --git a/lib/libarchive/libarchive_fe/err.c b/lib/libarchive/libarchive_fe/err.c new file mode 100644 index 0000000..eb3f9f3 --- /dev/null +++ b/lib/libarchive/libarchive_fe/err.c @@ -0,0 +1,74 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "lafe_platform.h" +__FBSDID("$FreeBSD$"); + +#ifdef HAVE_STDARG_H +#include <stdarg.h> +#endif +#include <stdio.h> +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif + +#include "err.h" + +const char *lafe_progname; + +static void +lafe_vwarnc(int code, const char *fmt, va_list ap) +{ + fprintf(stderr, "%s: ", lafe_progname); + vfprintf(stderr, fmt, ap); + if (code != 0) + fprintf(stderr, ": %s", strerror(code)); + fprintf(stderr, "\n"); +} + +void +lafe_warnc(int code, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + lafe_vwarnc(code, fmt, ap); + va_end(ap); +} + +void +lafe_errc(int eval, int code, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + lafe_vwarnc(code, fmt, ap); + va_end(ap); + exit(eval); +} diff --git a/lib/libarchive/libarchive_fe/err.h b/lib/libarchive/libarchive_fe/err.h new file mode 100644 index 0000000..4812b28 --- /dev/null +++ b/lib/libarchive/libarchive_fe/err.h @@ -0,0 +1,43 @@ +/*- + * Copyright (c) 2009 Joerg Sonnenberger + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (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$ + */ + +#ifndef LAFE_ERR_H +#define LAFE_ERR_H + +#if defined(__GNUC__) && (__GNUC__ > 2 || \ + (__GNUC__ == 2 && __GNUC_MINOR__ >= 5)) +#define __LA_DEAD __attribute__((__noreturn__)) +#else +#define __LA_DEAD +#endif + +extern const char *lafe_progname; + +void lafe_warnc(int code, const char *fmt, ...); +void lafe_errc(int eval, int code, const char *fmt, ...) __LA_DEAD; + +#endif diff --git a/lib/libarchive/libarchive_fe/lafe_platform.h b/lib/libarchive/libarchive_fe/lafe_platform.h new file mode 100644 index 0000000..38e100d --- /dev/null +++ b/lib/libarchive/libarchive_fe/lafe_platform.h @@ -0,0 +1,55 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (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$ + */ + +/* + * This header is the first thing included in any of the libarchive_fe + * source files. As far as possible, platform-specific issues should + * be dealt with here and not within individual source files. + */ + +#ifndef LAFE_PLATFORM_H_INCLUDED +#define LAFE_PLATFORM_H_INCLUDED + +#if defined(PLATFORM_CONFIG_H) +/* Use hand-built config.h in environments that need it. */ +#include PLATFORM_CONFIG_H +#else +/* Read config.h or die trying. */ +#include "config.h" +#endif + +/* Get a real definition for __FBSDID if we can */ +#if HAVE_SYS_CDEFS_H +#include <sys/cdefs.h> +#endif + +/* If not, define it so as to avoid dangling semicolons. */ +#ifndef __FBSDID +#define __FBSDID(a) struct _undefined_hack +#endif + +#endif diff --git a/lib/libarchive/libarchive_fe/line_reader.c b/lib/libarchive/libarchive_fe/line_reader.c new file mode 100644 index 0000000..4af60de --- /dev/null +++ b/lib/libarchive/libarchive_fe/line_reader.c @@ -0,0 +1,171 @@ +/*- + * Copyright (c) 2008 Tim Kientzle + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "lafe_platform.h" +__FBSDID("$FreeBSD$"); + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include "err.h" +#include "line_reader.h" + +#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) +#define strdup _strdup +#endif + +/* + * Read lines from file and do something with each one. If option_null + * is set, lines are terminated with zero bytes; otherwise, they're + * terminated with newlines. + * + * This uses a self-sizing buffer to handle arbitrarily-long lines. + */ +struct lafe_line_reader { + FILE *f; + char *buff, *buff_end, *line_start, *line_end, *p; + char *pathname; + size_t buff_length; + int nullSeparator; /* Lines separated by null, not CR/CRLF/etc. */ + int ret; +}; + +struct lafe_line_reader * +lafe_line_reader(const char *pathname, int nullSeparator) +{ + struct lafe_line_reader *lr; + + lr = calloc(1, sizeof(*lr)); + if (lr == NULL) + lafe_errc(1, ENOMEM, "Can't open %s", pathname); + + lr->nullSeparator = nullSeparator; + lr->pathname = strdup(pathname); + + if (strcmp(pathname, "-") == 0) + lr->f = stdin; + else + lr->f = fopen(pathname, "r"); + if (lr->f == NULL) + lafe_errc(1, errno, "Couldn't open %s", pathname); + lr->buff_length = 8192; + lr->buff = malloc(lr->buff_length); + if (lr->buff == NULL) + lafe_errc(1, ENOMEM, "Can't read %s", pathname); + lr->line_start = lr->line_end = lr->buff_end = lr->buff; + + return (lr); +} + +const char * +lafe_line_reader_next(struct lafe_line_reader *lr) +{ + size_t bytes_wanted, bytes_read, new_buff_size; + char *line_start, *p; + + for (;;) { + /* If there's a line in the buffer, return it immediately. */ + while (lr->line_end < lr->buff_end) { + if (lr->nullSeparator) { + if (*lr->line_end == '\0') { + line_start = lr->line_start; + lr->line_start = lr->line_end + 1; + lr->line_end = lr->line_start; + return (line_start); + } + } else if (*lr->line_end == '\x0a' || *lr->line_end == '\x0d') { + *lr->line_end = '\0'; + line_start = lr->line_start; + lr->line_start = lr->line_end + 1; + lr->line_end = lr->line_start; + if (line_start[0] != '\0') + return (line_start); + } + lr->line_end++; + } + + /* If we're at end-of-file, process the final data. */ + if (lr->f == NULL) { + /* If there's more text, return one last line. */ + if (lr->line_end > lr->line_start) { + *lr->line_end = '\0'; + line_start = lr->line_start; + lr->line_start = lr->line_end + 1; + lr->line_end = lr->line_start; + return (line_start); + } + /* Otherwise, we're done. */ + return (NULL); + } + + /* Buffer only has part of a line. */ + if (lr->line_start > lr->buff) { + /* Move a leftover fractional line to the beginning. */ + memmove(lr->buff, lr->line_start, + lr->buff_end - lr->line_start); + lr->buff_end -= lr->line_start - lr->buff; + lr->line_end -= lr->line_start - lr->buff; + lr->line_start = lr->buff; + } else { + /* Line is too big; enlarge the buffer. */ + new_buff_size = lr->buff_length * 2; + if (new_buff_size <= lr->buff_length) + lafe_errc(1, ENOMEM, + "Line too long in %s", lr->pathname); + lr->buff_length = new_buff_size; + p = realloc(lr->buff, new_buff_size); + if (p == NULL) + lafe_errc(1, ENOMEM, + "Line too long in %s", lr->pathname); + lr->buff_end = p + (lr->buff_end - lr->buff); + lr->line_end = p + (lr->line_end - lr->buff); + lr->line_start = lr->buff = p; + } + + /* Get some more data into the buffer. */ + bytes_wanted = lr->buff + lr->buff_length - lr->buff_end; + bytes_read = fread(lr->buff_end, 1, bytes_wanted, lr->f); + lr->buff_end += bytes_read; + + if (ferror(lr->f)) + lafe_errc(1, errno, "Can't read %s", lr->pathname); + if (feof(lr->f)) { + if (lr->f != stdin) + fclose(lr->f); + lr->f = NULL; + } + } +} + +void +lafe_line_reader_free(struct lafe_line_reader *lr) +{ + free(lr->buff); + free(lr->pathname); + free(lr); +} diff --git a/lib/libarchive/libarchive_fe/line_reader.h b/lib/libarchive/libarchive_fe/line_reader.h new file mode 100644 index 0000000..e4c3729 --- /dev/null +++ b/lib/libarchive/libarchive_fe/line_reader.h @@ -0,0 +1,37 @@ +/*- + * Copyright (c) 2009 Joerg Sonnenberger + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (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$ + */ + +#ifndef LAFE_LINE_READER_H +#define LAFE_LINE_READER_H + +struct lafe_line_reader; + +struct lafe_line_reader *lafe_line_reader(const char *, int nullSeparator); +const char *lafe_line_reader_next(struct lafe_line_reader *); +void lafe_line_reader_free(struct lafe_line_reader *); + +#endif diff --git a/lib/libarchive/libarchive_fe/matching.c b/lib/libarchive/libarchive_fe/matching.c new file mode 100644 index 0000000..01e9c39 --- /dev/null +++ b/lib/libarchive/libarchive_fe/matching.c @@ -0,0 +1,281 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "lafe_platform.h" +__FBSDID("$FreeBSD$"); + +#ifdef HAVE_ERRNO_H +#include <errno.h> +#endif +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif + +#include "err.h" +#include "line_reader.h" +#include "matching.h" +#include "pathmatch.h" + +struct match { + struct match *next; + int matches; + char pattern[1]; +}; + +struct lafe_matching { + struct match *exclusions; + int exclusions_count; + struct match *inclusions; + int inclusions_count; + int inclusions_unmatched_count; +}; + +static void add_pattern(struct match **list, const char *pattern); +static void initialize_matching(struct lafe_matching **); +static int match_exclusion(struct match *, const char *pathname); +static int match_inclusion(struct match *, const char *pathname); + +/* + * The matching logic here needs to be re-thought. I started out to + * try to mimic gtar's matching logic, but it's not entirely + * consistent. In particular 'tar -t' and 'tar -x' interpret patterns + * on the command line as anchored, but --exclude doesn't. + */ + +/* + * Utility functions to manage exclusion/inclusion patterns + */ + +int +lafe_exclude(struct lafe_matching **matching, const char *pattern) +{ + + if (*matching == NULL) + initialize_matching(matching); + add_pattern(&((*matching)->exclusions), pattern); + (*matching)->exclusions_count++; + return (0); +} + +int +lafe_exclude_from_file(struct lafe_matching **matching, const char *pathname) +{ + struct lafe_line_reader *lr; + const char *p; + int ret = 0; + + lr = lafe_line_reader(pathname, 0); + while ((p = lafe_line_reader_next(lr)) != NULL) { + if (lafe_exclude(matching, p) != 0) + ret = -1; + } + lafe_line_reader_free(lr); + return (ret); +} + +int +lafe_include(struct lafe_matching **matching, const char *pattern) +{ + + if (*matching == NULL) + initialize_matching(matching); + add_pattern(&((*matching)->inclusions), pattern); + (*matching)->inclusions_count++; + (*matching)->inclusions_unmatched_count++; + return (0); +} + +int +lafe_include_from_file(struct lafe_matching **matching, const char *pathname, + int nullSeparator) +{ + struct lafe_line_reader *lr; + const char *p; + int ret = 0; + + lr = lafe_line_reader(pathname, nullSeparator); + while ((p = lafe_line_reader_next(lr)) != NULL) { + if (lafe_include(matching, p) != 0) + ret = -1; + } + lafe_line_reader_free(lr); + return (ret); +} + +static void +add_pattern(struct match **list, const char *pattern) +{ + struct match *match; + size_t len; + + len = strlen(pattern); + match = malloc(sizeof(*match) + len + 1); + if (match == NULL) + lafe_errc(1, errno, "Out of memory"); + strcpy(match->pattern, pattern); + /* Both "foo/" and "foo" should match "foo/bar". */ + if (len && match->pattern[len - 1] == '/') + match->pattern[strlen(match->pattern)-1] = '\0'; + match->next = *list; + *list = match; + match->matches = 0; +} + + +int +lafe_excluded(struct lafe_matching *matching, const char *pathname) +{ + struct match *match; + struct match *matched; + + if (matching == NULL) + return (0); + + /* Mark off any unmatched inclusions. */ + /* In particular, if a filename does appear in the archive and + * is explicitly included and excluded, then we don't report + * it as missing even though we don't extract it. + */ + matched = NULL; + for (match = matching->inclusions; match != NULL; match = match->next){ + if (match->matches == 0 + && match_inclusion(match, pathname)) { + matching->inclusions_unmatched_count--; + match->matches++; + matched = match; + } + } + + /* Exclusions take priority */ + for (match = matching->exclusions; match != NULL; match = match->next){ + if (match_exclusion(match, pathname)) + return (1); + } + + /* It's not excluded and we found an inclusion above, so it's included. */ + if (matched != NULL) + return (0); + + + /* We didn't find an unmatched inclusion, check the remaining ones. */ + for (match = matching->inclusions; match != NULL; match = match->next){ + /* We looked at previously-unmatched inclusions already. */ + if (match->matches > 0 + && match_inclusion(match, pathname)) { + match->matches++; + return (0); + } + } + + /* If there were inclusions, default is to exclude. */ + if (matching->inclusions != NULL) + return (1); + + /* No explicit inclusions, default is to match. */ + return (0); +} + +/* + * This is a little odd, but it matches the default behavior of + * gtar. In particular, 'a*b' will match 'foo/a1111/222b/bar' + * + */ +static int +match_exclusion(struct match *match, const char *pathname) +{ + return (lafe_pathmatch(match->pattern, + pathname, + PATHMATCH_NO_ANCHOR_START | PATHMATCH_NO_ANCHOR_END)); +} + +/* + * Again, mimic gtar: inclusions are always anchored (have to match + * the beginning of the path) even though exclusions are not anchored. + */ +static int +match_inclusion(struct match *match, const char *pathname) +{ + return (lafe_pathmatch(match->pattern, pathname, PATHMATCH_NO_ANCHOR_END)); +} + +void +lafe_cleanup_exclusions(struct lafe_matching **matching) +{ + struct match *p, *q; + + if (*matching == NULL) + return; + + for (p = (*matching)->inclusions; p != NULL; ) { + q = p; + p = p->next; + free(q); + } + + for (p = (*matching)->exclusions; p != NULL; ) { + q = p; + p = p->next; + free(q); + } + + free(*matching); + *matching = NULL; +} + +static void +initialize_matching(struct lafe_matching **matching) +{ + *matching = calloc(sizeof(**matching), 1); + if (*matching == NULL) + lafe_errc(1, errno, "No memory"); +} + +int +lafe_unmatched_inclusions(struct lafe_matching *matching) +{ + + if (matching == NULL) + return (0); + return (matching->inclusions_unmatched_count); +} + +int +lafe_unmatched_inclusions_warn(struct lafe_matching *matching, const char *msg) +{ + struct match *p; + + if (matching == NULL) + return (0); + + for (p = matching->inclusions; p != NULL; p = p->next) { + if (p->matches == 0) + lafe_warnc(0, "%s: %s", p->pattern, msg); + } + + return (matching->inclusions_unmatched_count); +} diff --git a/lib/libarchive/libarchive_fe/matching.h b/lib/libarchive/libarchive_fe/matching.h new file mode 100644 index 0000000..f4edebd --- /dev/null +++ b/lib/libarchive/libarchive_fe/matching.h @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (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$ + */ + +#ifndef MATCHING_H +#define MATCHING_H + +struct lafe_matching; + +int lafe_exclude(struct lafe_matching **matching, const char *pattern); +int lafe_exclude_from_file(struct lafe_matching **matching, + const char *pathname); +int lafe_include(struct lafe_matching **matching, const char *pattern); +int lafe_include_from_file(struct lafe_matching **matching, + const char *pathname, int nullSeparator); + +int lafe_excluded(struct lafe_matching *, const char *pathname); +void lafe_cleanup_exclusions(struct lafe_matching **); +int lafe_unmatched_inclusions(struct lafe_matching *); +int lafe_unmatched_inclusions_warn(struct lafe_matching *, const char *msg); + +#endif diff --git a/lib/libarchive/libarchive_fe/pathmatch.c b/lib/libarchive/libarchive_fe/pathmatch.c new file mode 100644 index 0000000..e211362 --- /dev/null +++ b/lib/libarchive/libarchive_fe/pathmatch.c @@ -0,0 +1,255 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "lafe_platform.h" +__FBSDID("$FreeBSD$"); + +#ifdef HAVE_STRING_H +#include <string.h> +#endif + +#include "pathmatch.h" + +/* + * Check whether a character 'c' is matched by a list specification [...]: + * * Leading '!' or '^' negates the class. + * * <char>-<char> is a range of characters + * * \<char> removes any special meaning for <char> + * + * Some interesting boundary cases: + * a-d-e is one range (a-d) followed by two single characters - and e. + * \a-\d is same as a-d + * a\-d is three single characters: a, d, - + * Trailing - is not special (so [a-] is two characters a and -). + * Initial - is not special ([a-] is same as [-a] is same as [\\-a]) + * This function never sees a trailing \. + * [] always fails + * [!] always succeeds + */ +static int +pm_list(const char *start, const char *end, const char c, int flags) +{ + const char *p = start; + char rangeStart = '\0', nextRangeStart; + int match = 1, nomatch = 0; + + /* This will be used soon... */ + (void)flags; /* UNUSED */ + + /* If this is a negated class, return success for nomatch. */ + if ((*p == '!' || *p == '^') && p < end) { + match = 0; + nomatch = 1; + ++p; + } + + while (p < end) { + nextRangeStart = '\0'; + switch (*p) { + case '-': + /* Trailing or initial '-' is not special. */ + if ((rangeStart == '\0') || (p == end - 1)) { + if (*p == c) + return (match); + } else { + char rangeEnd = *++p; + if (rangeEnd == '\\') + rangeEnd = *++p; + if ((rangeStart <= c) && (c <= rangeEnd)) + return (match); + } + break; + case '\\': + ++p; + /* Fall through */ + default: + if (*p == c) + return (match); + nextRangeStart = *p; /* Possible start of range. */ + } + rangeStart = nextRangeStart; + ++p; + } + return (nomatch); +} + +/* + * If s is pointing to "./", ".//", "./././" or the like, skip it. + */ +static const char * +pm_slashskip(const char *s) { + while ((*s == '/') + || (s[0] == '.' && s[1] == '/') + || (s[0] == '.' && s[1] == '\0')) + ++s; + return (s); +} + +static int +pm(const char *p, const char *s, int flags) +{ + const char *end; + + /* + * Ignore leading './', './/', '././', etc. + */ + if (s[0] == '.' && s[1] == '/') + s = pm_slashskip(s + 1); + if (p[0] == '.' && p[1] == '/') + p = pm_slashskip(p + 1); + + for (;;) { + switch (*p) { + case '\0': + if (s[0] == '/') { + if (flags & PATHMATCH_NO_ANCHOR_END) + return (1); + /* "dir" == "dir/" == "dir/." */ + s = pm_slashskip(s); + } + return (*s == '\0'); + case '?': + /* ? always succeds, unless we hit end of 's' */ + if (*s == '\0') + return (0); + break; + case '*': + /* "*" == "**" == "***" ... */ + while (*p == '*') + ++p; + /* Trailing '*' always succeeds. */ + if (*p == '\0') + return (1); + while (*s) { + if (lafe_pathmatch(p, s, flags)) + return (1); + ++s; + } + return (0); + case '[': + /* + * Find the end of the [...] character class, + * ignoring \] that might occur within the class. + */ + end = p + 1; + while (*end != '\0' && *end != ']') { + if (*end == '\\' && end[1] != '\0') + ++end; + ++end; + } + if (*end == ']') { + /* We found [...], try to match it. */ + if (!pm_list(p + 1, end, *s, flags)) + return (0); + p = end; /* Jump to trailing ']' char. */ + break; + } else + /* No final ']', so just match '['. */ + if (*p != *s) + return (0); + break; + case '\\': + /* Trailing '\\' matches itself. */ + if (p[1] == '\0') { + if (*s != '\\') + return (0); + } else { + ++p; + if (*p != *s) + return (0); + } + break; + case '/': + if (*s != '/' && *s != '\0') + return (0); + /* Note: pattern "/\./" won't match "/"; + * pm_slashskip() correctly stops at backslash. */ + p = pm_slashskip(p); + s = pm_slashskip(s); + if (*p == '\0' && (flags & PATHMATCH_NO_ANCHOR_END)) + return (1); + --p; /* Counteract the increment below. */ + --s; + break; + case '$': + /* '$' is special only at end of pattern and only + * if PATHMATCH_NO_ANCHOR_END is specified. */ + if (p[1] == '\0' && (flags & PATHMATCH_NO_ANCHOR_END)){ + /* "dir" == "dir/" == "dir/." */ + return (*pm_slashskip(s) == '\0'); + } + /* Otherwise, '$' is not special. */ + /* FALL THROUGH */ + default: + if (*p != *s) + return (0); + break; + } + ++p; + ++s; + } +} + +/* Main entry point. */ +int +lafe_pathmatch(const char *p, const char *s, int flags) +{ + /* Empty pattern only matches the empty string. */ + if (p == NULL || *p == '\0') + return (s == NULL || *s == '\0'); + + /* Leading '^' anchors the start of the pattern. */ + if (*p == '^') { + ++p; + flags &= ~PATHMATCH_NO_ANCHOR_START; + } + + if (*p == '/' && *s != '/') + return (0); + + /* Certain patterns and file names anchor implicitly. */ + if (*p == '*' || *p == '/' || *p == '/') { + while (*p == '/') + ++p; + while (*s == '/') + ++s; + return (pm(p, s, flags)); + } + + /* If start is unanchored, try to match start of each path element. */ + if (flags & PATHMATCH_NO_ANCHOR_START) { + for ( ; s != NULL; s = strchr(s, '/')) { + if (*s == '/') + s++; + if (pm(p, s, flags)) + return (1); + } + return (0); + } + + /* Default: Match from beginning. */ + return (pm(p, s, flags)); +} diff --git a/lib/libarchive/libarchive_fe/pathmatch.h b/lib/libarchive/libarchive_fe/pathmatch.h new file mode 100644 index 0000000..a92f3ae --- /dev/null +++ b/lib/libarchive/libarchive_fe/pathmatch.h @@ -0,0 +1,42 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer + * in this position and unchanged. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (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$ + */ + +#ifndef LAFE_PATHMATCH_H +#define LAFE_PATHMATCH_H + +/* Don't anchor at beginning unless the pattern starts with "^" */ +#define PATHMATCH_NO_ANCHOR_START 1 +/* Don't anchor at end unless the pattern ends with "$" */ +#define PATHMATCH_NO_ANCHOR_END 2 + +/* Note that "^" and "$" are not special unless you set the corresponding + * flag above. */ + +int lafe_pathmatch(const char *p, const char *s, int flags); + +#endif diff --git a/lib/libarchive/test/Makefile b/lib/libarchive/test/Makefile index f9fead9..3f747b6 100644 --- a/lib/libarchive/test/Makefile +++ b/lib/libarchive/test/Makefile @@ -45,6 +45,8 @@ TESTS= \ test_read_format_cpio_odc.c \ test_read_format_cpio_svr4_gzip.c \ test_read_format_cpio_svr4c_Z.c \ + test_read_format_cpio_svr4_bzip2_rpm.c \ + test_read_format_cpio_svr4_gzip_rpm.c \ test_read_format_empty.c \ test_read_format_gtar_gz.c \ test_read_format_gtar_lzma.c \ @@ -69,6 +71,7 @@ TESTS= \ test_read_format_tlz.c \ test_read_format_txz.c \ test_read_format_tz.c \ + test_read_format_xar.c \ test_read_format_zip.c \ test_read_large.c \ test_read_pax_truncated.c \ diff --git a/lib/libarchive/test/main.c b/lib/libarchive/test/main.c index 5f8cbc3..0cd16a0 100644 --- a/lib/libarchive/test/main.c +++ b/lib/libarchive/test/main.c @@ -346,7 +346,7 @@ failure_finish(void *extra) if (dump_on_failure) { fprintf(stderr, " *** forcing core dump so failure can be debugged ***\n"); - *(char *)(NULL) = 0; + abort(); exit(1); } } @@ -485,6 +485,22 @@ wcsdump(const char *e, const wchar_t *w) logprintf("\"\n"); } +#ifndef HAVE_WCSCMP +static int +wcscmp(const wchar_t *s1, const wchar_t *s2) +{ + + while (*s1 == *s2++) { + if (*s1++ == L'\0') + return 0; + } + if (*s1 > *--s2) + return 1; + else + return -1; +} +#endif + /* Verify that two wide strings are equal, dump them if not. */ int assertion_equal_wstring(const char *file, int line, diff --git a/lib/libarchive/test/read_open_memory.c b/lib/libarchive/test/read_open_memory.c index 17e7f75..db0de85 100644 --- a/lib/libarchive/test/read_open_memory.c +++ b/lib/libarchive/test/read_open_memory.c @@ -43,16 +43,13 @@ struct read_memory_data { unsigned char *end; size_t read_size; size_t copy_buff_size; + size_t copy_buff_offset; char *copy_buff; }; static int memory_read_close(struct archive *, void *); static int memory_read_open(struct archive *, void *); -#if ARCHIVE_VERSION_NUMBER < 2000000 -static ssize_t memory_read_skip(struct archive *, void *, size_t request); -#else static off_t memory_read_skip(struct archive *, void *, off_t request); -#endif static ssize_t memory_read(struct archive *, void *, const void **buff); static int read_open_memory_internal(struct archive *a, void *buff, size_t size, size_t read_size, int fullapi); @@ -89,8 +86,10 @@ read_open_memory_internal(struct archive *a, void *buff, mine->buffer = (unsigned char *)buff; mine->end = mine->buffer + size; mine->read_size = read_size; - mine->copy_buff_size = read_size + 64; + mine->copy_buff_offset = 32; + mine->copy_buff_size = read_size + mine->copy_buff_offset * 2; mine->copy_buff = malloc(mine->copy_buff_size); + memset(mine->copy_buff, 0xA5, mine->copy_buff_size); if (fullapi) return (archive_read_open2(a, mine, memory_read_open, memory_read, memory_read_skip, memory_read_close)); @@ -126,9 +125,10 @@ memory_read(struct archive *a, void *client_data, const void **buff) size = mine->end - mine->buffer; if (size > mine->read_size) size = mine->read_size; - memset(mine->copy_buff, 0xA5, mine->copy_buff_size); - memcpy(mine->copy_buff, mine->buffer, size); - *buff = mine->copy_buff; + else + memset(mine->copy_buff, 0xA5, mine->copy_buff_size); + memcpy(mine->copy_buff + mine->copy_buff_offset, mine->buffer, size); + *buff = mine->copy_buff + mine->copy_buff_offset; mine->buffer += size; return ((ssize_t)size); @@ -137,13 +137,8 @@ memory_read(struct archive *a, void *client_data, const void **buff) /* * How mean can a skip() routine be? Let's try to find out. */ -#if ARCHIVE_VERSION_NUMBER < 2000000 -static ssize_t -memory_read_skip(struct archive *a, void *client_data, size_t skip) -#else static off_t memory_read_skip(struct archive *a, void *client_data, off_t skip) -#endif { struct read_memory_data *mine = (struct read_memory_data *)client_data; diff --git a/lib/libarchive/test/test.h b/lib/libarchive/test/test.h index 6ea7b57..725c899 100644 --- a/lib/libarchive/test/test.h +++ b/lib/libarchive/test/test.h @@ -48,9 +48,6 @@ #include <sys/types.h> /* Windows requires this before sys/stat.h */ #include <sys/stat.h> -#ifdef USE_DMALLOC -#include <dmalloc.h> -#endif #if HAVE_DIRENT_H #include <dirent.h> #endif @@ -299,3 +296,7 @@ int read_open_memory2(struct archive *, void *, size_t, size_t); assertion_equal_int(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a)) #define assertEqualStringA(a,v1,v2) \ assertion_equal_string(__FILE__, __LINE__, (v1), #v1, (v2), #v2, (a)) + +#ifdef USE_DMALLOC +#include <dmalloc.h> +#endif diff --git a/lib/libarchive/test/test_entry.c b/lib/libarchive/test/test_entry.c index bd946c4..35ca6e3 100644 --- a/lib/libarchive/test/test_entry.c +++ b/lib/libarchive/test/test_entry.c @@ -27,6 +27,16 @@ __FBSDID("$FreeBSD$"); #include <locale.h> +#ifndef HAVE_WCSCPY +static wchar_t * wcscpy(wchar_t *s1, const wchar_t *s2) +{ + wchar_t *dest = s1; + while ((*s1 = *s2) != L'\0') + ++s1, ++s2; + return dest; +} +#endif + /* * Most of these tests are system-independent, though a few depend on * features of the local system. Such tests are conditionalized on @@ -866,6 +876,7 @@ DEFINE_TEST(test_entry) assert(NULL == archive_entry_symlink_w(e)); } +#if HAVE_WCSCPY l = 0x12345678L; wc = (wchar_t)l; /* Wide character too big for UTF-8. */ if (NULL == setlocale(LC_ALL, "C") || (long)wc != l) { @@ -885,6 +896,7 @@ DEFINE_TEST(test_entry) failure("Converting wide characters from Unicode should fail."); assertEqualString(NULL, archive_entry_pathname(e)); } +#endif /* Release the experimental entry. */ archive_entry_free(e); diff --git a/lib/libarchive/test/test_fuzz.c b/lib/libarchive/test/test_fuzz.c index 7e3f28d..8f91fca 100644 --- a/lib/libarchive/test/test_fuzz.c +++ b/lib/libarchive/test/test_fuzz.c @@ -62,6 +62,7 @@ static struct { {0, "test_compat_zip_1.zip"}, {0, "test_read_format_ar.ar"}, {0, "test_read_format_cpio_bin_be.cpio"}, + {0, "test_read_format_cpio_svr4_gzip_rpm.rpm"}, /* Test RPM unwrapper */ {0, "test_read_format_gtar_sparse_1_17_posix10_modified.tar"}, {0, "test_read_format_mtree.mtree"}, {0, "test_read_format_tar_empty_filename.tar"}, @@ -111,8 +112,10 @@ DEFINE_TEST(test_fuzz) assert(size > 0); failure("Internal buffer is not big enough for " "uncompressed test file: %s", filename); - if (!assert(size < buffsize)) + if (!assert(size < buffsize)) { + free(rawimage); continue; + } } else { rawimage = slurpfile(&size, filename); if (!assert(rawimage != NULL)) @@ -152,8 +155,8 @@ DEFINE_TEST(test_fuzz) continue; } archive_read_close(a); - archive_read_finish(a); } + archive_read_finish(a); } free(image); free(rawimage); diff --git a/lib/libarchive/test/test_pax_filename_encoding.c b/lib/libarchive/test/test_pax_filename_encoding.c index 5affe9f..af0208c 100644 --- a/lib/libarchive/test/test_pax_filename_encoding.c +++ b/lib/libarchive/test/test_pax_filename_encoding.c @@ -225,9 +225,11 @@ test_pax_filename_encoding_3(void) * setlocale() does not set the default encoding for CP_ACP. */ entry = archive_entry_new(); if (archive_entry_update_pathname_utf8(entry, badname_utf8)) { + archive_entry_free(entry); skipping("Cannot test conversion failures."); return; } + archive_entry_free(entry); assert((a = archive_write_new()) != NULL); assertEqualIntA(a, 0, archive_write_set_format_pax(a)); diff --git a/lib/libarchive/test/test_read_data_large.c b/lib/libarchive/test/test_read_data_large.c index ecacf65..2dacb50 100644 --- a/lib/libarchive/test/test_read_data_large.c +++ b/lib/libarchive/test/test_read_data_large.c @@ -69,7 +69,7 @@ DEFINE_TEST(test_read_data_large) archive_entry_set_size(ae, sizeof(buff2)); assertA(0 == archive_write_header(a, ae)); archive_entry_free(ae); - assertA(sizeof(buff2) == archive_write_data(a, buff2, sizeof(buff2))); + assertA((int)sizeof(buff2) == archive_write_data(a, buff2, sizeof(buff2))); /* Close out the archive. */ assertA(0 == archive_write_close(a)); diff --git a/lib/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c b/lib/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c new file mode 100644 index 0000000..005838d --- /dev/null +++ b/lib/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.c @@ -0,0 +1,128 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * Copyright (c) 2009 Michihiro NAKAJIMA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "test.h" +__FBSDID("$FreeBSD$"); + +/* +Execute the following command to rebuild the data for this program: + tail -n +32 test_read_format_cpio_svr4_bzip2_rpm.c | /bin/sh + +F=test_read_format_cpio_svr4_bzip2_rpm.rpm +NAME=rpmsample +TMPRPM=/tmp/rpm +rm -rf ${TMPRPM} +mkdir -p ${TMPRPM}/BUILD +mkdir -p ${TMPRPM}/RPMS +mkdir -p ${TMPRPM}/SOURCES +mkdir -p ${TMPRPM}/SPECS +mkdir -p ${TMPRPM}/SRPMS +echo "hello" > ${TMPRPM}/BUILD/file1 +echo "hello" > ${TMPRPM}/BUILD/file2 +echo "hello" > ${TMPRPM}/BUILD/file3 +cat > ${TMPRPM}/SPECS/${NAME}.spec <<END +## +%define _topdir ${TMPRPM} +%define _binary_payload w9.bzdio + +Summary: Sample data of RPM filter of libarchive +Name: ${NAME} +Version: 1.0.0 +Release: 1 +License: BSD +URL: http://code.google.com/p/libarchive +BuildArch: noarch +BuildRoot: %{_tmppath}/%{name}-%{version}-root + +%install +rm -rf \$RPM_BUILD_ROOT + +mkdir -p \$RPM_BUILD_ROOT%{_sysconfdir} +install -m 644 file1 \$RPM_BUILD_ROOT%{_sysconfdir}/file1 +install -m 644 file2 \$RPM_BUILD_ROOT%{_sysconfdir}/file2 +install -m 644 file3 \$RPM_BUILD_ROOT%{_sysconfdir}/file3 +TZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file1 +TZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file2 +TZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file3 + +%files +%{_sysconfdir}/file1 +%{_sysconfdir}/file2 +%{_sysconfdir}/file3 + +%description +Sample data. +END +# +rpmbuild -bb ${TMPRPM}/SPECS/${NAME}.spec +uuencode ${F} < ${TMPRPM}/RPMS/noarch/${NAME}-1.0.0-1.noarch.rpm > ${F}.uu + +rm -rf ${TMPRPM} +exit 1 +*/ + +DEFINE_TEST(test_read_format_cpio_svr4_bzip2_rpm) +{ + struct archive_entry *ae; + struct archive *a; + const char *name = "test_read_format_cpio_svr4_bzip2_rpm.rpm"; + int r; + + assert((a = archive_read_new()) != NULL); + r = archive_read_support_compression_bzip2(a); + if (r == ARCHIVE_WARN) { + skipping("bzip2 reading not fully supported on this platform"); + assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); + return; + } + assertEqualIntA(a, ARCHIVE_OK, r); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_support_compression_rpm(a)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); + extract_reference_file(name); + assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 2)); + + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualString("./etc/file1", archive_entry_pathname(ae)); + assertEqualInt(86401, archive_entry_mtime(ae)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualString("./etc/file2", archive_entry_pathname(ae)); + assertEqualInt(86401, archive_entry_mtime(ae)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualString("./etc/file3", archive_entry_pathname(ae)); + assertEqualInt(86401, archive_entry_mtime(ae)); + + /* Verify the end-of-archive. */ + assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); + + /* Verify that the format detection worked. */ + assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_BZIP2); + assertEqualString(archive_compression_name(a), "bzip2"); + assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_SVR4_NOCRC); + + assertEqualInt(ARCHIVE_OK, archive_read_close(a)); + assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); +} + diff --git a/lib/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.rpm.uu b/lib/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.rpm.uu new file mode 100644 index 0000000..3e85150 --- /dev/null +++ b/lib/libarchive/test/test_read_format_cpio_svr4_bzip2_rpm.rpm.uu @@ -0,0 +1,49 @@ +$FreeBSD$ + +begin 644 test_read_format_cpio_svr4_bzip2_rpm.rpm +M[:ONVP,``````7)P;7-A;7!L92TQ+C`N,"TQ```````````````````````` +M```````````````````````````````````````````!``4````````````` +M````````CJWH`0`````````%````5````#X````'````1````!````$-```` +M!@`````````!```#Z`````0````L`````0```^P````'````,````!````/O +M````!````$`````!,F4X-3)F-39E,#,W83EE.61A9C<W8V(Q,&0P8S4T-65E +M9&8S-6$U8@````````:<A,!!LG.$S/]SK-(FA0BH6@```@@````^````!___ +M_[`````0`````(ZMZ`$`````````,0```NP````_````!P```MP````0```` +M9`````@``````````0```^@````&`````@````$```/I````!@````P````! +M```#Z@````8````2`````0```^P````)````%`````$```/M````"0```#P` +M```!```#[@````0```!,`````0```^\````&````4`````$```/Q````!``` +M`%P````!```#]@````8```!@`````0```_@````)````9`````$```/\```` +M!@```'`````!```#_0````8```"4`````0```_X````&````F@````$```0$ +M````!````*0````#```$!@````,```"P`````P``!`D````#````M@````,` +M``0*````!````+P````#```$"P````@```#(`````P``!`P````(```!*P`` +M``,```0-````!````3`````#```$#P````@```$\`````P``!!`````(```! +M2P````,```04````!@```5H````!```$%0````0```%T`````P``!!<````( +M```!@`````$```08````!````8P````#```$&0````@```&8`````P``!!H` +M```(```!Z@````,```0H````!@```@`````!```$1P````0```((`````P`` +M!$@````$```"%`````,```1)````"````B`````#```$6`````0```(D```` +M`0``!%D````(```"*`````$```1<````!````C`````#```$70````@```(\ +M`````P``!%X````(```"3@````$```1B````!@```E0````!```$9`````8` +M``)S`````0``!&4````&```">`````$```1F````!@```GX````!```$;``` +M``8```*``````0``!'0````$```"E`````,```1U````!````J`````#```$ +M=@````@```*L`````P``!'<````$```"Q`````,```1X````!````M`````# +M0P!R<&US86UP;&4`,2XP+C``,0!386UP;&4@9&%T82!O9B!24$T@9FEL=&5R +M(&]F(&QI8F%R8VAI=F4`4V%M<&QE(&1A=&$N`````$L)MWQC=64M9&5S:W1O +M<``````20E-$`%5N<W!E8VEF:65D`&AT='`Z+R]C;V1E+F=O;V=L92YC;VTO +M<"]L:6)A<F-H:79E`&QI;G5X`&YO87)C:``````````&````!@````:!I(&D +M@:0``````````5&!``%1@0`!48%B,3DT-F%C.3(T.3)D,C,T-V,V,C,U8C1D +M,C8Q,3$X-`!B,3DT-F%C.3(T.3)D,C,T-V,V,C,U8C1D,C8Q,3$X-`!B,3DT +M-F%C.3(T.3)D,C,T-V,V,C,U8C1D,C8Q,3$X-``````````````````````` +M`')O;W0`<F]O=`!R;V]T`')O;W0`<F]O=`!R;V]T`')P;7-A;7!L92TQ+C`N +M,"TQ+G-R8RYR<&T`________________<G!M<V%M<&QE`````0``2@$``$H! +M``!*<G!M;&EB*$-O;7!R97-S961&:6QE3F%M97,I`')P;6QI8BA087EL;V%D +M1FEL97-(879E4')E9FEX*0!R<&UL:6(H4&%Y;&]A9$ES0GII<#(I`#,N,"XT +M+3$`-"XP+3$`,RXP+C4M,0`T+C<N,```````"`$```@!```(`0``*H<``"J( +M```JB0`````````(,2XP+C`M,0````````````````!F:6QE,0!F:6QE,@!F +M:6QE,P`O971C+P`M3S(@+6<@+6UA<F-H/6DS.#8@+6UT=6YE/6DV.#8`8W!I +M;P!B>FEP,@`Y`&YO87)C:"UR<&TM;&EN=7@````````````````````````` +M`0````$````!`$%30TE)('1E>'0`9&ER96-T;W)Y```````````````````` +M````````````````````/P````?___SP````$$)::#DQ05DF4UFX89DX``!= +M?X!,$`@`*`'_X"(D%``[9(0`(`"2B/50T#0#0`](9!%(C1,0&GJ`R`M@PQRG +M<PN0PPC]8&X[2P=KHS%0Q<^=89M6CI5L`O2\("`W!K-V.;*M63U;6ES%CQI6 +E4,1$DE)B@G&.7I5?NT46(XB0/D,B!$Z-!A_B[DBG"A(7##,G```` +` +end diff --git a/lib/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c b/lib/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c new file mode 100644 index 0000000..59e53f1 --- /dev/null +++ b/lib/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.c @@ -0,0 +1,128 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * Copyright (c) 2009 Michihiro NAKAJIMA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "test.h" +__FBSDID("$FreeBSD$"); + +/* +Execute the following command to rebuild the data for this program: + tail -n +32 test_read_format_cpio_svr4_gzip_rpm.c | /bin/sh + +F=test_read_format_cpio_svr4_gzip_rpm.rpm +NAME=rpmsample +TMPRPM=/tmp/rpm +rm -rf ${TMPRPM} +mkdir -p ${TMPRPM}/BUILD +mkdir -p ${TMPRPM}/RPMS +mkdir -p ${TMPRPM}/SOURCES +mkdir -p ${TMPRPM}/SPECS +mkdir -p ${TMPRPM}/SRPMS +echo "hello" > ${TMPRPM}/BUILD/file1 +echo "hello" > ${TMPRPM}/BUILD/file2 +echo "hello" > ${TMPRPM}/BUILD/file3 +cat > ${TMPRPM}/SPECS/${NAME}.spec <<END +## +%define _topdir ${TMPRPM} +%define _binary_payload w9.gzdio + +Summary: Sample data of RPM filter of libarchive +Name: ${NAME} +Version: 1.0.0 +Release: 1 +License: BSD +URL: http://code.google.com/p/libarchive +BuildArch: noarch +BuildRoot: %{_tmppath}/%{name}-%{version}-root + +%install +rm -rf \$RPM_BUILD_ROOT + +mkdir -p \$RPM_BUILD_ROOT%{_sysconfdir} +install -m 644 file1 \$RPM_BUILD_ROOT%{_sysconfdir}/file1 +install -m 644 file2 \$RPM_BUILD_ROOT%{_sysconfdir}/file2 +install -m 644 file3 \$RPM_BUILD_ROOT%{_sysconfdir}/file3 +TZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file1 +TZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file2 +TZ=utc touch -afm -t 197001020000.01 \$RPM_BUILD_ROOT%{_sysconfdir}/file3 + +%files +%{_sysconfdir}/file1 +%{_sysconfdir}/file2 +%{_sysconfdir}/file3 + +%description +Sample data. +END +# +rpmbuild -bb ${TMPRPM}/SPECS/${NAME}.spec +uuencode ${F} < ${TMPRPM}/RPMS/noarch/${NAME}-1.0.0-1.noarch.rpm > ${F}.uu + +rm -rf ${TMPRPM} +exit 1 +*/ + +DEFINE_TEST(test_read_format_cpio_svr4_gzip_rpm) +{ + struct archive_entry *ae; + struct archive *a; + const char *name = "test_read_format_cpio_svr4_gzip_rpm.rpm"; + int r; + + assert((a = archive_read_new()) != NULL); + r = archive_read_support_compression_gzip(a); + if (r == ARCHIVE_WARN) { + skipping("gzip reading not fully supported on this platform"); + assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); + return; + } + assertEqualIntA(a, ARCHIVE_OK, r); + assertEqualIntA(a, ARCHIVE_OK, + archive_read_support_compression_rpm(a)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a)); + extract_reference_file(name); + assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, name, 2)); + + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualString("./etc/file1", archive_entry_pathname(ae)); + assertEqualInt(86401, archive_entry_mtime(ae)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualString("./etc/file2", archive_entry_pathname(ae)); + assertEqualInt(86401, archive_entry_mtime(ae)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualString("./etc/file3", archive_entry_pathname(ae)); + assertEqualInt(86401, archive_entry_mtime(ae)); + + /* Verify the end-of-archive. */ + assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); + + /* Verify that the format detection worked. */ + assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_GZIP); + assertEqualString(archive_compression_name(a), "gzip"); + assertEqualInt(archive_format(a), ARCHIVE_FORMAT_CPIO_SVR4_NOCRC); + + assertEqualInt(ARCHIVE_OK, archive_read_close(a)); + assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); +} + diff --git a/lib/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.rpm.uu b/lib/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.rpm.uu new file mode 100644 index 0000000..ac29865 --- /dev/null +++ b/lib/libarchive/test/test_read_format_cpio_svr4_gzip_rpm.rpm.uu @@ -0,0 +1,48 @@ +$FreeBSD$ + +begin 644 test_read_format_cpio_svr4_gzip_rpm.rpm +M[:ONVP,``````7)P;7-A;7!L92TQ+C`N,"TQ```````````````````````` +M```````````````````````````````````````````!``4````````````` +M````````CJWH`0`````````%````5````#X````'````1````!````$-```` +M!@`````````!```#Z`````0````L`````0```^P````'````,````!````/O +M````!````$`````!9&9E8V,W,#4T,C@X,V1D-&8P-6%E.#4Y,S<S,&1F,V)D +M,#$Q,S0V80````````9=A5.[L^@5U91731!5GLHZC0```@@````^````!___ +M_[`````0`````(ZMZ`$`````````,0```L0````_````!P```K0````0```` +M9`````@``````````0```^@````&`````@````$```/I````!@````P````! +M```#Z@````8````2`````0```^P````)````%`````$```/M````"0```#P` +M```!```#[@````0```!,`````0```^\````&````4`````$```/Q````!``` +M`%P````!```#]@````8```!@`````0```_@````)````9`````$```/\```` +M!@```'`````!```#_0````8```"4`````0```_X````&````F@````$```0$ +M````!````*0````#```$!@````,```"P`````P``!`D````#````M@````,` +M``0*````!````+P````#```$"P````@```#(`````P``!`P````(```!*P`` +M``,```0-````!````3`````#```$#P````@```$\`````P``!!`````(```! +M2P````,```04````!@```5H````!```$%0````0```%T`````P``!!<````( +M```!@`````$```08````!````8P````"```$&0````@```&4`````@``!!H` +M```(```!SP````(```0H````!@```=T````!```$1P````0```'D`````P`` +M!$@````$```!\`````,```1)````"````?P````#```$6`````0```(````` +M`0``!%D````(```"!`````$```1<````!````@P````#```$70````@```(8 +M`````P``!%X````(```"*@````$```1B````!@```C`````!```$9`````8` +M``)/`````0``!&4````&```"5`````$```1F````!@```ED````!```$;``` +M``8```);`````0``!'0````$```";`````,```1U````!````G@````#```$ +M=@````@```*$`````P``!'<````$```"G`````,```1X````!````J@````# +M0P!R<&US86UP;&4`,2XP+C``,0!386UP;&4@9&%T82!O9B!24$T@9FEL=&5R +M(&]F(&QI8F%R8VAI=F4`4V%M<&QE(&1A=&$N`````$L)MAUC=64M9&5S:W1O +M<``````20E-$`%5N<W!E8VEF:65D`&AT='`Z+R]C;V1E+F=O;V=L92YC;VTO +M<"]L:6)A<F-H:79E`&QI;G5X`&YO87)C:``````````&````!@````:!I(&D +M@:0``````````5&!``%1@0`!48%B,3DT-F%C.3(T.3)D,C,T-V,V,C,U8C1D +M,C8Q,3$X-`!B,3DT-F%C.3(T.3)D,C,T-V,V,C,U8C1D,C8Q,3$X-`!B,3DT +M-F%C.3(T.3)D,C,T-V,V,C,U8C1D,C8Q,3$X-``````````````````````` +M`')O;W0`<F]O=`!R;V]T`')O;W0`<F]O=`!R;V]T`')P;7-A;7!L92TQ+C`N +M,"TQ+G-R8RYR<&T`________________<G!M<V%M<&QE`````0``2@$``$IR +M<&UL:6(H0V]M<')E<W-E9$9I;&5.86UE<RD`<G!M;&EB*%!A>6QO861&:6QE +M<TAA=F50<F5F:7@I`#,N,"XT+3$`-"XP+3$`-"XW+C``````"`$```@!```( +M`0``*H<``"J(```JB0`````````(,2XP+C`M,0````````````````!F:6QE +M,0!F:6QE,@!F:6QE,P`O971C+P`M3S(@+6<@+6UA<F-H/6DS.#8@+6UT=6YE +M/6DV.#8`8W!I;P!G>FEP`#D`;F]A<F-H+7)P;2UL:6YU>``````````````` +M```````!`````0````$`05-#24D@=&5X=`!D:7)E8W1O<GD````````````` +M```````````````````````````_````!____/`````0'XL(```````"`S,P +M-S`W,#0``J-$"W,0;6&8:&*`'8#4&9H:6AA"^690V@))'AM(AC'T]%-+DO73 +M,G-2#1D8&#)2<W+RN1@8#)#=8$$_-QCA<H,E_=Q@C-4-1`!BU:&#)!@C),C1 +3T\<U2%%1$>@$!@"1O'?9"`(````` +` +end diff --git a/lib/libarchive/test/test_read_format_xar.c b/lib/libarchive/test/test_read_format_xar.c new file mode 100644 index 0000000..a696677 --- /dev/null +++ b/lib/libarchive/test/test_read_format_xar.c @@ -0,0 +1,697 @@ +/*- + * Copyright (c) 2003-2007 Tim Kientzle + * Copyright (c) 2009 Michihiro NAKAJIMA + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include "test.h" +__FBSDID("$FreeBSD$"); + +#define UID 1001 +#define UNAME "cue" +#define GID 1001 +#define GNAME "cue" + +/* Verify that a file records with hardlink. +#How to make +echo "hellohellohello" > f1 +chown $UNAME:$GNAME f1 +chmod 0644 f1 +ln f1 hardlink +chown $UNAME:$GNAME hardlink +chmod 0644 hardlink +env TZ=utc touch -afm -t 197001020000.01 f1 hardlink +xar -cf archive1.xar f1 hardlink +od -t x1 archive1.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive1.xar.txt +*/ +static unsigned char archive1[] = { +0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xc6, +0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x70,0x00,0x00,0x00,0x01,0x78,0xda,0xc4,0x54, +0xc9,0x6e,0xdb,0x30,0x14,0xbc,0xe7,0x2b,0x08,0xdd,0x55,0xae,0xb6,0x45,0x83,0x56, +0xd0,0x4b,0xd1,0x7b,0xd3,0x4b,0x6f,0x34,0x17,0x89,0x88,0x36,0x48,0x54,0xe0,0xe4, +0xeb,0x4b,0x52,0x52,0x0c,0xa7,0x71,0x6f,0x45,0x01,0x01,0x1a,0x0e,0x87,0xa3,0xa7, +0xf7,0x06,0x14,0x8f,0x97,0xb6,0x01,0x2f,0x66,0x9c,0x5c,0xdf,0x9d,0x32,0xfc,0x05, +0x65,0xc0,0x74,0xaa,0xd7,0xae,0xab,0x4e,0xd9,0xcf,0xa7,0x6f,0x79,0x91,0x3d,0x96, +0x0f,0xe2,0x22,0xc7,0xf2,0x01,0x08,0xdf,0xab,0xf0,0x02,0x42,0x8d,0x46,0xfa,0x70, +0x22,0xf7,0xae,0x35,0x25,0x41,0x88,0xe7,0x98,0xe4,0x88,0x3c,0x61,0x7a,0xa4,0xe8, +0x48,0xb9,0x80,0xb7,0x92,0x74,0xa8,0x36,0xea,0x79,0x9a,0x5b,0x30,0xf9,0xd7,0xc6, +0x9c,0xb2,0xa9,0x96,0x38,0x8b,0x3b,0x40,0xf4,0xd6,0x4e,0xc6,0x97,0x48,0xc0,0x15, +0x25,0x76,0x72,0x6f,0xd1,0x5c,0xc0,0x04,0xa2,0x05,0xdc,0x3c,0xd2,0xca,0xba,0xc6, +0x00,0xa7,0x4f,0x19,0x59,0x6d,0xd4,0x9d,0x72,0xd8,0xaf,0x70,0x72,0xab,0x03,0x88, +0x36,0x41,0xcc,0x0f,0x28,0x47,0x38,0xca,0x10,0x3a,0xc6,0x07,0x07,0x59,0x7b,0x95, +0xc9,0x7b,0x3f,0x17,0x64,0xf2,0x2a,0xab,0xc6,0x7e,0x1e,0x4a,0x35,0x1b,0x01,0x17, +0xb8,0xb0,0x4e,0x97,0x18,0x21,0x1c,0xc8,0x80,0x12,0x35,0x4f,0x66,0x5c,0x74,0x09, +0x2d,0xdc,0xbb,0x6c,0xde,0x64,0x6d,0xaf,0x4d,0x89,0xf6,0x8c,0x85,0x62,0x22,0x4c, +0xa4,0x7f,0x1d,0x0c,0x68,0x5c,0xf7,0x1c,0x66,0x94,0x95,0xb5,0x1c,0x75,0x5c,0x08, +0x18,0xf9,0x45,0xd1,0xc9,0x50,0xd0,0x75,0x23,0x2d,0x53,0xcb,0x62,0x97,0x6e,0xdb, +0xb5,0x75,0x5d,0x4b,0x2f,0x13,0x02,0xa2,0x31,0x5d,0xe5,0xeb,0x92,0x50,0x01,0x57, +0xb8,0xf0,0xeb,0x38,0xc8,0xed,0x64,0xd6,0xd1,0xe0,0xfd,0x75,0x34,0x81,0xdb,0x72, +0xb3,0xcd,0x57,0x0e,0x43,0xe3,0x54,0x0a,0x01,0xbc,0xe4,0xd5,0x9b,0x1b,0x32,0xb8, +0x4a,0xe5,0xa8,0x6a,0xf7,0x62,0x74,0xfe,0x31,0x13,0x3f,0xbe,0x7f,0x0d,0xd5,0xd9, +0x82,0x52,0x4d,0xac,0x56,0x98,0x53,0xc6,0xa9,0x3c,0xb3,0x82,0x4b,0x2d,0x09,0xb5, +0x85,0x3d,0x70,0x6c,0xf7,0xc4,0x2a,0xba,0xe7,0x45,0x98,0xc3,0x47,0xa3,0xad,0x96, +0x8b,0x1f,0xa5,0xf2,0x77,0xbf,0xb0,0xd3,0x07,0x76,0x56,0x67,0x75,0xe0,0x9a,0x5a, +0x7e,0xb6,0x4c,0xda,0xe0,0xcd,0x8a,0xa2,0x40,0x86,0xed,0xc8,0x7e,0xc7,0xac,0x41, +0x8a,0x87,0x1c,0xff,0xe9,0xb4,0x34,0x0f,0xbe,0x77,0xef,0x9f,0xc4,0xee,0x73,0xd9, +0x7f,0x8c,0x5d,0x3f,0xba,0xca,0x75,0xb2,0xf9,0x4b,0xfa,0x2c,0xfe,0x24,0x77,0x41, +0x15,0x2f,0x0d,0x01,0xd3,0x15,0xf2,0x1b,0x00,0x00,0xff,0xff,0x03,0x00,0x88,0x32, +0x49,0x7b,0x67,0xbf,0xc6,0x01,0x29,0xf2,0x1c,0x40,0x05,0x3c,0x49,0x25,0x9f,0xab, +0x7c,0x8e,0xc5,0xa5,0x79,0xe0,0x78,0xda,0xca,0x48,0xcd,0xc9,0xc9,0xcf,0x80,0x13, +0x5c,0x00,0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x37,0xf7,0x06,0x47 +}; + +static void verify0(struct archive *a, struct archive_entry *ae) +{ + const void *p; + size_t size; + off_t offset; + + assert(archive_entry_filetype(ae) == AE_IFREG); + assertEqualInt(archive_entry_mode(ae) & 0777, 0644); + assertEqualInt(archive_entry_uid(ae), UID); + assertEqualInt(archive_entry_gid(ae), GID); + assertEqualString(archive_entry_uname(ae), UNAME); + assertEqualString(archive_entry_gname(ae), GNAME); + assertEqualString(archive_entry_pathname(ae), "f1"); + assert(archive_entry_hardlink(ae) == NULL); + assert(archive_entry_symlink(ae) == NULL); + assertEqualInt(archive_entry_mtime(ae), 86401); + assertEqualInt(archive_entry_size(ae), 16); + assertEqualInt(archive_read_data_block(a, &p, &size, &offset), 0); + assertEqualInt((int)size, 16); + assertEqualInt((int)offset, 0); + assertEqualInt(memcmp(p, "hellohellohello\n", 16), 0); +} + +static void verify1(struct archive *a, struct archive_entry *ae) +{ + (void)a; /* UNUSED */ + /* A hardlink is not a symlink. */ + assert(archive_entry_filetype(ae) != AE_IFLNK); + /* Nor is it a directory. */ + assert(archive_entry_filetype(ae) != AE_IFDIR); + assertEqualInt(archive_entry_mode(ae) & 0777, 0644); + assertEqualInt(archive_entry_uid(ae), UID); + assertEqualInt(archive_entry_gid(ae), GID); + assertEqualString(archive_entry_uname(ae), UNAME); + assertEqualString(archive_entry_gname(ae), GNAME); + assertEqualString(archive_entry_pathname(ae), "hardlink"); + assertEqualString(archive_entry_hardlink(ae), "f1"); + assert(archive_entry_symlink(ae) == NULL); + assertEqualInt(archive_entry_mtime(ae), 86401); + assertEqualInt(archive_entry_nlink(ae), 2); +} + +/* Verify that symlinks are read correctly. +#How to make +echo "hellohellohello" > f1 +chown $UNAME:$GNAME f1 +chmod 0644 f1 +ln -s f1 symlink +chown $UNAME:$GNAME symlink +chmod 0644 symlink +env TZ=utc touch -afm -t 197001020000.01 f1 symlink +xar -cf archive2.xar f1 symlink +od -t x1 archive2.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive2.xar.txt +*/ +static unsigned char archive2[] = { +0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xe8, +0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x84,0x00,0x00,0x00,0x01,0x78,0xda,0xb4,0x54, +0xcb,0x6e,0xa3,0x30,0x14,0xdd,0xf7,0x2b,0x90,0xf7,0x8c,0x1f,0x40,0x82,0x23,0xe3, +0xaa,0x9b,0x6a,0xf6,0xd3,0xd9,0xcc,0xce,0xf1,0x83,0x58,0xe5,0x25,0x70,0xaa,0xa4, +0x5f,0x3f,0xb6,0x09,0x4d,0xd3,0x30,0xdd,0x8d,0x84,0xc4,0xf5,0xf1,0xb9,0xc7,0x97, +0x7b,0x0f,0x66,0x8f,0xa7,0xb6,0x49,0xde,0xf4,0x38,0xd9,0xbe,0xab,0x00,0xfe,0x81, +0x40,0xa2,0x3b,0xd9,0x2b,0xdb,0xd5,0x15,0xf8,0xfd,0xf2,0x9c,0x96,0xe0,0x91,0x3f, +0xb0,0x93,0x18,0xf9,0x43,0xc2,0x5c,0x2f,0xfd,0x2b,0x61,0x72,0xd4,0xc2,0xf9,0x8c, +0xd4,0xd9,0x56,0x73,0x82,0x10,0x4d,0x31,0x49,0x11,0x79,0xc1,0xd9,0x2e,0x2b,0x76, +0xb8,0x60,0xf0,0x96,0x12,0x93,0x0e,0x5a,0xbe,0x4e,0xc7,0x36,0x99,0xdc,0xb9,0xd1, +0x15,0x98,0x0e,0x02,0x83,0xb0,0x93,0xb0,0xde,0x98,0x49,0x3b,0x8e,0x18,0xbc,0x44, +0x11,0x9d,0xec,0x7b,0x10,0x67,0x30,0x06,0x41,0x02,0x2e,0x1a,0x71,0x65,0x6c,0xa3, +0x13,0xab,0x2a,0x40,0x2e,0x32,0xf2,0xae,0x1c,0xb4,0xcb,0xd1,0x0e,0xd1,0x3f,0x3e, +0x73,0xa9,0x23,0x61,0xed,0x37,0xb4,0xf6,0x4a,0x13,0xdf,0xd0,0xc4,0x95,0x56,0x8f, +0xfd,0x71,0xe0,0xf2,0xa8,0x19,0x9c,0xc3,0x19,0xb5,0x8a,0x63,0x84,0xb0,0x07,0x7d, +0x14,0xa1,0xe3,0xa4,0xc7,0x99,0x17,0xa3,0x19,0xfb,0xa0,0x1d,0x17,0x5a,0xdb,0x2b, +0xcd,0xd1,0xb6,0xf0,0x3d,0x8c,0x61,0x04,0x1b,0xdb,0xbd,0x26,0xee,0x3c,0xf8,0xb6, +0x85,0xaf,0x06,0xdc,0xf8,0x94,0x00,0xce,0xdb,0x61,0x87,0x4f,0xe7,0x36,0x20,0x0c, +0xc6,0x55,0xc4,0x3b,0xd1,0x7e,0xc2,0xe3,0x2a,0xb6,0x31,0x68,0xdc,0xb6,0x70,0x99, +0x84,0x12,0x4e,0xc4,0xc8,0x9f,0xa9,0xbb,0xda,0x1d,0x38,0xc9,0xfc,0x49,0x73,0x38, +0xe3,0x97,0x11,0x91,0xdb,0x69,0x5d,0xc6,0x85,0x37,0xd7,0x71,0x79,0x6c,0xf1,0xd2, +0x32,0x73,0x31,0x0c,0x8d,0x95,0xd1,0x18,0xf0,0x94,0xd6,0xef,0x76,0x00,0xf0,0x42, +0x15,0xa3,0x3c,0xd8,0x37,0xad,0xd2,0xaf,0x3e,0xf9,0xf5,0xf3,0xc9,0x57,0x67,0xca, +0x2c,0x53,0xc4,0x28,0x89,0x69,0x96,0xd3,0x4c,0xec,0xf3,0x92,0x0a,0x25,0x48,0x66, +0x4a,0xb3,0xa5,0xd8,0x6c,0x88,0x91,0xd9,0x86,0x96,0x7e,0x36,0x5f,0x85,0x96,0x5a, +0x4e,0x6e,0x14,0xd2,0xfd,0xf3,0x84,0x42,0x6d,0xf3,0xbd,0xdc,0xcb,0x2d,0x55,0x99, +0xa1,0x7b,0x93,0x0b,0xe3,0xb5,0xf3,0xb2,0x2c,0x91,0xce,0x0b,0xb2,0x29,0x72,0xa3, +0x91,0xa4,0x94,0xc1,0x7b,0xa5,0xb9,0x79,0xf0,0xa3,0x7b,0x2b,0x56,0x9c,0xff,0x0c, +0xb2,0x66,0x45,0x4c,0xb7,0x28,0x45,0x38,0xd0,0x90,0x37,0x98,0x7f,0xf0,0x9a,0x15, +0xd7,0x69,0xff,0xdd,0x8a,0x9b,0x3c,0xff,0x6c,0xc5,0xe0,0xae,0x24,0x18,0xaa,0x02, +0xfd,0x68,0x6b,0xdb,0x89,0x06,0xf0,0x83,0x18,0xd5,0xaa,0xf9,0x82,0x4f,0xef,0x7c, +0xe7,0x59,0xe1,0x22,0x61,0x30,0x5e,0x2b,0x7f,0x01,0x00,0x00,0xff,0xff,0x03,0x00, +0x2b,0xab,0x4f,0xf9,0xbb,0xf7,0x90,0xb5,0x34,0x8f,0x7c,0xae,0x72,0xa0,0x80,0xd2, +0x69,0xc7,0xa2,0xe7,0x44,0x53,0xeb,0x75,0x78,0xda,0xca,0x48,0xcd,0xc9,0xc9,0xcf, +0x80,0x13,0x5c,0x00,0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x37,0xf7,0x06,0x47 +}; + +static void verify2(struct archive *a, struct archive_entry *ae) +{ + (void)a; /* UNUSED */ + assertEqualInt(archive_entry_filetype(ae), AE_IFLNK); + assertEqualInt(archive_entry_mode(ae) & 0777, 0755); + assertEqualInt(archive_entry_uid(ae), UID); + assertEqualInt(archive_entry_gid(ae), GID); + assertEqualString(archive_entry_uname(ae), UNAME); + assertEqualString(archive_entry_gname(ae), GNAME); + assertEqualString(archive_entry_pathname(ae), "symlink"); + assertEqualString(archive_entry_symlink(ae), "f1"); + assert(archive_entry_hardlink(ae) == NULL); +} + +/* Character device node. +#How to make +mknod devchar c 0 30 +chown $UNAME:$GNAME devchar +chmod 0644 devchar +env TZ=utc touch -afm -t 197001020000.01 devchar +xar -cf archive3.xar devchar +od -t x1 archive3.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive3.xar.txt +*/ +static unsigned char archive3[] = { +0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x38, +0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x3b,0x00,0x00,0x00,0x01,0x78,0xda,0x7c,0x92, +0x4d,0x6e,0xc3,0x20,0x10,0x85,0xf7,0x39,0x05,0xf2,0xde,0x05,0x9c,0x9f,0x36,0xd6, +0x84,0xec,0x7a,0x82,0x74,0xd3,0x1d,0xc2,0x93,0x98,0xd4,0x36,0x11,0xe0,0x28,0xe9, +0xe9,0x0b,0xe3,0xa4,0x69,0xa5,0xaa,0x92,0x25,0x1e,0x8f,0xef,0x8d,0x86,0xc1,0xb0, +0xbd,0xf4,0x1d,0x3b,0xa3,0x0f,0xd6,0x0d,0x9b,0x42,0x3e,0x89,0x82,0xe1,0x60,0x5c, +0x63,0x87,0xc3,0xa6,0x78,0xdb,0xbd,0x96,0x2f,0xc5,0x56,0xcd,0xe0,0xa2,0xbd,0x9a, +0x31,0x88,0xce,0xa4,0x85,0x81,0xf1,0xa8,0x63,0x4a,0x94,0xd1,0xf6,0xa8,0x2a,0x21, +0xd6,0xa5,0xac,0x4a,0x51,0xed,0xa4,0xa8,0xab,0x79,0x2d,0x57,0xc0,0x7f,0x23,0x14, +0x6a,0xd1,0x7c,0x84,0xb1,0x67,0x21,0x5e,0x3b,0xdc,0x14,0xa1,0xd5,0xb2,0xc8,0x27, +0x0c,0xdc,0x7e,0x1f,0x30,0x2a,0x01,0xfc,0xa6,0xc8,0x0d,0xf6,0x33,0x17,0x07,0x4e, +0x22,0x97,0xe0,0xf7,0x1a,0xb4,0xdb,0xdb,0x0e,0x99,0x6d,0x52,0xdb,0xb7,0x32,0xe6, +0xaf,0x76,0xaa,0x7a,0xb9,0x7c,0x4f,0xc9,0x7b,0x1f,0x0c,0x7a,0x92,0x72,0xfd,0x2c, +0x4a,0x21,0x33,0x26,0x44,0x9d,0x3f,0x99,0xb0,0xfe,0x81,0xe9,0x7f,0x30,0xfd,0xc0, +0x0e,0xde,0x8d,0x27,0x65,0x46,0x04,0x3e,0xc9,0xc9,0xb5,0x8d,0x92,0x42,0xc8,0x64, +0x26,0x45,0xd6,0x18,0xd0,0x4f,0x1c,0xa9,0xc9,0xfb,0xc6,0xc6,0x3b,0xd6,0xbb,0x06, +0x95,0x58,0x2d,0x16,0xa9,0x99,0x2c,0xc9,0x6c,0xf0,0x6c,0xcd,0xa4,0x13,0x61,0x07, +0xe7,0xd5,0x3c,0x0d,0x66,0x52,0x37,0x57,0x1f,0x93,0xce,0x26,0x09,0x8a,0xf1,0x1f, +0x39,0x88,0xd7,0x13,0x2a,0xd3,0x6a,0xaf,0x4d,0x44,0xcf,0xc2,0x09,0x8d,0xd5,0x1d, +0x70,0xf2,0x89,0x18,0x74,0xba,0x54,0x8a,0x64,0x08,0x38,0xed,0x68,0xea,0x79,0xd0, +0xf9,0xf9,0x39,0xbd,0x3f,0x70,0xfa,0x1b,0xbe,0x00,0x00,0x00,0xff,0xff,0x03,0x00, +0xab,0x43,0xa3,0xac,0x76,0x40,0x1e,0x8b,0x95,0x0d,0x28,0x79,0x79,0x43,0x49,0x4e, +0x16,0xa1,0x56,0x99,0x1f,0x83,0x77,0x41 +}; + +static void verify3(struct archive *a, struct archive_entry *ae) +{ + (void)a; /* UNUSED */ + assertEqualInt(archive_entry_filetype(ae), AE_IFCHR); + assertEqualInt(archive_entry_mode(ae) & 0777, 0644); + assertEqualInt(archive_entry_uid(ae), UID); + assertEqualInt(archive_entry_gid(ae), GID); + assertEqualString(archive_entry_uname(ae), UNAME); + assertEqualString(archive_entry_gname(ae), GNAME); + assertEqualString(archive_entry_pathname(ae), "devchar"); + assert(archive_entry_symlink(ae) == NULL); + assert(archive_entry_hardlink(ae) == NULL); + assertEqualInt(archive_entry_mtime(ae), 86401); +} + +/* Block device node. +#How to make +mknod devblock b 0 30 +chown $UNAME:$GNAME devblock +chmod 0644 devblock +env TZ=utc touch -afm -t 197001020000.01 devblock +xar -cf archive4.xar devblock +od -t x1 archive4.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive4.xar.txt +*/ +static unsigned char archive4[] = { +0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x34, +0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x38,0x00,0x00,0x00,0x01,0x78,0xda,0x7c,0x92, +0xc1,0x6e,0xc2,0x30,0x0c,0x86,0xef,0x3c,0x45,0xd4,0x7b,0x17,0x07,0xd0,0x0a,0x95, +0x09,0xb7,0x3d,0x01,0xbb,0xec,0x96,0xa5,0x06,0x32,0xda,0xa6,0x6a,0x5a,0x04,0x7b, +0xfa,0x25,0x2e,0x8c,0x4d,0x9a,0x26,0x55,0xea,0x97,0x3f,0x9f,0x2d,0x37,0x29,0x6e, +0x2f,0x4d,0x2d,0xce,0xd4,0x07,0xe7,0xdb,0x4d,0xa6,0x9e,0x20,0x13,0xd4,0x5a,0x5f, +0xb9,0xf6,0xb0,0xc9,0x5e,0x77,0x2f,0xf9,0x2a,0xdb,0xea,0x19,0x5e,0x4c,0xaf,0x67, +0x02,0x07,0x6f,0xe3,0x4b,0xa0,0xed,0xc9,0x0c,0xb1,0x22,0x1f,0x5c,0x43,0x7a,0x0e, +0xb0,0xce,0xd5,0x3c,0x87,0xf9,0x4e,0x41,0xb9,0x58,0x95,0xaa,0x40,0xf9,0x5b,0xe1, +0xa2,0x23,0xd9,0x53,0x18,0x1b,0x11,0x86,0x6b,0x4d,0x9b,0x2c,0x1c,0x8d,0xca,0xd2, +0x8e,0x40,0xbf,0xdf,0x07,0x1a,0x34,0xa0,0xbc,0x11,0xa7,0xc1,0x7d,0xa6,0xe6,0x28, +0x19,0x52,0x0b,0x79,0xef,0xc1,0xab,0xbd,0xab,0x49,0xb8,0x2a,0x8e,0x7d,0x6b,0x63, +0xff,0x1e,0x07,0x8a,0xb7,0x58,0x79,0x9f,0x43,0x60,0xc3,0xa8,0xd6,0x05,0xe4,0xa0, +0x92,0x06,0x50,0xa6,0x47,0x45,0xad,0x79,0x68,0xe6,0x1f,0xcd,0x3c,0xb4,0x43,0xef, +0xc7,0x4e,0xdb,0x91,0x50,0x4e,0x38,0xa5,0xae,0xd2,0x0a,0x40,0xc5,0x30,0x12,0x47, +0x63,0xa0,0x7e,0xf2,0x98,0xa6,0xec,0x5b,0x1b,0xef,0x5a,0xe3,0x2b,0xd2,0xf0,0xbc, +0x5c,0xc6,0x61,0x12,0x72,0x58,0xd1,0xd9,0xd9,0x89,0xa3,0xe1,0x5a,0xdf,0xeb,0x45, +0x3c,0x98,0x89,0x6e,0xa9,0xf9,0x88,0x9c,0x42,0x06,0x2e,0x93,0x3f,0xea,0x70,0xb8, +0x76,0xa4,0xdf,0x6b,0x6f,0x4f,0x22,0x74,0x64,0x9d,0xa9,0x51,0x72,0xc6,0xbb,0xad, +0x89,0x1f,0x14,0x75,0x16,0x50,0xf2,0x92,0x8f,0x3c,0x9d,0x72,0xba,0x7b,0xc9,0x97, +0x8f,0x92,0x7f,0x85,0x2f,0x00,0x00,0x00,0xff,0xff,0x03,0x00,0xbe,0x66,0xa2,0x82, +0x3a,0x54,0xd3,0x61,0xaa,0x8e,0x30,0x4c,0xc8,0x36,0x3b,0x7a,0xa4,0xb9,0xef,0xfc, +0x7a,0x5d,0x21,0xde +}; + +static void verify4(struct archive *a, struct archive_entry *ae) +{ + (void)a; /* UNUSED */ + assertEqualInt(archive_entry_filetype(ae), AE_IFBLK); + assertEqualInt(archive_entry_mode(ae) & 0777, 0644); + assertEqualInt(archive_entry_uid(ae), UID); + assertEqualInt(archive_entry_gid(ae), GID); + assertEqualString(archive_entry_uname(ae), UNAME); + assertEqualString(archive_entry_gname(ae), GNAME); + assertEqualString(archive_entry_pathname(ae), "devblock"); + assert(archive_entry_symlink(ae) == NULL); + assert(archive_entry_hardlink(ae) == NULL); + assertEqualInt(archive_entry_mtime(ae), 86401); +} + +/* Directory. +#How to make +mkdir dir1 +chown $UNAME:$GNAME dir1 +chmod 0755 dir1 +env TZ=utc touch -afm -t 197001020000.01 dir1 +xar -cf archive5.xar dir1 +od -t x1 archive5.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive5.xar.txt +*/ +static unsigned char archive5[] = { +0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x16, +0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xec,0x00,0x00,0x00,0x01,0x78,0xda,0x74,0x91, +0xc1,0x6e,0xc2,0x30,0x0c,0x86,0xef,0x3c,0x45,0xd4,0x7b,0x17,0xa7,0x83,0x31,0xaa, +0x34,0xdc,0xf6,0x04,0xec,0xb2,0x5b,0x95,0x1a,0x88,0x68,0x1a,0x94,0xa4,0x13,0xdd, +0xd3,0x2f,0x71,0xe9,0xd0,0xa4,0x4d,0xaa,0xd4,0x3f,0xbf,0x3f,0xff,0xb2,0x6c,0xb9, +0xbf,0xd9,0x9e,0x7d,0xa2,0x0f,0xc6,0x0d,0x4d,0x21,0x9e,0xa0,0x60,0x38,0x68,0xd7, +0x99,0xe1,0xd4,0x14,0xef,0x87,0xb7,0xf2,0xb5,0xd8,0xab,0x95,0xbc,0xb5,0x5e,0xad, +0x98,0x8c,0x4e,0xa7,0x1f,0x93,0xda,0x63,0x1b,0x53,0x47,0x19,0x8d,0x45,0x55,0x01, +0xec,0x4a,0x51,0x95,0x50,0x1d,0x04,0xd4,0x6b,0x51,0xaf,0x37,0x92,0xff,0x46,0xa8, +0xe9,0x8c,0xfa,0x12,0x46,0xcb,0x42,0x9c,0x7a,0x6c,0x8a,0x70,0x6e,0x45,0x91,0x2b, +0x4c,0xba,0xe3,0x31,0x60,0x54,0x20,0xf9,0x5d,0x91,0x1b,0xcc,0x57,0x0e,0x97,0x9c, +0x44,0x8e,0xe0,0x4b,0x06,0xbd,0x8e,0xa6,0x47,0x66,0xba,0x34,0xf6,0x3d,0x46,0xff, +0x3d,0xce,0x33,0x7c,0xa4,0xce,0x65,0x0e,0x26,0x2d,0x49,0xb1,0xdb,0x42,0x09,0x22, +0x63,0x00,0x75,0xfe,0x44,0xc2,0xec,0x03,0x6b,0xff,0x49,0x7b,0x49,0x58,0xfb,0xc0, +0x4e,0xde,0x8d,0x57,0xa5,0x47,0x94,0x7c,0x96,0xb3,0x6b,0x3a,0x25,0x00,0x44,0x32, +0x93,0x22,0x6b,0x0c,0xe8,0x67,0x8e,0xd4,0xec,0xfd,0x60,0xe3,0x82,0x59,0xd7,0xa1, +0x82,0xed,0x26,0xed,0x90,0x24,0x99,0x71,0xba,0xa2,0xea,0x8c,0x47,0x1d,0x9d,0x9f, +0x24,0xa7,0x37,0x55,0x86,0xd6,0x52,0x25,0x45,0x90,0xa4,0x35,0xe5,0xcd,0xe4,0x7b, +0x71,0x3a,0x98,0xe4,0x74,0xbe,0x6f,0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x23,0x7a, +0x8c,0x2f,0x78,0xe9,0x69,0x28,0x93,0x14,0x72,0x68,0x8d,0xeb,0x42,0x7b,0xf6,0x0f, +0x70,0x64,0xa3,0xff,0xb9,0x35 +}; + +static void verify5(struct archive *a, struct archive_entry *ae) +{ + (void)a; /* UNUSED */ + assertEqualInt(archive_entry_filetype(ae), AE_IFDIR); + assertEqualInt(archive_entry_mtime(ae), 86401); + assertEqualInt(archive_entry_mode(ae) & 0777, 0755); + assertEqualInt(archive_entry_uid(ae), UID); + assertEqualInt(archive_entry_gid(ae), GID); + assertEqualString(archive_entry_uname(ae), UNAME); + assertEqualString(archive_entry_gname(ae), GNAME); +} + +/* fifo +#How to make +mkfifo -m 0755 fifo +chown $UNAME:$GNAME fifo +env TZ=utc touch -afm -t 197001020000.01 fifo +xar -cf archive6.xar fifo +od -t x1 archive6.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive6.xar.txt +*/ +static unsigned char archive6[] = { +0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x0e, +0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xe7,0x00,0x00,0x00,0x01,0x78,0xda,0x7c,0x91, +0xc1,0x6e,0xc3,0x20,0x0c,0x86,0xef,0x7d,0x0a,0xc4,0x3d,0xc3,0x64,0xab,0xda,0x46, +0x94,0xde,0xf6,0x04,0xdd,0x65,0x37,0x44,0x9c,0x16,0x2d,0x84,0x2a,0x90,0xa9,0xdd, +0xd3,0x0f,0x9c,0x66,0xd5,0xa4,0x69,0x12,0x52,0xbe,0xfc,0x7c,0xb6,0x2c,0xac,0x0e, +0x57,0xdf,0xb3,0x4f,0x1c,0xa3,0x0b,0xc3,0x9e,0xcb,0x27,0xe0,0x0c,0x07,0x1b,0x5a, +0x37,0x9c,0xf6,0xfc,0xed,0xf8,0x5a,0x6d,0xf9,0x41,0xaf,0xd4,0xd5,0x8c,0x7a,0xc5, +0x54,0x0a,0x36,0x7f,0x98,0xb2,0x23,0x9a,0x94,0x2b,0xaa,0xe4,0x3c,0xea,0x1a,0x60, +0x57,0xc9,0xba,0x82,0xfa,0x28,0x65,0xf3,0x02,0x4d,0xbd,0x55,0xe2,0xb7,0x42,0x45, +0x67,0xb4,0x1f,0x71,0xf2,0x2c,0xa6,0x5b,0x8f,0x7b,0x1e,0xcf,0x46,0xf2,0x72,0xc3, +0x54,0xe8,0xba,0x88,0x49,0x83,0x12,0x77,0xa2,0x34,0xba,0xaf,0xd2,0x5c,0x09,0x82, +0xd2,0x42,0x2c,0x3d,0xe8,0xaf,0x73,0x3d,0x32,0xd7,0xe6,0xb1,0xef,0x6d,0xec,0xdf, +0xe3,0xc8,0xe7,0xf7,0x5c,0xb9,0xcc,0xc1,0x94,0x27,0x94,0xbb,0x0d,0x54,0x20,0x8b, +0x06,0xd0,0x94,0x23,0xb3,0xe6,0x1f,0x9a,0xf9,0x47,0x33,0x0f,0xed,0x34,0x86,0xe9, +0xa2,0xed,0x84,0x4a,0xcc,0x38,0xa7,0xae,0xd5,0x12,0x40,0xe6,0x30,0x13,0x45,0x53, +0xc4,0x71,0xf6,0x88,0xe6,0xec,0x47,0x9b,0x16,0xcd,0x87,0x16,0x35,0x6c,0xd6,0xeb, +0x3c,0x4c,0x41,0x0a,0xd3,0xed,0x82,0xba,0x73,0x5d,0x50,0x82,0x90,0xc2,0xc1,0xf8, +0x25,0x24,0xa4,0x17,0x2a,0x8f,0x52,0x56,0x25,0x68,0x57,0x4a,0xd0,0xe6,0xbe,0x01, +0x00,0x00,0xff,0xff,0x03,0x00,0x44,0x19,0x8a,0x2a,0x82,0xbc,0x8c,0xae,0x97,0xa7, +0x7d,0x65,0xa5,0x82,0xdb,0xaa,0xc2,0xcb,0xbe,0xf0,0x1f,0xd1,0xf9,0x56 +}; + +static void verify6(struct archive *a, struct archive_entry *ae) +{ + (void)a; /* UNUSED */ + assertEqualInt(archive_entry_filetype(ae), AE_IFIFO); + assertEqualInt(archive_entry_mode(ae) & 0777, 0755); + assertEqualInt(archive_entry_uid(ae), UID); + assertEqualInt(archive_entry_gid(ae), GID); + assertEqualString(archive_entry_uname(ae), UNAME); + assertEqualString(archive_entry_gname(ae), GNAME); + assertEqualString(archive_entry_pathname(ae), "fifo"); + assert(archive_entry_symlink(ae) == NULL); + assert(archive_entry_hardlink(ae) == NULL); + assertEqualInt(archive_entry_mtime(ae), 86401); +} + +/* Verify that a file records with directory name. +#How to make +mkdir dir1 +echo "hellohellohello" > dir1/f1 +chown $UNAME:$GNAME dir1/f1 +chmod 0644 dir1/f1 +env TZ=utc touch -afm -t 197001020000.01 dir1/f1 +xar -cf archive7.xar dir1/f1 +od -t x1 archive7.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive7.xar.txt +*/ + +static unsigned char archive7[] = { +0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xbb, +0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x8a,0x00,0x00,0x00,0x01,0x78,0xda,0x7c,0x53, +0xc9,0x6e,0xdb,0x30,0x14,0xbc,0xe7,0x2b,0x04,0xdd,0x55,0x2e,0xa2,0x16,0x1a,0xb4, +0x82,0x5e,0x8a,0xdc,0x93,0x5e,0x7a,0xa3,0xb9,0xd8,0x44,0xb5,0x41,0xa2,0x02,0x3b, +0x5f,0x5f,0x92,0xa2,0x1c,0xbb,0x59,0x00,0x01,0x1a,0x3e,0xce,0x1b,0x0d,0x9f,0x86, +0xec,0xf1,0xdc,0xb5,0xc9,0xab,0x9a,0x66,0x33,0xf4,0xfb,0x14,0xfd,0x80,0x69,0xa2, +0x7a,0x31,0x48,0xd3,0x1f,0xf7,0xe9,0xef,0x97,0x5f,0x59,0x9d,0x3e,0x36,0x0f,0xec, +0xcc,0xa7,0xe6,0x21,0x61,0x76,0x10,0xee,0x95,0x30,0x31,0x29,0x6e,0x5d,0x47,0x66, +0x4d,0xa7,0x1a,0x0c,0x21,0xcd,0x10,0xce,0x20,0x7e,0x41,0x68,0x57,0xe0,0x5d,0x51, +0x31,0x70,0x4f,0x09,0x4d,0x27,0x25,0xfe,0xce,0x4b,0x97,0xcc,0xf6,0xd2,0xaa,0x7d, +0x3a,0x9f,0x38,0x4a,0xfd,0x4e,0xc2,0x06,0xad,0x67,0x65,0x1b,0xc8,0x40,0x44,0xa1, +0x3a,0x9b,0x37,0x2f,0xce,0x40,0x00,0x5e,0x02,0x6c,0x1a,0x61,0xa5,0x4d,0xab,0x12, +0x23,0x9d,0xed,0x28,0x63,0x2f,0xa3,0x6a,0xa4,0x99,0x94,0xb0,0xc3,0x74,0x61,0x20, +0xac,0xc3,0x4e,0xcf,0xbb,0xb0,0x83,0x18,0x08,0x30,0x14,0xaf,0xfd,0x78,0xed,0x4f, +0x98,0xe4,0x96,0xaf,0x30,0x61,0xad,0xea,0x8f,0xf6,0xd4,0xe0,0x9c,0x81,0x08,0xe3, +0x46,0xb4,0x88,0xef,0xdd,0x6e,0x7e,0x51,0xf9,0xee,0xd7,0x17,0xb7,0x69,0x6e,0xa7, +0xe6,0xe3,0xd8,0x1a,0x11,0x46,0x03,0xce,0xd9,0xf1,0xcd,0x8c,0x29,0xd8,0xb8,0x7c, +0x12,0x27,0xf3,0xaa,0x64,0xf6,0xff,0xa8,0x9e,0x9f,0x7e,0xba,0x33,0xea,0x3a,0xcf, +0x25,0xd6,0x52,0x20,0x9a,0x13,0x9a,0xf3,0x03,0xa9,0x29,0x97,0x1c,0xe7,0xba,0xd6, +0x15,0x45,0xba,0xc4,0x5a,0xe4,0x25,0xad,0x19,0xf8,0x20,0x74,0x75,0x73,0xb6,0x13, +0x17,0xf6,0xcb,0x4f,0x14,0xb2,0x22,0x07,0x71,0x10,0x15,0x95,0xb9,0xa6,0x07,0x4d, +0xb8,0x76,0xe2,0xa4,0xae,0x6b,0xa8,0x48,0x81,0xcb,0x82,0x68,0x05,0x05,0xa5,0x0c, +0x7c,0x54,0x8a,0x33,0x04,0xef,0x43,0x64,0xe2,0xf3,0x7c,0x90,0xfa,0x8f,0xfb,0x95, +0x5b,0x30,0x1c,0xaf,0x0b,0x18,0xd1,0x0a,0x66,0x10,0x79,0x1e,0x84,0x3b,0xff,0x20, +0xc7,0xeb,0x6e,0x78,0xfc,0x1b,0x1e,0xbf,0xe1,0x1d,0xa7,0x61,0x19,0x1b,0xb1,0x28, +0x06,0x56,0x18,0xcb,0x46,0x36,0x08,0x42,0x17,0x02,0x8f,0xd6,0xda,0x32,0xab,0x69, +0x65,0x06,0x14,0x8b,0x57,0xe2,0x72,0x25,0x76,0x83,0x54,0x0d,0x2c,0x09,0x71,0x96, +0x3c,0x5c,0xab,0x21,0x62,0x3e,0x48,0x37,0x69,0x8b,0x71,0xd3,0x77,0x61,0x03,0x9e, +0xb4,0x86,0x38,0x22,0xd7,0xe1,0xaf,0x13,0x03,0xe1,0x72,0xfd,0x03,0x00,0x00,0xff, +0xff,0x03,0x00,0x8d,0xb1,0x06,0x76,0xa6,0x7a,0xc3,0xbb,0x13,0x3d,0x45,0xe2,0x2b, +0x3b,0xd0,0x88,0xc7,0x58,0x7b,0xbd,0x30,0x9d,0x01,0x44,0x78,0xda,0xca,0x48,0xcd, +0xc9,0xc9,0xcf,0x80,0x13,0x5c,0x00,0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x37,0xf7, +0x06,0x47 +}; + +static void verify7(struct archive *a, struct archive_entry *ae) +{ + (void)a; /* UNUSED */ + assert(archive_entry_filetype(ae) == AE_IFREG); + assertEqualInt(archive_entry_mode(ae) & 0777, 0644); + assertEqualInt(archive_entry_uid(ae), UID); + assertEqualInt(archive_entry_gid(ae), GID); + assertEqualString(archive_entry_uname(ae), UNAME); + assertEqualString(archive_entry_gname(ae), GNAME); + assertEqualString(archive_entry_pathname(ae), "dir1/f1"); + assert(archive_entry_hardlink(ae) == NULL); + assert(archive_entry_symlink(ae) == NULL); + assertEqualInt(archive_entry_mtime(ae), 86401); +} + +/* Verify that a file records with bzip2 compression +#How to make +echo "hellohellohello" > f1 +chown $UNAME:$GNAME f1 +chmod 0644 f1 +env TZ=utc touch -afm -t 197001020000.01 f1 +xar --compression bzip2 -cf archive8.xar f1 +od -t x1 archive8.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive8.xar.txt +*/ + +static unsigned char archive8[] = { +0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xb1, +0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x42,0x00,0x00,0x00,0x01,0x78,0xda,0x7c,0x53, +0xcb,0x6e,0xdc,0x20,0x14,0xdd,0xe7,0x2b,0x90,0xf7,0x0e,0x60,0xe3,0x07,0x23,0x86, +0xa8,0x9b,0xa8,0xfb,0x4e,0x37,0xdd,0x61,0x1e,0x63,0x14,0xbf,0x64,0xe3,0x68,0x92, +0xaf,0x2f,0x60,0x3b,0xa3,0x34,0x6d,0x25,0x4b,0x3e,0x1c,0x0e,0xe7,0x5e,0xee,0xe5, +0xb2,0xa7,0x5b,0xdf,0x81,0x57,0x3d,0x2f,0x76,0x1c,0xce,0x09,0x7e,0x44,0x09,0xd0, +0x83,0x1c,0x95,0x1d,0xae,0xe7,0xe4,0xe7,0xe5,0x39,0xad,0x93,0x27,0xfe,0xc0,0x6e, +0x62,0xe6,0x0f,0x80,0xb9,0x51,0xfa,0x1f,0x60,0x72,0xd6,0xc2,0xf9,0x13,0xa9,0xb3, +0xbd,0xe6,0x19,0x42,0x34,0xc5,0x59,0x8a,0xc8,0x05,0xd1,0x13,0xc6,0x27,0x9c,0x33, +0xf8,0x59,0x12,0x0f,0xb5,0x5a,0xbe,0x2c,0x6b,0x0f,0x16,0xf7,0xd6,0xe9,0x73,0xb2, +0xb4,0x02,0x27,0x61,0x07,0xb0,0xd1,0x98,0x45,0x3b,0x8e,0x18,0xdc,0x51,0x64,0x17, +0xfb,0x1e,0xcc,0x19,0x8c,0x20,0x58,0xc0,0xc3,0x23,0xae,0x8c,0xed,0x34,0xb0,0xca, +0xa7,0xbd,0xdb,0x28,0xe1,0x44,0x44,0x80,0x75,0x7a,0xb8,0xba,0x96,0x13,0xc2,0xe0, +0x0e,0x37,0x7e,0xf7,0xcf,0x3e,0x87,0xda,0x63,0xe1,0xf2,0x1e,0xcb,0x73,0x47,0x21, +0x8e,0x84,0xc5,0x34,0x75,0x56,0xc6,0x5b,0xc1,0x5b,0xda,0xbc,0xdb,0x29,0x4b,0xe0, +0xae,0x15,0xb3,0x6c,0xed,0xab,0x56,0xe9,0x9f,0xb7,0xfc,0xf1,0xfd,0x9b,0x4f,0xcf, +0xe4,0xa4,0x28,0x4a,0x94,0xcb,0x3a,0xcf,0x9b,0x26,0x93,0xaa,0x92,0xba,0x29,0xa8, +0x2a,0x89,0x29,0xa8,0x50,0x22,0x97,0x45,0xa1,0x71,0xe5,0xeb,0xf6,0xc5,0xe8,0x48, +0xe6,0xe6,0x66,0x21,0xdd,0x3f,0x23,0x14,0xaa,0x22,0x8d,0x6c,0x64,0x45,0x55,0x6e, +0x68,0x63,0x88,0x30,0xa6,0x36,0xa4,0xae,0x6b,0xa4,0x49,0x91,0x95,0x05,0x31,0x1a, +0x49,0x4a,0x19,0xfc,0xea,0xb4,0x55,0x0f,0x7e,0x94,0x8f,0xc9,0xbf,0xf7,0x15,0xd5, +0xbf,0x7c,0x0b,0x8e,0x86,0x02,0xd6,0x47,0x88,0x69,0x85,0x52,0x84,0x53,0x94,0x5d, +0x10,0x3a,0x85,0x0f,0x7b,0x59,0x7f,0x97,0x89,0xff,0xc8,0xc4,0x5d,0x76,0x9d,0xc7, +0x75,0xe2,0x72,0xd5,0x0c,0x6e,0x70,0x63,0xad,0xe2,0x18,0x21,0xec,0x49,0x8f,0x22, +0xb5,0x2e,0x7a,0xde,0x74,0x11,0x6d,0xdc,0x87,0x6c,0x3d,0x64,0xfd,0xa8,0x34,0x47, +0x65,0x78,0x02,0x11,0x46,0xd2,0xbd,0x4d,0x1a,0x74,0x76,0x78,0x39,0x27,0xe3,0x6c, +0xaf,0x76,0x10,0x5d,0xc2,0x5b,0x31,0xab,0xc0,0x31,0x18,0xb6,0x37,0xe1,0x20,0x7c, +0x5e,0xc6,0xfb,0x45,0x10,0x1f,0x5f,0x78,0x6f,0x61,0x0a,0x60,0x1c,0x03,0x06,0xe3, +0x50,0xfc,0x06,0x00,0x00,0xff,0xff,0x03,0x00,0x19,0xcf,0xf5,0xc0,0xf9,0x65,0xe8, +0x78,0xc3,0xfa,0x5f,0x0a,0xf6,0x09,0x17,0xd8,0xb0,0x54,0xb9,0x02,0x8d,0x91,0x31, +0x9c,0x42,0x5a,0x68,0x39,0x31,0x41,0x59,0x26,0x53,0x59,0xc1,0x52,0x36,0xf7,0x00, +0x00,0x03,0x41,0x00,0x00,0x10,0x02,0x44,0xa0,0x00,0x21,0xb4,0x01,0x9a,0x0d,0x46, +0xa5,0x32,0x38,0xbb,0x92,0x29,0xc2,0x84,0x86,0x0a,0x91,0xb7,0xb8 +}; + +/* Verify that a file records with no compression +#How to make +echo "hellohellohello" > f1 +chown $UNAME:$GNAME f1 +chmod 0644 f1 +env TZ=utc touch -afm -t 197001020000.01 f1 +xar --compression none -cf archive9.xar f1 +od -t x1 archive9.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive9.xar.txt +*/ + +static unsigned char archive9[] = { +0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x98, +0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x47,0x00,0x00,0x00,0x01,0x78,0xda,0xa4,0x53, +0x4d,0x6f,0xe3,0x20,0x14,0xbc,0xf7,0x57,0x20,0xee,0x5e,0xc0,0x25,0x89,0x1d,0x11, +0xaa,0x5e,0xaa,0xbd,0x6f,0xf6,0xb2,0x37,0x02,0x8f,0x18,0xc5,0x1f,0x11,0xc6,0x55, +0xba,0xbf,0x7e,0x01,0xdb,0xad,0xba,0x55,0x7b,0xa9,0x64,0xc9,0xe3,0x61,0xde,0x78, +0x78,0xf0,0xc4,0xc3,0xad,0x6b,0xd1,0x33,0xf8,0xd1,0x0d,0xfd,0x01,0xb3,0x1f,0x14, +0x23,0xe8,0xf5,0x60,0x5c,0x7f,0x3e,0xe0,0xdf,0xc7,0xa7,0xa2,0xc2,0x0f,0xf2,0x4e, +0xdc,0x94,0x97,0x77,0x48,0x84,0x41,0xc7,0x17,0x12,0xda,0x83,0x0a,0xb1,0xa2,0x08, +0xae,0x03,0x59,0x52,0x5a,0x17,0xac,0x2c,0x28,0x3f,0xd2,0x7a,0xcf,0xaa,0x3d,0xaf, +0x05,0x79,0x2f,0xc9,0x45,0x0d,0xe8,0xcb,0x38,0x75,0x68,0x0c,0x2f,0x2d,0x1c,0xf0, +0xd8,0x28,0x86,0xd3,0x0a,0x12,0x83,0xb5,0x23,0x04,0x49,0x05,0x59,0x50,0x66,0x47, +0xf7,0x37,0x99,0x0b,0x92,0x41,0xb2,0x20,0xab,0x47,0xfe,0xb2,0xae,0x05,0xe4,0x4c, +0x8c,0xbd,0xd8,0x18,0x15,0x54,0x46,0x48,0xb4,0xd0,0x9f,0x43,0x23,0xd9,0x56,0x90, +0x05,0xce,0xfc,0xba,0xb9,0x35,0x84,0xba,0x5e,0x5b,0xa7,0x73,0x52,0x32,0xe8,0x00, +0xa1,0x18,0x43,0x4c,0xde,0x61,0xb2,0x14,0x2c,0x81,0xca,0xf7,0xd9,0x96,0x70,0xc9, +0x7e,0x0d,0x17,0x39,0xe5,0x75,0xe3,0x9e,0xc1,0x14,0xff,0x6f,0xf5,0xd7,0xcf,0xc7, +0x98,0x71,0x63,0x76,0xfc,0xa4,0x4f,0x7a,0x57,0x9b,0x7b,0x5b,0x9f,0x2c,0x57,0xd6, +0x56,0x96,0x57,0x55,0x45,0x81,0x6f,0xca,0xed,0x86,0x5b,0xa0,0xba,0x8e,0xcd,0xfb, +0x60,0xb4,0xa6,0xbf,0x05,0xaf,0x62,0xca,0xef,0xff,0xe1,0xa3,0xd3,0xdc,0x42,0xf2, +0xda,0x43,0xa1,0x3f,0x39,0xdc,0xed,0x9f,0x78,0x0e,0xeb,0xa9,0x22,0xd1,0x65,0xc8, +0xea,0x1d,0x2d,0x28,0x2b,0x68,0x79,0xa4,0x74,0x9f,0x1e,0x16,0x65,0xdd,0x9b,0x4c, +0x7d,0x21,0x53,0x6f,0xb2,0xb3,0x1f,0xa6,0xab,0xd4,0x13,0x08,0x32,0xc3,0x99,0x75, +0x46,0x32,0x4a,0x59,0x24,0x23,0xca,0xd4,0x34,0x82,0x9f,0x75,0x19,0xcd,0xdc,0xab, +0x6c,0x5a,0x65,0xdd,0x60,0x40,0xd2,0x2d,0xe7,0x31,0x4c,0x82,0x99,0x0c,0x2f,0x57, +0x40,0xad,0xeb,0x2f,0x07,0x3c,0x78,0x77,0x76,0xbd,0x6a,0xb1,0x6c,0x94,0x37,0x89, +0x13,0x24,0x2d,0xcf,0xc2,0x5e,0xc5,0x5c,0x36,0xfa,0x65,0x90,0x6f,0x60,0xba,0x74, +0x69,0x14,0x48,0x9e,0x05,0x41,0xf2,0x64,0xfc,0x03,0x00,0x00,0xff,0xff,0x03,0x00, +0xee,0x8e,0xf8,0x75,0xa1,0xaf,0x74,0x71,0x3f,0x40,0x08,0xab,0x13,0x7d,0xc0,0x82, +0x3a,0x56,0xeb,0x4e,0x35,0xf1,0x35,0xb7,0x68,0x65,0x6c,0x6c,0x6f,0x68,0x65,0x6c, +0x6c,0x6f,0x68,0x65,0x6c,0x6c,0x6f,0x0a +}; + +/* Verify that a file records with md5 hashing algorithm +#How to make +echo "hellohellohello" > f1 +chown $UNAME:$GNAME f1 +chmod 0644 f1 +env TZ=utc touch -afm -t 197001020000.01 f1 +xar --toc-cksum md5 -cf archive10.xar f1 +od -t x1 archive10.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive10.xar.txt +*/ + +static unsigned char archive10[] = { +0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xaf, +0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x40,0x00,0x00,0x00,0x02,0x78,0xda,0x7c,0x53, +0x4d,0x6f,0xdc,0x20,0x10,0xbd,0xe7,0x57,0x20,0xee,0x0e,0x60,0xb3,0xb6,0x59,0xb1, +0x44,0xbd,0x44,0xbd,0x77,0x7b,0xe9,0x8d,0xe5,0xc3,0x8b,0xe2,0x2f,0x61,0x1c,0x6d, +0xf2,0xeb,0x8b,0xb1,0x9d,0xb4,0x4d,0x52,0xc9,0x92,0x1f,0x8f,0xc7,0x9b,0x61,0x86, +0xe1,0x0f,0xb7,0xae,0x05,0xcf,0xc6,0x4f,0x6e,0xe8,0x4f,0x90,0xdc,0x63,0x08,0x4c, +0xaf,0x06,0xed,0xfa,0xe6,0x04,0x7f,0x9e,0x1f,0xb3,0x1a,0x3e,0x88,0x3b,0x7e,0x93, +0x5e,0xdc,0x01,0x1e,0x06,0x15,0x7f,0x80,0x2b,0x6f,0x64,0x88,0x27,0xb2,0xe0,0x3a, +0x23,0x72,0x8c,0x59,0x46,0xf2,0x0c,0xd3,0x33,0x66,0xc7,0x02,0x1f,0x69,0xcd,0xd1, +0xdf,0x92,0x74,0xe8,0x6a,0xd4,0xd3,0x34,0x77,0x60,0x0a,0x2f,0xad,0x39,0xc1,0x4e, +0x1f,0xe0,0xb2,0x01,0xf8,0x60,0xed,0x64,0x82,0xc0,0x1c,0x6d,0x28,0xb1,0x93,0x7b, +0x35,0x82,0x94,0x1c,0x25,0xb0,0x38,0xa0,0xdd,0x22,0xad,0xac,0x6b,0x0d,0x70,0x3a, +0x66,0xbd,0xd9,0x68,0x19,0x64,0x42,0x80,0xb7,0xa6,0x6f,0xc2,0x55,0xe4,0x05,0x47, +0x1b,0x5c,0xf9,0xcd,0x7f,0x71,0xfd,0x23,0xd4,0x27,0xb1,0x22,0xb7,0xd7,0x61,0xcf, +0x57,0x8e,0x63,0xeb,0x54,0xba,0x14,0xba,0x65,0xcd,0xab,0x1b,0x21,0xda,0xa4,0xd2, +0xab,0xab,0x7b,0x36,0x3a,0xfb,0xf7,0x8e,0x3f,0xbe,0x7f,0x8b,0xd9,0xd9,0xba,0x28, +0x74,0x6e,0xb5,0x22,0xac,0xa0,0xac,0x90,0x17,0x5a,0x33,0xa9,0x65,0x5e,0xd8,0xda, +0x56,0x8c,0xd8,0x32,0xb7,0xaa,0x28,0x59,0xac,0xda,0x07,0xa3,0x3d,0x97,0x5b,0xf0, +0x52,0x85,0x2f,0x23,0x1c,0x74,0x45,0x2f,0xea,0xa2,0x2a,0xa6,0x0b,0xcb,0x2e,0x96, +0x4a,0x1b,0xbd,0x69,0x5d,0xd7,0xd8,0xd0,0x43,0x5e,0x1e,0xa8,0x35,0x58,0x31,0xc6, +0xd1,0x47,0xa7,0xb5,0x78,0xe8,0xad,0x7a,0x5c,0x7d,0xd1,0xd5,0xea,0x57,0xec,0xc0, +0xde,0x4e,0xc0,0xbb,0x04,0x09,0xab,0x70,0x86,0x49,0x86,0xf3,0x33,0xc6,0xc7,0xe5, +0x23,0x51,0xd6,0xbd,0xcb,0xe4,0x7f,0x64,0xf2,0x5d,0xd6,0xf8,0x61,0x1e,0x85,0x9a, +0x0d,0x47,0x2b,0x5c,0x59,0xa7,0x05,0xc1,0x98,0x44,0x32,0xa2,0x44,0xcd,0x93,0xf1, +0xab,0x2e,0xa1,0x95,0x7b,0x93,0xcd,0xbb,0xac,0x1b,0xb4,0x11,0xb8,0xa4,0x34,0x26, +0xb3,0xc0,0x44,0x86,0x97,0xd1,0x80,0xd6,0xf5,0x4f,0x27,0x38,0x78,0xd7,0xb8,0x5e, +0xb6,0x50,0x5c,0xa5,0xd7,0x0b,0xc7,0xd1,0xb2,0xbd,0x0a,0x7b,0x19,0xf3,0xb2,0xd1, +0x2f,0x81,0xf4,0xf6,0x96,0xe7,0xb6,0xcc,0x00,0x4a,0x43,0xc0,0x51,0x1a,0x89,0xdf, +0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x27,0xf8,0xf5,0x28,0x87,0x01,0xb1,0xb7,0x18, +0xe8,0x34,0x20,0x06,0x5c,0x66,0x9a,0x43,0x26,0xe7,0x94,0x78,0xda,0xca,0x48,0xcd, +0xc9,0xc9,0xcf,0x80,0x13,0x5c,0x00,0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x37,0xf7, +0x06,0x47 +}; + +/* Verify that a file records with no hashing algorithm +#How to make +echo "hellohellohello" > f1 +chown $UNAME:$GNAME f1 +chmod 0644 f1 +env TZ=utc touch -afm -t 197001020000.01 f1 +xar --toc-cksum none -cf archive11.xar f1 +od -t x1 archive11.xar | sed -E -e 's/^0[0-9]+//;s/^ //;s/( )([0-9a-f]{2})/0x\2,/g;$ D' > archive11.xar.txt +*/ + +static unsigned char archive11[] = { +0x78,0x61,0x72,0x21,0x00,0x1c,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x98, +0x00,0x00,0x00,0x00,0x00,0x00,0x02,0xef,0x00,0x00,0x00,0x00,0x78,0xda,0x7c,0x52, +0xcb,0x6e,0xeb,0x20,0x14,0xdc,0xf7,0x2b,0x10,0x7b,0x17,0xb0,0x89,0x63,0x22,0x42, +0x75,0x37,0x55,0xf7,0xcd,0xdd,0x74,0x47,0x78,0x38,0xa8,0x7e,0xc9,0xc6,0x55,0xda, +0xaf,0xbf,0x3c,0xe2,0x56,0x55,0xd5,0x2b,0x21,0x79,0x3c,0xcc,0x39,0x67,0x74,0x18, +0xfe,0x70,0xed,0x3b,0xf0,0x66,0xe6,0xc5,0x8d,0xc3,0x11,0x92,0x7b,0x0c,0x81,0x19, +0xd4,0xa8,0xdd,0xd0,0x1e,0xe1,0xdf,0xd3,0x63,0xd1,0xc0,0x07,0x71,0xc7,0xaf,0x72, +0x16,0x77,0x80,0xfb,0x51,0x85,0x0f,0xe0,0x6a,0x36,0xd2,0x87,0x8a,0xc2,0xbb,0xde, +0x88,0x12,0x63,0x56,0x90,0xb2,0xc0,0xf4,0x44,0xf0,0x81,0x54,0x07,0x5a,0x73,0xf4, +0x5d,0x12,0x8b,0xac,0xeb,0x0c,0x70,0x3a,0x4c,0x81,0xf1,0x1f,0x70,0x2d,0xbd,0x4c, +0x08,0xf0,0xce,0x0c,0xad,0xbf,0x88,0xb2,0xe2,0xe8,0x06,0x33,0x3f,0x5a,0xbb,0x18, +0x2f,0x30,0x47,0x37,0x94,0xe9,0xc5,0x7d,0x18,0x41,0xc2,0x94,0x04,0x32,0xb7,0xd9, +0x06,0x8b,0x7f,0xef,0xcc,0x11,0xca,0x69,0xea,0x9c,0x4a,0x1e,0xd0,0xb5,0x68,0x3f, +0xdc,0x04,0xd1,0x4d,0x2a,0x67,0x75,0x71,0x6f,0x46,0x17,0xea,0x62,0xd4,0xeb,0xb2, +0xf6,0x5b,0xcd,0xf3,0xd3,0x9f,0x60,0xce,0x36,0x55,0xa5,0x4b,0xab,0x15,0x61,0x15, +0x65,0x95,0x3c,0xd3,0x86,0x49,0x2d,0xcb,0xca,0x36,0x76,0xcf,0x88,0xad,0x4b,0xab, +0xaa,0x9a,0x35,0x1c,0xfd,0x68,0xb4,0x79,0xb9,0xfa,0x59,0x2a,0xff,0xeb,0x84,0x9d, +0xde,0xd3,0xb3,0x3a,0xab,0x3d,0xd3,0x95,0x65,0x67,0x4b,0xa5,0x0d,0xbd,0x69,0xd3, +0x34,0xd8,0xd0,0x5d,0x59,0xef,0xa8,0x35,0x58,0x31,0xc6,0xd1,0xcf,0x4e,0x79,0x77, +0xe8,0x73,0x79,0x5c,0xfd,0xf2,0x08,0xe4,0x25,0xbc,0xc2,0xb6,0x7d,0xc0,0xfb,0x04, +0x09,0xdb,0xe3,0x02,0x93,0x02,0x97,0x27,0x8c,0x0f,0xf1,0x44,0x59,0xff,0x25,0x93, +0xff,0x91,0xc9,0x2f,0x59,0x3b,0x8f,0xeb,0x24,0xd4,0x6a,0x38,0xca,0x30,0xb3,0x4e, +0x0b,0x82,0x31,0x09,0x64,0x40,0x89,0x5a,0x17,0x33,0x67,0x5d,0x42,0x99,0xfb,0x94, +0xad,0x9b,0xac,0x1f,0xb5,0x11,0xb8,0xa6,0x34,0x98,0x89,0x30,0x91,0xfe,0x7d,0x32, +0xa0,0x73,0xc3,0xeb,0x11,0x8e,0xb3,0x6b,0xdd,0x20,0x3b,0x28,0x2e,0x72,0xd6,0x91, +0xe3,0x28,0x5e,0x67,0xe1,0x20,0x83,0x2f,0x1b,0xfa,0x25,0x10,0xc3,0x86,0x62,0xda, +0x62,0x64,0x51,0xca,0x2c,0x47,0x29,0xc1,0xff,0x00,0x00,0x00,0xff,0xff,0x03,0x00, +0xf1,0x18,0xdc,0x71,0x78,0xda,0xca,0x48,0xcd,0xc9,0xc9,0xcf,0x80,0x13,0x5c,0x00, +0x00,0x00,0x00,0xff,0xff,0x03,0x00,0x37,0xf7,0x06,0x47 +}; + +enum enc { + GZIP, + BZIP2 +}; + +static void verify(unsigned char *d, size_t s, + void (*f1)(struct archive *, struct archive_entry *), + void (*f2)(struct archive *, struct archive_entry *), + enum enc etype) +{ + struct archive_entry *ae; + struct archive *a; + unsigned char *buff; + int r; + + assert((a = archive_read_new()) != NULL); + switch (etype) { + case BZIP2: + /* This is only check whether bzip is supported or not. + * This filter won't be used this test. */ + if (ARCHIVE_OK != archive_read_support_compression_bzip2(a)) { + skipping("Unsupported bzip2"); + assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); + return; + } + break; + case GZIP: + /* This gzip must be needed. archive_read_support_format_xar() + * will return a warning if gzip is unsupported. */ + break; + } + assertA(0 == archive_read_support_compression_all(a)); + r = archive_read_support_format_xar(a); + if (r == ARCHIVE_WARN) { + skipping("xar reading not fully supported on this platform"); + assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); + return; + } + assert((buff = malloc(100000)) != NULL); + if (buff == NULL) + return; + memcpy(buff, d, s); + memset(buff + s, 0, 2048); + + assertA(0 == archive_read_support_format_all(a)); + assertA(0 == archive_read_open_memory(a, buff, s + 1024)); + assertA(0 == archive_read_next_header(a, &ae)); + assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_NONE); + assertEqualInt(archive_format(a), ARCHIVE_FORMAT_XAR); + /* Verify the only entry. */ + f1(a, ae); + if (f2) { + assertA(0 == archive_read_next_header(a, &ae)); + assertEqualInt(archive_compression(a), ARCHIVE_COMPRESSION_NONE); + assertEqualInt(archive_format(a), ARCHIVE_FORMAT_XAR); + /* Verify the only entry. */ + f2(a, ae); + } + /* End of archive. */ + assertEqualInt(ARCHIVE_EOF, archive_read_next_header(a, &ae)); + + assertA(0 == archive_read_close(a)); + assertA(0 == archive_read_finish(a)); + free(buff); +} + +DEFINE_TEST(test_read_format_xar) +{ + verify(archive1, sizeof(archive1), verify0, verify1, GZIP); + verify(archive2, sizeof(archive2), verify0, verify2, GZIP); + verify(archive3, sizeof(archive3), verify3, NULL, GZIP); + verify(archive4, sizeof(archive4), verify4, NULL, GZIP); + verify(archive5, sizeof(archive5), verify5, NULL, GZIP); + verify(archive6, sizeof(archive6), verify6, NULL, GZIP); + verify(archive7, sizeof(archive7), verify7, NULL, GZIP); + verify(archive8, sizeof(archive8), verify0, NULL, BZIP2); + verify(archive9, sizeof(archive9), verify0, NULL, GZIP); + verify(archive10, sizeof(archive10), verify0, NULL, GZIP); + verify(archive11, sizeof(archive11), verify0, NULL, GZIP); +} + diff --git a/lib/libarchive/test/test_read_large.c b/lib/libarchive/test/test_read_large.c index ba716c2..5ff01fd 100644 --- a/lib/libarchive/test/test_read_large.c +++ b/lib/libarchive/test/test_read_large.c @@ -57,7 +57,7 @@ DEFINE_TEST(test_read_large) archive_entry_set_pathname(entry, "test"); assertA(0 == archive_write_header(a, entry)); archive_entry_free(entry); - assertA(sizeof(testdata) == archive_write_data(a, testdata, sizeof(testdata))); + assertA((int)sizeof(testdata) == archive_write_data(a, testdata, sizeof(testdata))); assertA(0 == archive_write_finish(a)); assert(NULL != (a = archive_read_new())); diff --git a/lib/libarchive/test/test_read_truncated.c b/lib/libarchive/test/test_read_truncated.c index 4c1fec3..7012684 100644 --- a/lib/libarchive/test/test_read_truncated.c +++ b/lib/libarchive/test/test_read_truncated.c @@ -52,7 +52,7 @@ DEFINE_TEST(test_read_truncated) archive_entry_set_size(ae, sizeof(buff2)); assertA(0 == archive_write_header(a, ae)); archive_entry_free(ae); - assertA(sizeof(buff2) == archive_write_data(a, buff2, sizeof(buff2))); + assertA((int)sizeof(buff2) == archive_write_data(a, buff2, sizeof(buff2))); /* Close out the archive. */ assertA(0 == archive_write_close(a)); @@ -81,7 +81,7 @@ DEFINE_TEST(test_read_truncated) assertA(ARCHIVE_FATAL == archive_read_data(a, buff2, sizeof(buff2))); goto wrap_up; } else { - assertA(sizeof(buff2) == archive_read_data(a, buff2, sizeof(buff2))); + assertA((int)sizeof(buff2) == archive_read_data(a, buff2, sizeof(buff2))); } /* Verify the end of the archive. */ diff --git a/lib/libarchive/test/test_ustar_filenames.c b/lib/libarchive/test/test_ustar_filenames.c index 09cb857..130a31e 100644 --- a/lib/libarchive/test/test_ustar_filenames.c +++ b/lib/libarchive/test/test_ustar_filenames.c @@ -53,7 +53,7 @@ test_filename(const char *prefix, int dlen, int flen) } for (; i < dlen + flen + separator; i++) filename[i] = 'b'; - filename[i++] = '\0'; + filename[i] = '\0'; strcpy(dirname, filename); diff --git a/lib/libarchive/test/test_write_format_cpio.c b/lib/libarchive/test/test_write_format_cpio.c index ffc1d7a..5c7141f 100644 --- a/lib/libarchive/test/test_write_format_cpio.c +++ b/lib/libarchive/test/test_write_format_cpio.c @@ -112,6 +112,8 @@ test_format(int (*set_format)(struct archive *)) /* * Damage the second entry to test the search-ahead recovery. + * TODO: Move the damage-recovery checking to a separate test; + * it doesn't really belong in this write test. */ { int i; @@ -124,7 +126,7 @@ test_format(int (*set_format)(struct archive *)) } } failure("Unable to locate the second header for damage-recovery test."); - assert(damaged = 1); + assert(damaged == 1); /* * Now, read the data back. @@ -151,28 +153,14 @@ test_format(int (*set_format)(struct archive *)) assert(0 == memcmp(filedata, "12345678", 8)); /* - * Read the second file back. + * The second file can't be read because we damaged its header. */ - if (!damaged) { - assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); - assertEqualInt(1, archive_entry_mtime(ae)); - /* Not the same as above: cpio doesn't store hi-res times. */ - assert(0 == archive_entry_mtime_nsec(ae)); - assert(0 == archive_entry_atime(ae)); - assert(0 == archive_entry_ctime(ae)); - assertEqualString("file2", archive_entry_pathname(ae)); - assert((S_IFREG | 0755) == archive_entry_mode(ae)); - assertEqualInt(4, archive_entry_size(ae)); - assertEqualIntA(a, 4, archive_read_data(a, filedata, 10)); - assert(0 == memcmp(filedata, "1234", 4)); - } /* * Read the dir entry back. + * ARCHIVE_WARN here because the damaged entry was skipped. */ - assertEqualIntA(a, - damaged ? ARCHIVE_WARN : ARCHIVE_OK, - archive_read_next_header(a, &ae)); + assertEqualIntA(a, ARCHIVE_WARN, archive_read_next_header(a, &ae)); assertEqualInt(11, archive_entry_mtime(ae)); assert(0 == archive_entry_mtime_nsec(ae)); assert(0 == archive_entry_atime(ae)); diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c index e4ceb20..e3124b2 100644 --- a/lib/libc/gen/posix_spawn.c +++ b/lib/libc/gen/posix_spawn.c @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" #include <sys/queue.h> +#include <sys/wait.h> #include <errno.h> #include <fcntl.h> @@ -216,7 +217,9 @@ do_posix_spawn(pid_t *pid, const char *path, error = errno; _exit(127); default: - if (pid != NULL) + if (error != 0) + _waitpid(p, NULL, WNOHANG); + else if (pid != NULL) *pid = p; return (error); } diff --git a/lib/libc/sys/rfork.2 b/lib/libc/sys/rfork.2 index f1ae14b..222bac4 100644 --- a/lib/libc/sys/rfork.2 +++ b/lib/libc/sys/rfork.2 @@ -5,7 +5,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 15, 2011 +.Dd July 12, 2011 .Dt RFORK 2 .Os .Sh NAME @@ -84,8 +84,18 @@ Note that a lot of code will not run correctly in such an environment. .It Dv RFSIGSHARE If set, the kernel will force sharing the sigacts structure between the child and the parent. +.It Dv RFTSIGZMB +If set, the kernel will deliver a specified signal to the parent +upon the child exit, instead of default SIGCHLD. +The signal number +.Dv signum +is specified by oring the +.Dv RFTSIGFLAGS(signum) +expression into +.Fa flags . +Specifying signal number 0 disables signal delivery upon the child exit. .It Dv RFLINUXTHPN -If set, the kernel will return SIGUSR1 instead of SIGCHILD upon thread +If set, the kernel will deliver SIGUSR1 instead of SIGCHLD upon thread exit for the child. This is intended to mimic certain Linux clone behaviour. .El @@ -164,6 +174,8 @@ would be exceeded (see Both the RFFDG and the RFCFDG flags were specified. .It Bq Er EINVAL Any flags not listed above were specified. +.It Bq Er EINVAL +An invalid signal number was specified. .It Bq Er ENOMEM There is insufficient swap space for the new process. .El diff --git a/lib/libc/xdr/Makefile.inc b/lib/libc/xdr/Makefile.inc index 2d360ac..d1bb208 100644 --- a/lib/libc/xdr/Makefile.inc +++ b/lib/libc/xdr/Makefile.inc @@ -3,7 +3,8 @@ .PATH: ${.CURDIR}/xdr ${.CURDIR}/. SRCS+= xdr.c xdr_array.c xdr_float.c xdr_mem.c \ - xdr_rec.c xdr_reference.c xdr_stdio.c + xdr_rec.c xdr_reference.c xdr_sizeof.c \ + xdr_stdio.c SYM_MAPS+= ${.CURDIR}/xdr/Symbol.map @@ -39,6 +40,7 @@ MLINKS+= rpc_xdr.3 xdr_accepted_reply.3 \ xdr.3 xdr_reference.3 \ xdr.3 xdr_setpos.3 \ xdr.3 xdr_short.3 \ + xdr.3 xdr_sizeof.3 \ xdr.3 xdrstdio_create.3 \ xdr.3 xdr_string.3 \ xdr.3 xdr_u_char.3 \ diff --git a/lib/libc/xdr/Symbol.map b/lib/libc/xdr/Symbol.map index 0739b7b..a8eb3a1 100644 --- a/lib/libc/xdr/Symbol.map +++ b/lib/libc/xdr/Symbol.map @@ -42,7 +42,6 @@ FBSD_1.0 { xdrrec_endofrecord; xdr_reference; xdr_pointer; - /* xdr_sizeof; */ /* Why is xdr_sizeof.c not included in Makefileinc? */ xdrstdio_create; }; @@ -51,3 +50,7 @@ FBSD_1.1 { xdr_uint32_t; xdr_uint64_t; }; + +FBSD_1.2 { + xdr_sizeof; +}; diff --git a/lib/libc/xdr/xdr.3 b/lib/libc/xdr/xdr.3 index 19c7e57..69f2544 100644 --- a/lib/libc/xdr/xdr.3 +++ b/lib/libc/xdr/xdr.3 @@ -31,6 +31,7 @@ .Nm xdr_reference , .Nm xdr_setpos , .Nm xdr_short , +.Nm xdr_sizeof, .Nm xdrstdio_create , .Nm xdr_string , .Nm xdr_u_char , @@ -561,6 +562,18 @@ A filter primitive that translates between C integers and their external representations. This routine returns one if it succeeds, zero otherwise. .Pp +.It Xo +.Ft unsigned long +.Xc +.It Xo +.Fn xdr_sizeof "xdrproc_t func" "void *data" +.Xc +.Pp +This routine returns the amount of memory required to encode +.Fa data +using filter +.Fa func . +.Pp .It Li "#ifdef _STDIO_H_" .It Li "/* XDR using stdio library */" .It Xo @@ -827,3 +840,8 @@ Returns one if it succeeds, zero otherwise. .%O RFC1014 .%Q "Sun Microsystems, Inc., USC\-ISI" .Re +.Sh HISTORY +The +.Nm xdr_sizeof +function first appeared in +.Fx 9.0 . diff --git a/lib/libc/xdr/xdr_sizeof.c b/lib/libc/xdr/xdr_sizeof.c index 20f1c3a..f33c613 100644 --- a/lib/libc/xdr/xdr_sizeof.c +++ b/lib/libc/xdr/xdr_sizeof.c @@ -94,7 +94,7 @@ x_inline(xdrs, len) if (xdrs->x_op != XDR_ENCODE) { return (NULL); } - if (len < (u_int)xdrs->x_base) { + if (len < (u_int)(uintptr_t)xdrs->x_base) { /* x_private was already allocated */ xdrs->x_handy += len; return ((int32_t *) xdrs->x_private); @@ -106,7 +106,7 @@ x_inline(xdrs, len) xdrs->x_base = 0; return (NULL); } - xdrs->x_base = (caddr_t) len; + xdrs->x_base = (caddr_t)(uintptr_t)len; xdrs->x_handy += len; return ((int32_t *) xdrs->x_private); } diff --git a/lib/libkvm/kvm_pcpu.c b/lib/libkvm/kvm_pcpu.c index bc73baf..d7108b4 100644 --- a/lib/libkvm/kvm_pcpu.c +++ b/lib/libkvm/kvm_pcpu.c @@ -39,13 +39,11 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> -#include <sys/cpuset.h> #include <sys/pcpu.h> #include <sys/sysctl.h> #include <kvm.h> #include <limits.h> #include <stdlib.h> -#include <unistd.h> #include "kvm_private.h" @@ -120,9 +118,6 @@ _kvm_pcpu_clear(void) void * kvm_getpcpu(kvm_t *kd, int cpu) { - long kcpusetsize; - ssize_t nbytes; - uintptr_t readptr; char *buf; if (kd == NULL) { @@ -130,10 +125,6 @@ kvm_getpcpu(kvm_t *kd, int cpu) return (NULL); } - kcpusetsize = sysconf(_SC_CPUSET_SIZE); - if (kcpusetsize == -1 || (u_long)kcpusetsize > sizeof(cpuset_t)) - return ((void *)-1); - if (maxcpu == 0) if (_kvm_pcpu_init(kd) < 0) return ((void *)-1); @@ -146,26 +137,8 @@ kvm_getpcpu(kvm_t *kd, int cpu) _kvm_err(kd, kd->program, "out of memory"); return ((void *)-1); } - nbytes = sizeof(struct pcpu) - 2 * kcpusetsize; - readptr = (uintptr_t)pcpu_data[cpu]; - if (kvm_read(kd, readptr, buf, nbytes) != nbytes) { - _kvm_err(kd, kd->program, "unable to read per-CPU data"); - free(buf); - return ((void *)-1); - } - - /* Fetch the valid cpuset_t objects. */ - CPU_ZERO((cpuset_t *)(buf + nbytes)); - CPU_ZERO((cpuset_t *)(buf + nbytes + sizeof(cpuset_t))); - readptr += nbytes; - if (kvm_read(kd, readptr, buf + nbytes, kcpusetsize) != kcpusetsize) { - _kvm_err(kd, kd->program, "unable to read per-CPU data"); - free(buf); - return ((void *)-1); - } - readptr += kcpusetsize; - if (kvm_read(kd, readptr, buf + nbytes + sizeof(cpuset_t), - kcpusetsize) != kcpusetsize) { + if (kvm_read(kd, (uintptr_t)pcpu_data[cpu], buf, + sizeof(struct pcpu)) != sizeof(struct pcpu)) { _kvm_err(kd, kd->program, "unable to read per-CPU data"); free(buf); return ((void *)-1); diff --git a/lib/liblzma/config.h b/lib/liblzma/config.h index 374762c..9d97247 100644 --- a/lib/liblzma/config.h +++ b/lib/liblzma/config.h @@ -59,10 +59,10 @@ #define PACKAGE "xz" #define PACKAGE_BUGREPORT "lasse.collin@tukaani.org" #define PACKAGE_NAME "XZ Utils" -#define PACKAGE_STRING "XZ Utils 5.0.0" +#define PACKAGE_STRING "XZ Utils 5.0.3" #define PACKAGE_TARNAME "xz" #define PACKAGE_URL "http://tukaani.org/xz/" -#define PACKAGE_VERSION "5.0.0" +#define PACKAGE_VERSION "5.0.3" #define SIZEOF_SIZE_T 8 #define STDC_HEADERS 1 #define TUKLIB_CPUCORES_SYSCTL 1 @@ -82,8 +82,12 @@ #ifndef __EXTENSIONS__ # define __EXTENSIONS__ 1 #endif -#define VERSION "5.0.0" +#define VERSION "5.0.3" #if defined(__FreeBSD__) +#include <sys/_types.h> +#if defined(__NO_STRICT_ALIGNMENT) +#define TUKLIB_FAST_UNALIGNED_ACCESS 1 +#endif #include <machine/endian.h> #if _BYTE_ORDER == _BIG_ENDIAN # define WORDS_BIGENDIAN 1 diff --git a/lib/libprocstat/Makefile b/lib/libprocstat/Makefile index 05a64e7..9804483 100644 --- a/lib/libprocstat/Makefile +++ b/lib/libprocstat/Makefile @@ -15,13 +15,15 @@ SRCS= cd9660.c \ VERSION_DEF= ${.CURDIR}/Versions.def SYMBOL_MAPS= ${.CURDIR}/Symbol.map -INCS= libprocstat.h +INCS= libprocstat.h CFLAGS+= -I. -I${.CURDIR} -D_KVM_VNODE SHLIB_MAJOR= 1 -WITHOUT_MAN= yes + DPADD= ${LIBKVM} ${LIBUTIL} LDADD= -lkvm -lutil +MAN= libprocstat.3 + .if ${MK_NCP} != "no" CFLAGS+= -DLIBPROCSTAT_NWFS SRCS+= nwfs.c diff --git a/lib/libprocstat/libprocstat.3 b/lib/libprocstat/libprocstat.3 new file mode 100644 index 0000000..49799f5 --- /dev/null +++ b/lib/libprocstat/libprocstat.3 @@ -0,0 +1,258 @@ +.\" Copyright (c) 2011 Sergey Kandaurov <pluknet@FreeBSD.org> +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (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$ +.\" +.Dd July 12, 2011 +.Dt LIBPROCSTAT 3 +.Os +.Sh NAME +.Nm procstat_open_kvm , +.Nm procstat_open_sysctl , +.Nm procstat_close , +.Nm procstat_getfiles , +.Nm procstat_getprocs , +.Nm procstat_freefiles , +.Nm procstat_freeprocs , +.Nm procstat_get_pipe_info , +.Nm procstat_get_pts_info , +.Nm procstat_get_socket_info , +.Nm procstat_get_vnode_info +.Nd library interface for file and process information retrieval +.Sh LIBRARY +.Lb libprocstat +.Sh SYNOPSIS +.In sys/param.h +.In sys/queue.h +.In libprocstat.h +.Ft void +.Fn procstat_close "struct procstat *procstat" +.Ft void +.Fo procstat_freefiles +.Fa "struct procstat *procstat" +.Fa "struct filestat_list *head" +.Fc +.Ft void +.Fn procstat_freeprocs "struct procstat *procstat" "struct kinfo_proc *p" +.Ft int +.Fo procstat_get_pipe_info +.Fa "struct procstat *procstat" +.Fa "struct filestat *fst" +.Fa "struct pipestat *pipe" +.Fa "char *errbuf" +.Fc +.Ft int +.Fo procstat_get_pts_info +.Fa "struct procstat *procstat" +.Fa "struct filestat *fst" +.Fa "struct ptsstat *pts" +.Fa "char *errbuf" +.Fc +.Ft int +.Fo procstat_get_socket_info +.Fa "struct procstat *procstat" +.Fa "struct filestat *fst" +.Fa "struct sockstat *sock" +.Fa "char *errbuf" +.Fc +.Ft int +.Fo procstat_get_vnode_info +.Fa "struct procstat *procstat" +.Fa "struct filestat *fst" +.Fa "struct vnstat *vn" +.Fa "char *errbuf" +.Fc +.Ft "struct filestat_list *" +.Fo procstat_getfiles +.Fa "struct procstat *procstat" +.Fa "struct kinfo_proc *kp" +.Fa "int mmapped" +.Fc +.Ft "struct kinfo_proc *" +.Fo procstat_getprocs +.Fa "struct procstat *procstat" +.Fa "int what" +.Fa "int arg" +.Fa "unsigned int *count" +.Fc +.Ft "struct procstat *" +.Fn procstat_open_kvm "const char *nlistf" "const char *memf" +.Ft "struct procstat *" +.Fn procstat_open_sysctl void +.Sh DESCRIPTION +The +.Nm libprocstat +library contains the API for runtime file and process information +retrieval from the running kernel via the +.Xr sysctl 3 +library backend, and for post-mortem analysis via the +.Xr kvm 3 +library backend. +.Pp +The +.Fn procstat_open_kvm +and +.Fn procstat_open_sysctl +functions use the +.Xr kvm 3 +or +.Xr sysctl 3 +library routines, respectively, to access kernel state information +used to retrieve processes and files states. +The +.Fa nlistf +argument is the executable image of the kernel being examined. +If this argument is +.Dv NULL , +the currently running kernel is assumed. +The +.Fa memf +argument is the kernel memory device file. +If this argument is +.Dv NULL , +then +.Pa /dev/mem +is assumed. +See +.Xr kvm_open 3 +for more details. +Both functions dynamically allocate and return a +.Vt procstat +structure pointer used in the rest of the +.Nm libprocstat +library routines until the corresponding +.Fn procstat_close +call that cleans up the resources allocated by the +.Fn procstat_open_* +functions. +.Pp +The +.Fn procstat_getprocs +function gets a pointer to the +.Vt procstat +structure from one of the +.Fn procstat_open_* +functions and returns a dynamically allocated (sub-)set of active processes +in the kernel filled in to array of +.Vt kinfo_proc +structures. +The +.Fa what +and +.Fa arg +arguments constitute a filtering predicate as described in the +.Xr kvm_getprocs 3 +function. +The number of processes found is returned in the reference parameter +.Fa cnt . +The caller is responsible to free the allocated memory with a subsequent +.Fn procstat_freeprocs +function call. +.Pp +The +.Fn procstat_getfiles +function gets a pointer to the +.Vt procstat +structure initialized with one of the +.Fn procstat_open_* +functions, a pointer to +.Vt kinfo_proc +structure from the array obtained from the +.Fn kvm_getprocs +function, and returns a dynamically allocated linked list of filled in +.Vt filestat_list +structures using the STAILQ macros defined in +.Xr queue 3 . +The caller is responsible to free the allocated memory with a subsequent +.Fn procstat_freefiles +function call. +.Pp +The +.Fn procstat_get_pipe_info , +.Fn procstat_get_pts_info , +.Fn procstat_get_socket_info +and +.Fn procstat_get_vnode_info +functions are used to retrive information about pipes, pseudo-terminals, +sockets, and vnodes, respectively. +Each of them have a similar interface API. +The +.Fa procstat +argument is a pointer obtained from one of +.Fn procstat_open_* +functions. +The +.Ft filestat Fa fst +argument is an element of STAILQ linked list as obtained from the +.Fn procstat_getfiles +function. +The +.Ft filestat +structure contains a +.Fa fs_type +field that specifies a file type and a corresponding function to be +called among the +.Nm procstat_get_*_info +function family. +The actual object is returned in the 3rd reference parameter. +The +.Fa errbuf +argument indicates an actual error message in case of failure. +.Pp +.Bl -tag -width 20n -compact -offset indent +.It Li PS_FST_TYPE_FIFO +.Nm procstat_get_vnode_info +.It Li PS_FST_TYPE_VNODE +.Nm procstat_get_vnode_info +.It Li PS_FST_TYPE_SOCKET +.Nm procstat_get_socket_info +.It Li PS_FST_TYPE_PIPE +.Nm procstat_get_pipe_info +.It Li PS_FST_TYPE_PTS +.Nm procstat_get_pts_info +.El +.Sh SEE ALSO +.Xr fstat 1 , +.Xr fuser 1 , +.Xr pipe 2 , +.Xr socket 2 , +.Xr kvm 3 , +.Xr queue 3 , +.Xr sysctl 3 , +.Xr pts 4 , +.Xr vnode 9 +.Sh HISTORY +The +.Nm libprocstat +library appeared in +.Fx 9.0 . +.Sh AUTHORS +.An -nosplit +The +.Nm libprocstat +library was written by +.An Stanislav Sedov Aq stas@FreeBSD.org . +.Pp +This manual page was written by +.An Sergey Kandaurov Aq pluknet@FreeBSD.org . diff --git a/lib/libstand/stand.h b/lib/libstand/stand.h index eae1605..db0490f 100644 --- a/lib/libstand/stand.h +++ b/lib/libstand/stand.h @@ -65,15 +65,13 @@ #include <sys/cdefs.h> #include <sys/stat.h> #include <sys/dirent.h> + +/* this header intentionally exports NULL from <string.h> */ #include <string.h> #define CHK(fmt, args...) printf("%s(%d): " fmt "\n", __func__, __LINE__ , ##args) #define PCHK(fmt, args...) {printf("%s(%d): " fmt "\n", __func__, __LINE__ , ##args); getchar();} -#ifndef NULL -#define NULL 0 -#endif - /* Avoid unwanted userlandish components */ #define _KERNEL #include <sys/errno.h> diff --git a/lib/libstand/zalloc.c b/lib/libstand/zalloc.c index 2cd71c4..41aef0d 100644 --- a/lib/libstand/zalloc.c +++ b/lib/libstand/zalloc.c @@ -77,7 +77,7 @@ __FBSDID("$FreeBSD$"); */ void * -znalloc(MemPool *mp, iaddr_t bytes) +znalloc(MemPool *mp, uintptr_t bytes) { /* * align according to pool object size (can be 0). This is @@ -136,7 +136,7 @@ znalloc(MemPool *mp, iaddr_t bytes) */ void -zfree(MemPool *mp, void *ptr, iaddr_t bytes) +zfree(MemPool *mp, void *ptr, uintptr_t bytes) { /* * align according to pool object size (can be 0). This is @@ -153,8 +153,8 @@ zfree(MemPool *mp, void *ptr, iaddr_t bytes) if ((char *)ptr < (char *)mp->mp_Base || (char *)ptr + bytes > (char *)mp->mp_End || - ((iaddr_t)ptr & MEMNODE_SIZE_MASK) != 0) - panic("zfree(%p,%ju): wild pointer", ptr, bytes); + ((uintptr_t)ptr & MEMNODE_SIZE_MASK) != 0) + panic("zfree(%p,%ju): wild pointer", ptr, (uintmax_t)bytes); /* * free the segment @@ -177,8 +177,10 @@ zfree(MemPool *mp, void *ptr, iaddr_t bytes) /* * range check */ - if ((char *)ptr + bytes > (char *)mn) - panic("zfree(%p,%ju): corrupt memlist1",ptr, bytes); + if ((char *)ptr + bytes > (char *)mn) { + panic("zfree(%p,%ju): corrupt memlist1", ptr, + (uintmax_t)bytes); + } /* * merge against next area or create independant area @@ -208,8 +210,10 @@ zfree(MemPool *mp, void *ptr, iaddr_t bytes) return; /* NOT REACHED */ } - if ((char *)ptr < (char *)mn + mn->mr_Bytes) - panic("zfree(%p,%ju): corrupt memlist2", ptr, bytes); + if ((char *)ptr < (char *)mn + mn->mr_Bytes) { + panic("zfree(%p,%ju): corrupt memlist2", ptr, + (uintmax_t)bytes); + } } /* * We are beyond the last MemNode, append new MemNode. Merge against @@ -241,7 +245,7 @@ zfree(MemPool *mp, void *ptr, iaddr_t bytes) */ void -zextendPool(MemPool *mp, void *base, iaddr_t bytes) +zextendPool(MemPool *mp, void *base, uintptr_t bytes) { if (mp->mp_Size == 0) { mp->mp_Base = base; diff --git a/lib/libstand/zalloc_defs.h b/lib/libstand/zalloc_defs.h index 2544f59..5331ee0 100644 --- a/lib/libstand/zalloc_defs.h +++ b/lib/libstand/zalloc_defs.h @@ -38,20 +38,12 @@ #define DMALLOCDEBUG /* add debugging code to gather stats */ #define ZALLOCDEBUG -#include <string.h> +#include <sys/stdint.h> #include "stand.h" - -typedef uintptr_t iaddr_t; /* unsigned int same size as pointer */ -typedef intptr_t saddr_t; /* signed int same size as pointer */ #include "zalloc_mem.h" -#define Prototype extern #define Library extern -#ifndef NULL -#define NULL ((void *)0) -#endif - /* * block extension for sbrk() */ @@ -60,8 +52,7 @@ typedef intptr_t saddr_t; /* signed int same size as pointer */ #define BLKEXTENDMASK (BLKEXTEND - 1) /* - * required malloc alignment. Use sizeof(long double) for architecture - * independance. + * required malloc alignment. Just hardwire to 16. * * Note: if we implement a more sophisticated realloc, we should ensure that * MALLOCALIGN is at least as large as MemNode. @@ -72,10 +63,8 @@ typedef struct Guard { size_t ga_Magic; /* must be at least 32 bits */ } Guard; -#define MATYPE long double -#define MALLOCALIGN ((sizeof(MATYPE) > sizeof(Guard)) ? sizeof(MATYPE) : sizeof(Guard)) +#define MALLOCALIGN 16 #define GAMAGIC 0x55FF44FD #define GAFREE 0x5F54F4DF #include "zalloc_protos.h" - diff --git a/lib/libstand/zalloc_malloc.c b/lib/libstand/zalloc_malloc.c index 5cd7bcb..b9a295f 100644 --- a/lib/libstand/zalloc_malloc.c +++ b/lib/libstand/zalloc_malloc.c @@ -126,7 +126,7 @@ Free(void *ptr, const char *file, int line) void * Calloc(size_t n1, size_t n2, const char *file, int line) { - iaddr_t bytes = (iaddr_t)n1 * (iaddr_t)n2; + uintptr_t bytes = (uintptr_t)n1 * (uintptr_t)n2; void *res; if ((res = Malloc(bytes, file, line)) != NULL) { diff --git a/lib/libstand/zalloc_mem.h b/lib/libstand/zalloc_mem.h index c872da1..f29c0d7 100644 --- a/lib/libstand/zalloc_mem.h +++ b/lib/libstand/zalloc_mem.h @@ -37,15 +37,15 @@ typedef struct MemNode { struct MemNode *mr_Next; - iaddr_t mr_Bytes; + uintptr_t mr_Bytes; } MemNode; typedef struct MemPool { void *mp_Base; void *mp_End; MemNode *mp_First; - iaddr_t mp_Size; - iaddr_t mp_Used; + uintptr_t mp_Size; + uintptr_t mp_Used; } MemPool; #define MEMNODE_SIZE_MASK ((sizeof(MemNode) <= 8) ? 7 : 15) diff --git a/lib/libstand/zalloc_protos.h b/lib/libstand/zalloc_protos.h index c90bd5a..53a40e4 100644 --- a/lib/libstand/zalloc_protos.h +++ b/lib/libstand/zalloc_protos.h @@ -29,7 +29,7 @@ * $FreeBSD$ */ -Library void *znalloc(struct MemPool *mpool, iaddr_t bytes); -Library void zfree(struct MemPool *mpool, void *ptr, iaddr_t bytes); -Library void zextendPool(MemPool *mp, void *base, iaddr_t bytes); +Library void *znalloc(struct MemPool *mpool, uintptr_t bytes); +Library void zfree(struct MemPool *mpool, void *ptr, uintptr_t bytes); +Library void zextendPool(MemPool *mp, void *base, uintptr_t bytes); Library void zallocstats(struct MemPool *mp); diff --git a/lib/libusb/libusb.3 b/lib/libusb/libusb.3 index e7e3115..33d807d 100644 --- a/lib/libusb/libusb.3 +++ b/lib/libusb/libusb.3 @@ -542,6 +542,8 @@ The library is also compliant with LibUSB version 0.1.12. .Fn usb_device .Fn usb_get_busses .Fn usb_check_connected +.Fn usb_get_driver_np +.Fn usb_detach_kernel_driver_np . .Sh SEE ALSO .Xr libusb20 3 , diff --git a/lib/libusb/libusb01.c b/lib/libusb/libusb01.c index 4124ef6..17edb0e 100644 --- a/lib/libusb/libusb01.c +++ b/lib/libusb/libusb01.c @@ -203,6 +203,12 @@ usb_get_string(usb_dev_handle * dev, int strindex, { int err; + if (dev == NULL) + return (-1); + + if (buflen > 65535) + buflen = 65535; + err = libusb20_dev_req_string_sync((void *)dev, strindex, langid, buf, buflen); @@ -218,6 +224,12 @@ usb_get_string_simple(usb_dev_handle * dev, int strindex, { int err; + if (dev == NULL) + return (-1); + + if (buflen > 65535) + buflen = 65535; + err = libusb20_dev_req_string_simple_sync((void *)dev, strindex, buf, buflen); @@ -233,6 +245,12 @@ usb_get_descriptor_by_endpoint(usb_dev_handle * udev, int ep, uint8_t type, { memset(buf, 0, size); + if (udev == NULL) + return (-1); + + if (size > 65535) + size = 65535; + return (usb_control_msg(udev, ep | USB_ENDPOINT_IN, USB_REQ_GET_DESCRIPTOR, (type << 8) + ep_index, 0, buf, size, 1000)); @@ -244,6 +262,12 @@ usb_get_descriptor(usb_dev_handle * udev, uint8_t type, uint8_t desc_index, { memset(buf, 0, size); + if (udev == NULL) + return (-1); + + if (size > 65535) + size = 65535; + return (usb_control_msg(udev, USB_ENDPOINT_IN, USB_REQ_GET_DESCRIPTOR, (type << 8) + desc_index, 0, buf, size, 1000)); } @@ -943,3 +967,49 @@ usb_get_busses(void) { return (usb_busses); } + +int +usb_get_driver_np(usb_dev_handle * dev, int interface, char *name, int namelen) +{ + struct libusb20_device *pdev; + char *ptr; + int err; + + pdev = (void *)dev; + + if (pdev == NULL) + return (-1); + if (namelen < 1) + return (-1); + if (namelen > 255) + namelen = 255; + + err = libusb20_dev_get_iface_desc(pdev, interface, name, namelen); + if (err != 0) + return (-1); + + /* we only want the driver name */ + ptr = strstr(name, ":"); + if (ptr != NULL) + *ptr = 0; + + return (0); +} + +int +usb_detach_kernel_driver_np(usb_dev_handle * dev, int interface) +{ + struct libusb20_device *pdev; + int err; + + pdev = (void *)dev; + + if (pdev == NULL) + return (-1); + + err = libusb20_dev_detach_kernel_driver(pdev, interface); + if (err != 0) + return (-1); + + return (0); +} diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c index 737e610..3ecba58 100644 --- a/lib/libusb/libusb10.c +++ b/lib/libusb/libusb10.c @@ -719,6 +719,8 @@ libusb_get_driver(struct libusb20_device *pdev, int interface, return (LIBUSB_ERROR_INVALID_PARAM); if (namelen < 1) return (LIBUSB_ERROR_INVALID_PARAM); + if (namelen > 255) + namelen = 255; err = libusb20_dev_get_iface_desc( pdev, interface, name, namelen); diff --git a/lib/libusb/libusb10_desc.c b/lib/libusb/libusb10_desc.c index 5823723..3448679 100644 --- a/lib/libusb/libusb10_desc.c +++ b/lib/libusb/libusb10_desc.c @@ -300,6 +300,9 @@ libusb_get_string_descriptor_ascii(libusb_device_handle *pdev, if (pdev == NULL || data == NULL || length < 1) return (LIBUSB20_ERROR_INVALID_PARAM); + if (length > 65535) + length = 65535; + /* put some default data into the destination buffer */ data[0] = 0; @@ -314,6 +317,12 @@ int libusb_get_descriptor(libusb_device_handle * devh, uint8_t desc_type, uint8_t desc_index, uint8_t *data, int length) { + if (devh == NULL || data == NULL || length < 1) + return (LIBUSB20_ERROR_INVALID_PARAM); + + if (length > 65535) + length = 65535; + return (libusb_control_transfer(devh, LIBUSB_ENDPOINT_IN, LIBUSB_REQUEST_GET_DESCRIPTOR, (desc_type << 8) | desc_index, 0, data, length, 1000)); diff --git a/lib/libusb/libusb20.c b/lib/libusb/libusb20.c index 716f540..b35e2bf 100644 --- a/lib/libusb/libusb20.c +++ b/lib/libusb/libusb20.c @@ -1081,6 +1081,8 @@ libusb20_dev_get_iface_desc(struct libusb20_device *pdev, if ((buf == NULL) || (len == 0)) return (LIBUSB20_ERROR_INVALID_PARAM); + buf[0] = 0; /* set default string value */ + return (pdev->beMethods->dev_get_iface_desc( pdev, iface_index, buf, len)); } diff --git a/lib/libusb/usb.h b/lib/libusb/usb.h index 8ee68f2..dc3959e 100644 --- a/lib/libusb/usb.h +++ b/lib/libusb/usb.h @@ -299,6 +299,8 @@ int usb_find_busses(void); int usb_find_devices(void); struct usb_device *usb_device(usb_dev_handle * dev); struct usb_bus *usb_get_busses(void); +int usb_get_driver_np(usb_dev_handle * dev, int interface, char *name, int namelen); +int usb_detach_kernel_driver_np(usb_dev_handle * dev, int interface); #if 0 { /* style */ diff --git a/lib/libutil/login.conf.5 b/lib/libutil/login.conf.5 index 2d1b906..134c779 100644 --- a/lib/libutil/login.conf.5 +++ b/lib/libutil/login.conf.5 @@ -19,7 +19,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 20, 2008 +.Dd July 8, 2011 .Dt LOGIN.CONF 5 .Os .Sh NAME @@ -190,6 +190,7 @@ notation may be used. .It "vmemoryuse size Maximum permitted total VM usage per process. .It "stacksize size Maximum stack size limit. .It "pseudoterminals number Maximum number of pseudo-terminals. +.It "swapuse size Maximum swap space size limit. .El .Pp These resource limit entries actually specify both the maximum |