mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-28 19:34:43 +01:00
Compare commits
274
Commits
master
...
release/11.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34bd347501 | ||
|
|
0a66c4b08a | ||
|
|
336408d8fb | ||
|
|
819ec55864 | ||
|
|
671fb7df97 | ||
|
|
792e18eda4 | ||
|
|
4372a8abb9 | ||
|
|
ee2ac57fcd | ||
|
|
512b217070 | ||
|
|
67e9d9f440 | ||
|
|
17fd01f05d | ||
|
|
17ed644781 | ||
|
|
60c3a17946 | ||
|
|
3b2158e5ad | ||
|
|
62bbb5c601 | ||
|
|
8802b72b4e | ||
|
|
fe73edb427 | ||
|
|
33aff35778 | ||
|
|
7c79f14cff | ||
|
|
5b4e1ec6a8 | ||
|
|
f49310563e | ||
|
|
613505b093 | ||
|
|
190ecec782 | ||
|
|
ff7167d87b | ||
|
|
0b2bc2f1d2 | ||
|
|
89f3b03b54 | ||
|
|
80f08e175b | ||
|
|
1e9a4fa85c | ||
|
|
7109dada7c | ||
|
|
0d3ec54958 | ||
|
|
11637f5724 | ||
|
|
08f8bf6588 | ||
|
|
29479789b4 | ||
|
|
7d55fc9230 | ||
|
|
827f2d8e5c | ||
|
|
0be478f83f | ||
|
|
9fec72cb49 | ||
|
|
e20fd6cb7b | ||
|
|
6b44e7fe78 | ||
|
|
45bb561ccc | ||
|
|
f411688074 | ||
|
|
abefffa73c | ||
|
|
51b0565b0b | ||
|
|
396875fe9e | ||
|
|
f1b919399c | ||
|
|
8b3112669f | ||
|
|
e78b4e5988 | ||
|
|
640c199940 | ||
|
|
526e8ae9ee | ||
|
|
ef384e0d40 | ||
|
|
368f1ba3f9 | ||
|
|
b3bc68d93c | ||
|
|
304fd4ea7a | ||
|
|
c8fc89515f | ||
|
|
b46f188dc4 | ||
|
|
30c09759e3 | ||
|
|
702af97a48 | ||
|
|
ac40671ce0 | ||
|
|
e38b3d3a99 | ||
|
|
bc37050e42 | ||
|
|
584adb92ca | ||
|
|
2c8efb0f82 | ||
|
|
badb1d48f4 | ||
|
|
3e1942ddba | ||
|
|
a3e93a9010 | ||
|
|
e6e75a30c1 | ||
|
|
dcbfdf410f | ||
|
|
506794cf4c | ||
|
|
ccf787d164 | ||
|
|
661075afaf | ||
|
|
92e01550f4 | ||
|
|
71c931d251 | ||
|
|
b5e2ba4f5a | ||
|
|
3e4c1aa52a | ||
|
|
7573d5ed7d | ||
|
|
e2d4a6a8f3 | ||
|
|
2e1a0dde62 | ||
|
|
c1037f3947 | ||
|
|
ed982599f0 | ||
|
|
37f9784baa | ||
|
|
5d8732b259 | ||
|
|
e4a4adc85c | ||
|
|
b8112e2e89 | ||
|
|
daa9993e80 | ||
|
|
be17245afc | ||
|
|
c0e055fae0 | ||
|
|
a34455d414 | ||
|
|
7eb5f0fd3c | ||
|
|
02c0075216 | ||
|
|
5a26bb96ef | ||
|
|
34608b523e | ||
|
|
b794f476db | ||
|
|
99062cdd66 | ||
|
|
a47474b311 | ||
|
|
f172e9db6f | ||
|
|
c3b7936afe | ||
|
|
f4ef939946 | ||
|
|
dc45a739f1 | ||
|
|
12c212870e | ||
|
|
9423e30951 | ||
|
|
6b814739f1 | ||
|
|
82d4204a10 | ||
|
|
bfea20cf8b | ||
|
|
555a66dde3 | ||
|
|
56e01df652 | ||
|
|
feb5de2dde | ||
|
|
98ceee8409 | ||
|
|
e59af6421a | ||
|
|
5927bb68f7 | ||
|
|
bf248e5b67 | ||
|
|
5c401164bd | ||
|
|
0b3fd3a792 | ||
|
|
64f44a7c96 | ||
|
|
7769821166 | ||
|
|
9339dd728a | ||
|
|
2fb0221495 | ||
|
|
74fef9f0ed | ||
|
|
5f758babca | ||
|
|
ae0777121b | ||
|
|
b6d66342c8 | ||
|
|
1c3a364ea3 | ||
|
|
bca3ac77d0 | ||
|
|
9d9b3557fd | ||
|
|
430c030f8a | ||
|
|
19f8e59ed0 | ||
|
|
d89bbe5d4b | ||
|
|
fc653de7d2 | ||
|
|
c81844ff3b | ||
|
|
2bf019fe8e | ||
|
|
87dae3d674 | ||
|
|
89b97df36f | ||
|
|
7e2ae2d882 | ||
|
|
6a45f16d44 | ||
|
|
4061526893 | ||
|
|
695befa4f7 | ||
|
|
b8d810f1c9 | ||
|
|
d9b7b9d1f6 | ||
|
|
1abf18ad34 | ||
|
|
817ff25c71 | ||
|
|
b55da59d7a | ||
|
|
44a8f55c90 | ||
|
|
ddbd946fa1 | ||
|
|
e08ff22972 | ||
|
|
217f28eaa1 | ||
|
|
0117d25d6a | ||
|
|
5ceddcfe35 | ||
|
|
b2dae14c49 | ||
|
|
2591ec4737 | ||
|
|
54acfab938 | ||
|
|
77dd9999ac | ||
|
|
b6581bf2a1 | ||
|
|
794674b5d5 | ||
|
|
89a705c439 | ||
|
|
a4ba4f0efa | ||
|
|
352ce54d0d | ||
|
|
e6b932cf11 | ||
|
|
c4e2f7b840 | ||
|
|
653cfd1cdf | ||
|
|
3d95659a9b | ||
|
|
b99d8e84b5 | ||
|
|
8e44e7e022 | ||
|
|
5dd6aeda91 | ||
|
|
f4f76fbb39 | ||
|
|
c4fd22683a | ||
|
|
62648ee887 | ||
|
|
ec7f75fb75 | ||
|
|
4aa8790f86 | ||
|
|
1d3ef50b29 | ||
|
|
2a36bd13a9 | ||
|
|
8223b18a34 | ||
|
|
af774f5c48 | ||
|
|
b196907c76 | ||
|
|
3e5f5fb53f | ||
|
|
072ec9c1e6 | ||
|
|
5952003d11 | ||
|
|
6b6214dac7 | ||
|
|
64ad0a119e | ||
|
|
4fb92ad6c6 | ||
|
|
8e0964970b | ||
|
|
34c461de41 | ||
|
|
175cfb44e1 | ||
|
|
442ba83795 | ||
|
|
08abf7e29d | ||
|
|
bc225c5b51 | ||
|
|
cc9d6d44c8 | ||
|
|
d9d0114bbc | ||
|
|
e103f9085a | ||
|
|
cc664b9bec | ||
|
|
8c7b03fe3d | ||
|
|
a7da496a8f | ||
|
|
20528c390f | ||
|
|
fe543455a7 | ||
|
|
16542d14b1 | ||
|
|
6ebcad9859 | ||
|
|
0f0fde700e | ||
|
|
dc3a6704e6 | ||
|
|
0b66401cb9 | ||
|
|
20f9c96dbf | ||
|
|
e6ca210e3c | ||
|
|
2eee535623 | ||
|
|
145b302821 | ||
|
|
ec3e770961 | ||
|
|
4bdfe407a6 | ||
|
|
e7048d68e1 | ||
|
|
7ce9a4edc5 | ||
|
|
eb75c892ad | ||
|
|
bc301e9bf0 | ||
|
|
7177fe9271 | ||
|
|
b02c62a3c7 | ||
|
|
ebfa5c38a7 | ||
|
|
e247bac34b | ||
|
|
ca17b3e53b | ||
|
|
cf47860dd7 | ||
|
|
0a91ab2b4e | ||
|
|
bafd85eb9d | ||
|
|
fbb4f11b70 | ||
|
|
2dd8d7bbd6 | ||
|
|
82d9ac3773 | ||
|
|
4834b2493e | ||
|
|
c11ee04c3d | ||
|
|
7f38d1257c | ||
|
|
ae0d5ab157 | ||
|
|
90216203de | ||
|
|
7b3203088f | ||
|
|
63ad51bcb7 | ||
|
|
2f93a3f5d2 | ||
|
|
e82dbd8760 | ||
|
|
79a180b126 | ||
|
|
a0c0a67188 | ||
|
|
3702299d41 | ||
|
|
864bf172c4 | ||
|
|
7af26f7839 | ||
|
|
71b6d270be | ||
|
|
e08b42ec26 | ||
|
|
e7b6e41f23 | ||
|
|
3eeae56e70 | ||
|
|
307a609d02 | ||
|
|
fe49fb6bb1 | ||
|
|
3380bc229c | ||
|
|
e4cf35ba6c | ||
|
|
94b49ea6f9 | ||
|
|
2e33c30fe3 | ||
|
|
ffa95dadf4 | ||
|
|
8da1d57aa9 | ||
|
|
4daa68ce2a | ||
|
|
fded06be2a | ||
|
|
448c31efa2 | ||
|
|
00caa152f1 | ||
|
|
3e501082b8 | ||
|
|
abae7d14c4 | ||
|
|
69e303843a | ||
|
|
3872d54617 | ||
|
|
dc0822fbf6 | ||
|
|
7b3c77a2bb | ||
|
|
688500bf09 | ||
|
|
54859495fb | ||
|
|
b9ca940a88 | ||
|
|
777eb5c818 | ||
|
|
371ab94ebe | ||
|
|
3617b98a01 | ||
|
|
20b5df1c81 | ||
|
|
78ef5a21aa | ||
|
|
f909c41816 | ||
|
|
32f3c06b70 | ||
|
|
753105b560 | ||
|
|
d9abcf2842 | ||
|
|
d01da32b42 | ||
|
|
ed0c0d253f | ||
|
|
7977155c93 | ||
|
|
607cd4258a | ||
|
|
2c6b98f515 | ||
|
|
1a3035ea7d | ||
|
|
4a87fae024 | ||
|
|
913ef4fc33 |
No files matched your search
@@ -131,7 +131,8 @@ TGTS= all all-man buildenv buildenvvars buildkernel buildworld \
|
||||
builddtb xdev xdev-build xdev-install \
|
||||
xdev-links native-xtools stageworld stagekernel stage-packages \
|
||||
create-world-packages create-kernel-packages create-packages \
|
||||
packages installconfig real-packages sign-packages package-pkg
|
||||
packages installconfig real-packages sign-packages package-pkg \
|
||||
test-system-compiler
|
||||
|
||||
# XXX: r156740: This can't work since bsd.subdir.mk is not included ever.
|
||||
# It will only work for SUBDIR_TARGETS in make.conf.
|
||||
@@ -151,7 +152,8 @@ TGTS+= ${BITGTS}
|
||||
META_TGT_WHITELIST+= \
|
||||
_* build32 buildfiles buildincludes buildkernel buildsoft \
|
||||
buildworld everything kernel-toolchain kernel-toolchains kernel \
|
||||
kernels libraries native-xtools showconfig tinderbox toolchain \
|
||||
kernels libraries native-xtools showconfig test-system-compiler \
|
||||
tinderbox toolchain \
|
||||
toolchains universe world worlds xdev xdev-build
|
||||
|
||||
.ORDER: buildworld installworld
|
||||
@@ -207,7 +209,8 @@ SUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
|
||||
SUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
|
||||
.endif
|
||||
|
||||
_MAKE= PATH=${PATH} ${SUB_MAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
|
||||
_MAKE= PATH=${PATH} MAKE_CMD=${MAKE} ${SUB_MAKE} -f Makefile.inc1 \
|
||||
TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
|
||||
|
||||
# Only allow meta mode for the whitelisted targets. See META_TGT_WHITELIST
|
||||
# above.
|
||||
|
||||
+58
-52
@@ -72,7 +72,8 @@ X${COMPILER}?= ${${COMPILER}}
|
||||
# If a full path to an external cross compiler is given, don't build
|
||||
# a cross compiler.
|
||||
.if ${XCC:N${CCACHE_BIN}:M/*}
|
||||
MK_CROSS_COMPILER= no
|
||||
MK_CLANG_BOOTSTRAP= no
|
||||
MK_GCC_BOOTSTRAP= no
|
||||
.endif
|
||||
|
||||
# Pull in COMPILER_TYPE and COMPILER_FREEBSD_VERSION early.
|
||||
@@ -80,50 +81,68 @@ MK_CROSS_COMPILER= no
|
||||
.include "share/mk/src.opts.mk"
|
||||
|
||||
# Check if there is a local compiler that can satisfy as an external compiler.
|
||||
.if ${MK_SYSTEM_COMPILER} == "yes" && ${MK_CROSS_COMPILER} == "yes" && \
|
||||
(${MK_CLANG_BOOTSTRAP} == "yes" || ${MK_GCC_BOOTSTRAP} == "yes") && \
|
||||
!make(showconfig) && !make(native-xtools) && !make(xdev*)
|
||||
# Which compiler is expected to be used?
|
||||
.if ${MK_CLANG_BOOTSTRAP} == "yes"
|
||||
_expected_compiler_type= clang
|
||||
WANT_COMPILER_TYPE= clang
|
||||
.elif ${MK_GCC_BOOTSTRAP} == "yes"
|
||||
_expected_compiler_type= gcc
|
||||
WANT_COMPILER_TYPE= gcc
|
||||
.else
|
||||
WANT_COMPILER_TYPE=
|
||||
.endif
|
||||
.if !defined(WANT_COMPILER_FREEBSD_VERSION)
|
||||
.if ${WANT_COMPILER_TYPE} == "clang"
|
||||
WANT_COMPILER_FREEBSD_VERSION_FILE= lib/clang/freebsd_cc_version.h
|
||||
WANT_COMPILER_FREEBSD_VERSION!= \
|
||||
awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \
|
||||
${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
|
||||
WANT_COMPILER_VERSION_FILE= lib/clang/include/clang/Basic/Version.inc
|
||||
WANT_COMPILER_VERSION!= \
|
||||
awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
|
||||
${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
|
||||
.elif ${WANT_COMPILER_TYPE} == "gcc"
|
||||
WANT_COMPILER_FREEBSD_VERSION_FILE= gnu/usr.bin/cc/cc_tools/freebsd-native.h
|
||||
WANT_COMPILER_FREEBSD_VERSION!= \
|
||||
awk '$$2 == "FBSD_CC_VER" {printf("%d\n", $$3)}' \
|
||||
${SRCDIR}/${WANT_COMPILER_FREEBSD_VERSION_FILE} || echo unknown
|
||||
WANT_COMPILER_VERSION_FILE= contrib/gcc/BASE-VER
|
||||
WANT_COMPILER_VERSION!= \
|
||||
awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3}' \
|
||||
${SRCDIR}/${WANT_COMPILER_VERSION_FILE} || echo unknown
|
||||
.endif
|
||||
.export WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_VERSION
|
||||
.endif # !defined(WANT_COMPILER_FREEBSD_VERSION)
|
||||
# It needs to be the same revision as we would build for the bootstrap.
|
||||
# If the expected vs CC is different then we can't skip.
|
||||
# GCC cannot be used for cross-arch yet. For clang we pass -target later if
|
||||
# TARGET_ARCH!=MACHINE_ARCH.
|
||||
.if ${_expected_compiler_type} == ${COMPILER_TYPE} && \
|
||||
(${COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH})
|
||||
# It needs to be the same revision as we would build for the bootstrap.
|
||||
.if !defined(CROSS_COMPILER_FREEBSD_VERSION)
|
||||
.if ${_expected_compiler_type} == "clang"
|
||||
CROSS_COMPILER_FREEBSD_VERSION!= \
|
||||
awk '$$2 == "FREEBSD_CC_VERSION" {printf("%d\n", $$3)}' \
|
||||
${SRCDIR}/lib/clang/freebsd_cc_version.h || echo unknown
|
||||
CROSS_COMPILER_VERSION!= \
|
||||
awk '$$2 == "CLANG_VERSION" {split($$3, a, "."); print a[1] * 10000 + a[2] * 100 + a[3]}' \
|
||||
${SRCDIR}/lib/clang/include/clang/Basic/Version.inc || echo unknown
|
||||
.elif ${_expected_compiler_type} == "gcc"
|
||||
CROSS_COMPILER_FREEBSD_VERSION!= \
|
||||
awk '$$2 == "FBSD_CC_VER" {printf("%d\n", $$3)}' \
|
||||
${SRCDIR}/gnu/usr.bin/cc/cc_tools/freebsd-native.h || echo unknown
|
||||
CROSS_COMPILER_VERSION!= \
|
||||
awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3}' \
|
||||
${SRCDIR}/contrib/gcc/BASE-VER || echo unknown
|
||||
.endif
|
||||
.export CROSS_COMPILER_FREEBSD_VERSION CROSS_COMPILER_VERSION
|
||||
.endif # !defined(CROSS_COMPILER_FREEBSD_VERSION)
|
||||
.if ${COMPILER_VERSION} == ${CROSS_COMPILER_VERSION} && \
|
||||
${COMPILER_FREEBSD_VERSION} == ${CROSS_COMPILER_FREEBSD_VERSION}
|
||||
.if ${MK_SYSTEM_COMPILER} == "yes" && \
|
||||
(${MK_CLANG_BOOTSTRAP} == "yes" || ${MK_GCC_BOOTSTRAP} == "yes") && \
|
||||
!make(showconfig) && !make(native-xtools) && !make(xdev*) && \
|
||||
${WANT_COMPILER_TYPE} == ${COMPILER_TYPE} && \
|
||||
(${COMPILER_TYPE} == "clang" || ${TARGET_ARCH} == ${MACHINE_ARCH}) && \
|
||||
${COMPILER_VERSION} == ${WANT_COMPILER_VERSION} && \
|
||||
${COMPILER_FREEBSD_VERSION} == ${WANT_COMPILER_FREEBSD_VERSION}
|
||||
# Everything matches, disable the bootstrap compiler.
|
||||
MK_CLANG_BOOTSTRAP= no
|
||||
MK_GCC_BOOTSTRAP= no
|
||||
.if make(buildworld)
|
||||
USING_SYSTEM_COMPILER= yes
|
||||
.endif # ${WANT_COMPILER_TYPE} == ${COMPILER_TYPE}
|
||||
USING_SYSTEM_COMPILER?= no
|
||||
TEST_SYSTEM_COMPILER_VARS= \
|
||||
USING_SYSTEM_COMPILER MK_SYSTEM_COMPILER \
|
||||
MK_CROSS_COMPILER MK_CLANG_BOOTSTRAP MK_GCC_BOOTSTRAP \
|
||||
WANT_COMPILER_TYPE WANT_COMPILER_VERSION WANT_COMPILER_VERSION_FILE \
|
||||
WANT_COMPILER_FREEBSD_VERSION WANT_COMPILER_FREEBSD_VERSION_FILE \
|
||||
CC COMPILER_TYPE COMPILER_VERSION COMPILER_FREEBSD_VERSION
|
||||
test-system-compiler: .PHONY
|
||||
.for v in ${TEST_SYSTEM_COMPILER_VARS}
|
||||
${_+_}@printf "%-35s= %s\n" "${v}" "${${v}}"
|
||||
.endfor
|
||||
.if ${USING_SYSTEM_COMPILER} == "yes" && \
|
||||
(make(buildworld) || make(buildkernel) || make(kernel-toolchain) || \
|
||||
make(toolchain) || make(_cross-tools))
|
||||
.info SYSTEM_COMPILER: Determined that CC=${CC} matches the source tree. Not bootstrapping a cross-compiler.
|
||||
.endif
|
||||
.endif # ${COMPILER_VERSION} == ${CROSS_COMPILER_VERSION}
|
||||
.endif # ${_expected_compiler_type} == ${COMPILER_TYPE}
|
||||
.endif # ${XCC:N${CCACHE_BIN}:M/*}
|
||||
|
||||
# For installworld need to ensure that the looked-up compiler metadata is
|
||||
# passed along rather than trying to run cc from the restricted
|
||||
@@ -530,8 +549,7 @@ BFLAGS+= -B${CROSS_BINUTILS_PREFIX}
|
||||
.endif
|
||||
|
||||
# External compiler needs sysroot and target flags.
|
||||
.if ${MK_CROSS_COMPILER} == "no" || \
|
||||
(${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no")
|
||||
.if ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
|
||||
.if !defined(CROSS_BINUTILS_PREFIX) || !exists(${CROSS_BINUTILS_PREFIX})
|
||||
BFLAGS+= -B${WORLDTMP}/usr/bin
|
||||
.endif
|
||||
@@ -559,7 +577,7 @@ TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/}-${TARGET_ABI}-freebsd11.0
|
||||
XCFLAGS+= -target ${TARGET_TRIPLE}
|
||||
.endif
|
||||
XCFLAGS+= --sysroot=${WORLDTMP}
|
||||
.endif # ${MK_CROSS_COMPILER} == "no"
|
||||
.endif # ${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"
|
||||
|
||||
.if !empty(BFLAGS)
|
||||
XCFLAGS+= ${BFLAGS}
|
||||
@@ -884,7 +902,7 @@ ITOOLS= [ awk cap_mkdb cat chflags chmod chown cmp cp \
|
||||
${LOCAL_ITOOLS}
|
||||
|
||||
# Needed for share/man
|
||||
.if ${MK_MAN} != "no"
|
||||
.if ${MK_MAN_UTILS} != "no"
|
||||
ITOOLS+=makewhatis
|
||||
.endif
|
||||
|
||||
@@ -1561,10 +1579,6 @@ _groff= gnu/usr.bin/groff \
|
||||
_vtfontcvt= usr.bin/vtfontcvt
|
||||
.endif
|
||||
|
||||
.if ${BOOTSTRAPPING} < 900002
|
||||
_sed= usr.bin/sed
|
||||
.endif
|
||||
|
||||
.if ${BOOTSTRAPPING} < 1000033
|
||||
_libopenbsd= lib/libopenbsd
|
||||
_m4= usr.bin/m4
|
||||
@@ -1603,10 +1617,6 @@ _crunchide= usr.sbin/crunch/crunchide
|
||||
_crunchgen= usr.sbin/crunch/crunchgen
|
||||
.endif
|
||||
|
||||
.if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
|
||||
_awk= usr.bin/awk
|
||||
.endif
|
||||
|
||||
# r296926 -P keymap search path, MFC to stable/10 in r298297
|
||||
.if ${BOOTSTRAPPING} < 1003501 || \
|
||||
(${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103)
|
||||
@@ -1674,7 +1684,6 @@ bootstrap-tools: .PHONY
|
||||
${_gperf} \
|
||||
${_groff} \
|
||||
${_dtc} \
|
||||
${_awk} \
|
||||
${_cat} \
|
||||
${_dd} \
|
||||
${_kbdcontrol} \
|
||||
@@ -1682,7 +1691,6 @@ bootstrap-tools: .PHONY
|
||||
${_libopenbsd} \
|
||||
${_makewhatis} \
|
||||
usr.bin/rpcgen \
|
||||
${_sed} \
|
||||
${_yacc} \
|
||||
${_m4} \
|
||||
${_lex} \
|
||||
@@ -1800,7 +1808,6 @@ _elftctools= lib/libelftc \
|
||||
usr.bin/elfcopy
|
||||
.endif
|
||||
|
||||
.if ${MK_CROSS_COMPILER} != "no"
|
||||
.if ${MK_CLANG_BOOTSTRAP} != "no"
|
||||
_clang= usr.bin/clang
|
||||
_clang_libs= lib/clang
|
||||
@@ -1808,7 +1815,6 @@ _clang_libs= lib/clang
|
||||
.if ${MK_GCC_BOOTSTRAP} != "no"
|
||||
_cc= gnu/usr.bin/cc
|
||||
.endif
|
||||
.endif
|
||||
.if ${MK_USB} != "no"
|
||||
_usb_tools= sys/boot/usb/tools
|
||||
.endif
|
||||
@@ -2356,11 +2362,11 @@ check-old-dirs: .PHONY
|
||||
done
|
||||
|
||||
delete-old: delete-old-files delete-old-dirs .PHONY
|
||||
@echo "To remove old libraries run '${MAKE} delete-old-libs'."
|
||||
@echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
|
||||
|
||||
check-old: check-old-files check-old-libs check-old-dirs .PHONY
|
||||
@echo "To remove old files and directories run '${MAKE} delete-old'."
|
||||
@echo "To remove old libraries run '${MAKE} delete-old-libs'."
|
||||
@echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
|
||||
@echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
|
||||
|
||||
.endif
|
||||
|
||||
|
||||
+2
-2
@@ -81,8 +81,8 @@ LIBCOMPATCFLAGS+= -B${LIBCOMPATTMP}/usr/lib${libcompat}
|
||||
LIBCOMPATCFLAGS+= -isystem ${LIBCOMPATTMP}/usr/include
|
||||
# Force using libc++ for external GCC.
|
||||
# XXX: This should be checking MK_GNUCXX == no
|
||||
.if ${X_COMPILER_VERSION} >= 40800 && (${MK_CROSS_COMPILER} == "no" || \
|
||||
(${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no"))
|
||||
.if ${X_COMPILER_VERSION} >= 40800 && \
|
||||
(${MK_CLANG_BOOTSTRAP} == "no" && ${MK_GCC_BOOTSTRAP} == "no")
|
||||
LIBCOMPATCXXFLAGS+= -isystem ${LIBCOMPATTMP}/usr/include/c++/v1 -std=c++11 \
|
||||
-nostdinc++ -L${LIBCOMPAT_OBJTREE}${.CURDIR}/lib/libc++
|
||||
.endif
|
||||
|
||||
+3
-9
@@ -203,7 +203,7 @@ OLD_FILES+=usr/share/man/man9/rman_await_resource.9.gz
|
||||
# 20160517: ReiserFS removed
|
||||
OLD_FILES+=usr/share/man/man5/reiserfs.5.gz
|
||||
# 20160430: kvm_getfiles(3) removed from kvm(3)
|
||||
OLD_LIBS+=usr/lib/libkvm.so.6
|
||||
OLD_LIBS+=lib/libkvm.so.6
|
||||
OLD_FILES+=usr/share/man/man3/kvm_getfiles.3.gz
|
||||
# 20160423: remove mroute6d
|
||||
OLD_FILES+=etc/rc.d/mroute6d
|
||||
@@ -229,6 +229,7 @@ OLD_LIBS+=usr/lib/libdevinfo.so.5
|
||||
OLD_LIBS+=usr/lib32/libdevinfo.so.5
|
||||
# 20160305: new clang import which bumps version from 3.7.1 to 3.8.0.
|
||||
OLD_FILES+=usr/bin/macho-dump
|
||||
OLD_FILES+=usr/bin/tblgen
|
||||
OLD_FILES+=usr/lib/clang/3.7.1/include/sanitizer/allocator_interface.h
|
||||
OLD_FILES+=usr/lib/clang/3.7.1/include/sanitizer/asan_interface.h
|
||||
OLD_FILES+=usr/lib/clang/3.7.1/include/sanitizer/common_interface_defs.h
|
||||
@@ -460,13 +461,6 @@ OLD_FILES+=usr/share/locale/kk_KZ.PT154/LC_MONETARY
|
||||
OLD_FILES+=usr/share/locale/kk_KZ.PT154/LC_NUMERIC
|
||||
OLD_FILES+=usr/share/locale/kk_KZ.PT154/LC_TIME
|
||||
OLD_DIRS+=usr/share/locale/kk_KZ.PT154/
|
||||
OLD_FILES+=usr/share/locale/kk_KZ.UTF-8/LC_COLLATE
|
||||
OLD_FILES+=usr/share/locale/kk_KZ.UTF-8/LC_CTYPE
|
||||
OLD_FILES+=usr/share/locale/kk_KZ.UTF-8/LC_MESSAGES
|
||||
OLD_FILES+=usr/share/locale/kk_KZ.UTF-8/LC_MONETARY
|
||||
OLD_FILES+=usr/share/locale/kk_KZ.UTF-8/LC_NUMERIC
|
||||
OLD_FILES+=usr/share/locale/kk_KZ.UTF-8/LC_TIME
|
||||
OLD_DIRS+=usr/share/locale/kk_KZ.UTF-8
|
||||
OLD_FILES+=usr/share/locale/la_LN.ISO8859-1/LC_COLLATE
|
||||
OLD_FILES+=usr/share/locale/la_LN.ISO8859-1/LC_CTYPE
|
||||
OLD_FILES+=usr/share/locale/la_LN.ISO8859-1/LC_TIME
|
||||
@@ -8014,7 +8008,7 @@ OLD_FILES+=usr/share/man/man5/usbd.conf.5.gz
|
||||
.if ${TARGET_ARCH} != "i386" && ${TARGET_ARCH} != "amd64"
|
||||
OLD_FILES+=usr/share/man/man8/boot_i386.8.gz
|
||||
.endif
|
||||
.if ${TARGET_ARCH} != "aarch64" && ${TARGET_CPUARCH} != "arm" && \
|
||||
.if ${TARGET_ARCH} != "aarch64" && ${TARGET} != "arm" && \
|
||||
${TARGET_ARCH} != "powerpc" && ${TARGET_ARCH} != "powerpc64" && \
|
||||
${TARGET_ARCH} != "sparc64"
|
||||
OLD_FILES+=usr/share/man/man8/ofwdump.8.gz
|
||||
|
||||
@@ -16,28 +16,17 @@ from older versions of FreeBSD, try WITHOUT_CLANG and WITH_GCC to bootstrap to
|
||||
the tip of head, and then rebuild without this option. The bootstrap process
|
||||
from older version of current across the gcc/clang cutover is a bit fragile.
|
||||
|
||||
NOTE TO PEOPLE WHO THINK THAT FreeBSD 11.x IS SLOW:
|
||||
FreeBSD 11.x has many debugging features turned on, in both the kernel
|
||||
and userland. These features attempt to detect incorrect use of
|
||||
system primitives, and encourage loud failure through extra sanity
|
||||
checking and fail stop semantics. They also substantially impact
|
||||
system performance. If you want to do performance measurement,
|
||||
benchmarking, and optimization, you'll want to turn them off. This
|
||||
includes various WITNESS- related kernel options, INVARIANTS, malloc
|
||||
debugging flags in userland, and various verbose features in the
|
||||
kernel. Many developers choose to disable these features on build
|
||||
machines to maximize performance. (To completely disable malloc
|
||||
debugging, define MALLOC_PRODUCTION in /etc/make.conf, or to merely
|
||||
disable the most expensive debugging functionality run
|
||||
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
|
||||
20160928:
|
||||
11.0-RELEASE.
|
||||
|
||||
20160622:
|
||||
The libc stub for the pipe(2) system call has been replaced with
|
||||
a wrapper which calls the pipe2(2) system call and the pipe(2) is now
|
||||
only implemented by the kernels which include "options
|
||||
COMPAT_FREEBSD10" in their config file (this is the default).
|
||||
Users should ensure that this option is enabled in their kernel
|
||||
or upgrade userspace to r302092 before upgrading their kernel.
|
||||
a wrapper that calls the pipe2(2) system call and the pipe(2)
|
||||
system call is now only implemented by the kernels that include
|
||||
"options COMPAT_FREEBSD10" in their config file (this is the
|
||||
default). Users should ensure that this option is enabled in
|
||||
their kernel or upgrade userspace to r302092 before upgrading their
|
||||
kernel.
|
||||
|
||||
20160527:
|
||||
CAM will now strip leading spaces from SCSI disks' serial numbers.
|
||||
|
||||
@@ -612,6 +612,7 @@ main(int argc, char *argv[])
|
||||
|
||||
if (nkept == 0) {
|
||||
printheader();
|
||||
xo_finish();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -465,6 +465,15 @@ place in the configuration, and is removed from the spare list of all active
|
||||
pools.
|
||||
.Pp
|
||||
Spares cannot replace log devices.
|
||||
.Pp
|
||||
This feature requires a userland helper.
|
||||
FreeBSD provides
|
||||
.Xr zfsd 8
|
||||
for this purpose.
|
||||
It must be manually enabled by adding
|
||||
.Va zfsd_enable="YES"
|
||||
to
|
||||
.Pa /etc/rc.conf .
|
||||
.Ss Intent Log
|
||||
The
|
||||
.Tn ZFS
|
||||
@@ -2023,7 +2032,8 @@ Discarded approximately 29 seconds of transactions.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr zpool-features 7 ,
|
||||
.Xr zfs 8
|
||||
.Xr zfs 8 ,
|
||||
.Xr zfsd 8
|
||||
.Sh AUTHORS
|
||||
This manual page is a
|
||||
.Xr mdoc 7
|
||||
@@ -2040,9 +2050,3 @@ The
|
||||
.Xr mdoc 7
|
||||
implementation of this manual page was initially written by
|
||||
.An Martin Matuska Aq [email protected] .
|
||||
.Sh CAVEATS
|
||||
The
|
||||
.Cm spare
|
||||
feature requires a utility to detect zpool degradation and initiate
|
||||
disk replacement within the zpool.
|
||||
FreeBSD does not provide such a utility at this time.
|
||||
+1
-1
@@ -1 +1 @@
|
||||
v0.10
|
||||
v0.11
|
||||
@@ -142,7 +142,7 @@ main(int argc, char **argv)
|
||||
logfail(EX_CANTCREAT, "cannot build mbox path for `%s/%s'", _PATH_MAILDIR, user);
|
||||
}
|
||||
|
||||
f = open(fn, O_RDONLY|O_CREAT, 0600);
|
||||
f = open(fn, O_RDONLY|O_CREAT|O_NOFOLLOW, 0600);
|
||||
if (f < 0)
|
||||
logfail(EX_NOINPUT, "cannt open mbox `%s'", fn);
|
||||
|
||||
|
||||
+2
-2
@@ -321,7 +321,7 @@ deliver(struct qitem *it)
|
||||
snprintf(errmsg, sizeof(errmsg), "unknown bounce reason");
|
||||
|
||||
retry:
|
||||
syslog(LOG_INFO, "trying delivery");
|
||||
syslog(LOG_INFO, "<%s> trying delivery", it->addr);
|
||||
|
||||
if (it->remote)
|
||||
error = deliver_remote(it);
|
||||
@@ -331,7 +331,7 @@ retry:
|
||||
switch (error) {
|
||||
case 0:
|
||||
delqueue(it);
|
||||
syslog(LOG_INFO, "delivery successful");
|
||||
syslog(LOG_INFO, "<%s> delivery successful", it->addr);
|
||||
exit(EX_OK);
|
||||
|
||||
case 1:
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@
|
||||
#define VERSION "DragonFly Mail Agent " DMA_VERSION
|
||||
|
||||
#define BUF_SIZE 2048
|
||||
#define ERRMSG_SIZE 200
|
||||
#define ERRMSG_SIZE 1024
|
||||
#define USERNAME_SIZE 50
|
||||
#define MIN_RETRY 300 /* 5 minutes */
|
||||
#define MAX_RETRY (3*60*60) /* retry at least every 3 hours */
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
+1
-1
@@ -196,7 +196,7 @@ retry:
|
||||
goto out;
|
||||
}
|
||||
|
||||
error = snprintf(line, sizeof(line), "%sFrom %s\t%s", newline, sender, ctime(&now));
|
||||
error = snprintf(line, sizeof(line), "%sFrom %s %s", newline, sender, ctime(&now));
|
||||
if (error < 0 || (size_t)error >= sizeof(line)) {
|
||||
syslog(LOG_NOTICE, "local delivery deferred: can not write header: %m");
|
||||
goto out;
|
||||
|
||||
+6
-3
@@ -372,11 +372,13 @@ deliver_to_host(struct qitem *it, struct mx_hostentry *host)
|
||||
host->host, host->addr, c, neterr); \
|
||||
snprintf(errmsg, sizeof(errmsg), "%s [%s] did not like our %s:\n%s", \
|
||||
host->host, host->addr, c, neterr); \
|
||||
return (-1); \
|
||||
error = -1; \
|
||||
goto out; \
|
||||
} else if (res != exp) { \
|
||||
syslog(LOG_NOTICE, "remote delivery deferred: %s [%s] failed after %s: %s", \
|
||||
host->host, host->addr, c, neterr); \
|
||||
return (1); \
|
||||
error = 1; \
|
||||
goto out; \
|
||||
}
|
||||
|
||||
/* Check first reply from remote host */
|
||||
@@ -426,7 +428,8 @@ deliver_to_host(struct qitem *it, struct mx_hostentry *host)
|
||||
syslog(LOG_ERR, "remote delivery failed:"
|
||||
" SMTP login failed: %m");
|
||||
snprintf(errmsg, sizeof(errmsg), "SMTP login to %s failed", host->host);
|
||||
return (-1);
|
||||
error = -1;
|
||||
goto out;
|
||||
}
|
||||
/* SMTP login is not available, so try without */
|
||||
else if (error > 0) {
|
||||
|
||||
@@ -2551,7 +2551,7 @@ again:
|
||||
|
||||
case 'w':
|
||||
/* wchar_t */
|
||||
if (!cpp_demangle_push_str(ddata, "wchar_t", 6))
|
||||
if (!cpp_demangle_push_str(ddata, "wchar_t", 7))
|
||||
goto clean;
|
||||
++ddata->cur;
|
||||
goto rtn;
|
||||
|
||||
File renamed without changes.
@@ -4,6 +4,9 @@
|
||||
|
||||
#undef JEMALLOC_OVERRIDE_VALLOC
|
||||
|
||||
#ifndef MALLOC_PRODUCTION
|
||||
#define MALLOC_PRODUCTION
|
||||
#endif
|
||||
#ifndef MALLOC_PRODUCTION
|
||||
#define JEMALLOC_DEBUG
|
||||
#endif
|
||||
|
||||
@@ -1,163 +0,0 @@
|
||||
README for libarchive bundle.
|
||||
|
||||
Questions? Issues?
|
||||
* http://www.libarchive.org is the home for ongoing
|
||||
libarchive development, including documentation, and
|
||||
links to the libarchive mailing lists.
|
||||
* To report an issue, use the issue tracker at
|
||||
https://github.com/libarchive/libarchive/issues
|
||||
* To submit an enhancement to libarchive, please submit
|
||||
a pull request via GitHub.
|
||||
https://github.com/libarchive/libarchive/pulls
|
||||
|
||||
This distribution bundle includes the following components:
|
||||
* libarchive: a library for reading and writing streaming archives
|
||||
* tar: the 'bsdtar' program is a full-featured 'tar'
|
||||
implementation built on libarchive
|
||||
* cpio: the 'bsdcpio' program is a different interface to
|
||||
essentially the same functionality
|
||||
* cat: the 'bsdcat' program is a simple replacement tool for
|
||||
zcat, bzcat, xzcat, and such
|
||||
* examples: Some small example programs that you may find useful.
|
||||
* examples/minitar: a compact sample demonstrating use of libarchive.
|
||||
* contrib: Various items sent to me by third parties;
|
||||
please contact the authors with any questions.
|
||||
|
||||
The top-level directory contains the following information files:
|
||||
* NEWS - highlights of recent changes
|
||||
* COPYING - what you can do with this
|
||||
* INSTALL - installation instructions
|
||||
* README - this file
|
||||
* configure - configuration script, see INSTALL for details.
|
||||
* CMakeLists.txt - input for "cmake" build tool, see INSTALL
|
||||
|
||||
The following files in the top-level directory are used by the
|
||||
'configure' script:
|
||||
* Makefile.am, aclocal.m4, configure.ac
|
||||
- used to build this distribution, only needed by maintainers
|
||||
* Makefile.in, config.h.in
|
||||
- templates used by configure script
|
||||
|
||||
Guide to Documentation installed by this system:
|
||||
* bsdtar.1 explains the use of the bsdtar program
|
||||
* bsdcpio.1 explains the use of the bsdcpio program
|
||||
* bsdcat.1 explains the use of the bsdcat program
|
||||
* libarchive.3 gives an overview of the library as a whole
|
||||
* archive_read.3, archive_write.3, archive_write_disk.3, and
|
||||
archive_read_disk.3 provide detailed calling sequences for the read
|
||||
and write APIs
|
||||
* archive_entry.3 details the "struct archive_entry" utility class
|
||||
* archive_internals.3 provides some insight into libarchive's
|
||||
internal structure and operation.
|
||||
* libarchive-formats.5 documents the file formats supported by the library
|
||||
* cpio.5, mtree.5, and tar.5 provide detailed information about these
|
||||
popular archive formats, including hard-to-find details about
|
||||
modern cpio and tar variants.
|
||||
The manual pages above are provided in the 'doc' directory in
|
||||
a number of different formats.
|
||||
|
||||
You should also read the copious comments in "archive.h" and the
|
||||
source code for the sample programs for more details. Please let us
|
||||
know about any errors or omissions you find.
|
||||
|
||||
Currently, the library automatically detects and reads the following fomats:
|
||||
* GNU tar format (including GNU long filenames, long link names, and sparse files)
|
||||
* Solaris 9 extended tar format (including ACLs)
|
||||
* Old V7 tar archives
|
||||
* POSIX ustar
|
||||
* POSIX pax interchange format
|
||||
* POSIX octet-oriented cpio
|
||||
* SVR4 ASCII cpio
|
||||
* POSIX octet-oriented cpio
|
||||
* Binary cpio (big-endian or little-endian)
|
||||
* 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
|
||||
* 7-Zip archives
|
||||
* Microsoft CAB format
|
||||
* LHA and LZH archives
|
||||
* RAR archives
|
||||
* XAR archives
|
||||
|
||||
The library also detects and handles any of the following before evaluating the archive:
|
||||
* uuencoded files
|
||||
* files with RPM wrapper
|
||||
* gzip compression
|
||||
* bzip2 compression
|
||||
* compress/LZW compression
|
||||
* lzma, lzip, and xz compression
|
||||
* lz4 compression
|
||||
* lzop compression
|
||||
|
||||
The library can create archives in any of the following formats:
|
||||
* 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).
|
||||
* Old GNU tar format
|
||||
* Old V7 tar format
|
||||
* POSIX octet-oriented cpio
|
||||
* SVR4 "newc" cpio
|
||||
* shar archives
|
||||
* ZIP archives (with uncompressed or "deflate" compressed entries)
|
||||
* GNU and BSD 'ar' archives
|
||||
* 'mtree' format
|
||||
* ISO9660 format
|
||||
* 7-Zip archives
|
||||
* XAR archives
|
||||
|
||||
When creating archives, the result can be filtered with any of the following:
|
||||
* uuencode
|
||||
* gzip compression
|
||||
* bzip2 compression
|
||||
* compress/LZW compression
|
||||
* lzma, lzip, and xz compression
|
||||
* lz4 compression
|
||||
* lzop compression
|
||||
|
||||
Notes about the library architecture:
|
||||
|
||||
* This is a heavily stream-oriented system. There is no direct
|
||||
support for in-place modification or random access.
|
||||
|
||||
* The library is designed to be extended with new compression and
|
||||
archive formats. The only requirement is that the format be
|
||||
readable or writable as a stream and that each archive entry be
|
||||
independent. There are articles on the libarchive Wiki explaining
|
||||
how to extend libarchive.
|
||||
|
||||
* On read, compression and format are always detected automatically.
|
||||
|
||||
* I've attempted to minimize static link pollution. If you don't
|
||||
explicitly invoke a particular feature (such as support for a
|
||||
particular compression or format), it won't get pulled in to
|
||||
statically-linked programs. In particular, if you don't explicitly
|
||||
enable a particular compression or decompression support, you won't
|
||||
need to link against the corresponding compression or decompression
|
||||
libraries. This also reduces the size of statically-linked
|
||||
binaries in environments where that matters.
|
||||
|
||||
* On read, the library accepts whatever blocks you hand it.
|
||||
Your read callback is free to pass the library a byte at a time
|
||||
or mmap the entire archive and give it to the library at once.
|
||||
On write, the library always produces correctly-blocked output.
|
||||
|
||||
* The object-style approach allows you to have multiple archive streams
|
||||
open at once. bsdtar uses this in its "@archive" extension.
|
||||
|
||||
* The archive itself is read/written using callback functions.
|
||||
You can read an archive directly from an in-memory buffer or
|
||||
write it to a socket, if you wish. There are some utility
|
||||
functions to provide easy-to-use "open file," etc, capabilities.
|
||||
|
||||
* The read/write APIs are designed to allow individual entries
|
||||
to be read or written to any data source: You can create
|
||||
a block of data in memory and add it to a tar archive without
|
||||
first writing a temporary file. You can also read an entry from
|
||||
an archive and write the data directly to a socket. If you want
|
||||
to read/write entries to disk, there are convenience functions to
|
||||
make this especially easy.
|
||||
|
||||
* Note: "pax interchange format" is really an extended tar format,
|
||||
despite what the name says.
|
||||
@@ -0,0 +1,222 @@
|
||||
# Welcome to libarchive!
|
||||
|
||||
The libarchive project develops a portable, efficient C library that
|
||||
can read and write streaming archives in a variety of formats. It
|
||||
also includes implementations of the common `tar`, `cpio`, and `zcat`
|
||||
command-line tools that use the libarchive library.
|
||||
|
||||
## Questions? Issues?
|
||||
|
||||
* http://www.libarchive.org is the home for ongoing
|
||||
libarchive development, including documentation,
|
||||
and links to the libarchive mailing lists.
|
||||
* To report an issue, use the issue tracker at
|
||||
https://github.com/libarchive/libarchive/issues
|
||||
* To submit an enhancement to libarchive, please
|
||||
submit a pull request via GitHub: https://github.com/libarchive/libarchive/pulls
|
||||
|
||||
## Contents of the Distribution
|
||||
|
||||
This distribution bundle includes the following major components:
|
||||
|
||||
* **libarchive**: a library for reading and writing streaming archives
|
||||
* **tar**: the 'bsdtar' program is a full-featured 'tar' implementation built on libarchive
|
||||
* **cpio**: the 'bsdcpio' program is a different interface to essentially the same functionality
|
||||
* **cat**: the 'bsdcat' program is a simple replacement tool for zcat, bzcat, xzcat, and such
|
||||
* **examples**: Some small example programs that you may find useful.
|
||||
* **examples/minitar**: a compact sample demonstrating use of libarchive.
|
||||
* **contrib**: Various items sent to me by third parties; please contact the authors with any questions.
|
||||
|
||||
The top-level directory contains the following information files:
|
||||
|
||||
* **NEWS** - highlights of recent changes
|
||||
* **COPYING** - what you can do with this
|
||||
* **INSTALL** - installation instructions
|
||||
* **README** - this file
|
||||
* **CMakeLists.txt** - input for "cmake" build tool, see INSTALL
|
||||
* **configure** - configuration script, see INSTALL for details. If your copy of the source lacks a `configure` script, you can try to construct it by running the script in `build/autogen.sh` (or use `cmake`).
|
||||
|
||||
The following files in the top-level directory are used by the 'configure' script:
|
||||
* `Makefile.am`, `aclocal.m4`, `configure.ac` - used to build this distribution, only needed by maintainers
|
||||
* `Makefile.in`, `config.h.in` - templates used by configure script
|
||||
|
||||
## Documentation
|
||||
|
||||
In addition to the informational articles and documentation
|
||||
in the online [libarchive Wiki](https://github.com/libarchive/libarchive/wiki),
|
||||
the distribution also includes a number of manual pages:
|
||||
|
||||
* bsdtar.1 explains the use of the bsdtar program
|
||||
* bsdcpio.1 explains the use of the bsdcpio program
|
||||
* bsdcat.1 explains the use of the bsdcat program
|
||||
* libarchive.3 gives an overview of the library as a whole
|
||||
* archive_read.3, archive_write.3, archive_write_disk.3, and
|
||||
archive_read_disk.3 provide detailed calling sequences for the read
|
||||
and write APIs
|
||||
* archive_entry.3 details the "struct archive_entry" utility class
|
||||
* archive_internals.3 provides some insight into libarchive's
|
||||
internal structure and operation.
|
||||
* libarchive-formats.5 documents the file formats supported by the library
|
||||
* cpio.5, mtree.5, and tar.5 provide detailed information about these
|
||||
popular archive formats, including hard-to-find details about
|
||||
modern cpio and tar variants.
|
||||
|
||||
The manual pages above are provided in the 'doc' directory in
|
||||
a number of different formats.
|
||||
|
||||
You should also read the copious comments in `archive.h` and the
|
||||
source code for the sample programs for more details. Please let us
|
||||
know about any errors or omissions you find.
|
||||
|
||||
## Supported Formats
|
||||
|
||||
Currently, the library automatically detects and reads the following fomats:
|
||||
* Old V7 tar archives
|
||||
* POSIX ustar
|
||||
* GNU tar format (including GNU long filenames, long link names, and sparse files)
|
||||
* Solaris 9 extended tar format (including ACLs)
|
||||
* POSIX pax interchange format
|
||||
* POSIX octet-oriented cpio
|
||||
* SVR4 ASCII cpio
|
||||
* POSIX octet-oriented cpio
|
||||
* Binary cpio (big-endian or little-endian)
|
||||
* ISO9660 CD-ROM images (with optional Rockridge or Joliet extensions)
|
||||
* ZIP archives (with uncompressed or "deflate" compressed entries, including support for encrypted Zip archives)
|
||||
* GNU and BSD 'ar' archives
|
||||
* 'mtree' format
|
||||
* 7-Zip archives
|
||||
* Microsoft CAB format
|
||||
* LHA and LZH archives
|
||||
* RAR archives (with some limitations due to RAR's proprietary status)
|
||||
* XAR archives
|
||||
|
||||
The library also detects and handles any of the following before evaluating the archive:
|
||||
* uuencoded files
|
||||
* files with RPM wrapper
|
||||
* gzip compression
|
||||
* bzip2 compression
|
||||
* compress/LZW compression
|
||||
* lzma, lzip, and xz compression
|
||||
* lz4 compression
|
||||
* lzop compression
|
||||
|
||||
The library can create archives in any of the following formats:
|
||||
* 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).
|
||||
* Old GNU tar format
|
||||
* Old V7 tar format
|
||||
* POSIX octet-oriented cpio
|
||||
* SVR4 "newc" cpio
|
||||
* shar archives
|
||||
* ZIP archives (with uncompressed or "deflate" compressed entries)
|
||||
* GNU and BSD 'ar' archives
|
||||
* 'mtree' format
|
||||
* ISO9660 format
|
||||
* 7-Zip archives
|
||||
* XAR archives
|
||||
|
||||
When creating archives, the result can be filtered with any of the following:
|
||||
* uuencode
|
||||
* gzip compression
|
||||
* bzip2 compression
|
||||
* compress/LZW compression
|
||||
* lzma, lzip, and xz compression
|
||||
* lz4 compression
|
||||
* lzop compression
|
||||
|
||||
## Notes about the Library Design
|
||||
|
||||
The following notes address many of the most common
|
||||
questions we are asked about libarchive:
|
||||
|
||||
* This is a heavily stream-oriented system. That means that
|
||||
it is optimized to read or write the archive in a single
|
||||
pass from beginning to end. For example, this allows
|
||||
libarchive to process archives too large to store on disk
|
||||
by processing them on-the-fly as they are read from or
|
||||
written to a network or tape drive. This also makes
|
||||
libarchive useful for tools that need to produce
|
||||
archives on-the-fly (such as webservers that provide
|
||||
archived contents of a users account).
|
||||
|
||||
* In-place modification and random access to the contents
|
||||
of an archive are not directly supported. For some formats,
|
||||
this is not an issue: For example, tar.gz archives are not
|
||||
designed for random access. In some other cases, libarchive
|
||||
can re-open an archive and scan it from the beginning quickly
|
||||
enough to provide the needed abilities even without true
|
||||
random access. Of course, some applications do require true
|
||||
random access; those applications should consider alternatives
|
||||
to libarchive.
|
||||
|
||||
* The library is designed to be extended with new compression and
|
||||
archive formats. The only requirement is that the format be
|
||||
readable or writable as a stream and that each archive entry be
|
||||
independent. There are articles on the libarchive Wiki explaining
|
||||
how to extend libarchive.
|
||||
|
||||
* On read, compression and format are always detected automatically.
|
||||
|
||||
* The same API is used for all formats; in particular, it's very
|
||||
easy for software using libarchive to transparently handle
|
||||
any of libarchive's archiving formats.
|
||||
|
||||
* Libarchive's automatic support for decompression can be used
|
||||
without archiving by explicitly selecting the "raw" and "empty"
|
||||
formats.
|
||||
|
||||
* I've attempted to minimize static link pollution. If you don't
|
||||
explicitly invoke a particular feature (such as support for a
|
||||
particular compression or format), it won't get pulled in to
|
||||
statically-linked programs. In particular, if you don't explicitly
|
||||
enable a particular compression or decompression support, you won't
|
||||
need to link against the corresponding compression or decompression
|
||||
libraries. This also reduces the size of statically-linked
|
||||
binaries in environments where that matters.
|
||||
|
||||
* The library is generally _thread safe_ depending on the platform:
|
||||
it does not define any global variables of its own. However, some
|
||||
platforms do not provide fully thread-safe versions of key C library
|
||||
functions. On those platforms, libarchive will use the non-thread-safe
|
||||
functions. Patches to improve this are of great interest to us.
|
||||
|
||||
* In particular, libarchive's modules to read or write a directory
|
||||
tree do use `chdir()` to optimize the directory traversals. This
|
||||
can cause problems for programs that expect to do disk access from
|
||||
multiple threads. Of course, those modules are completely
|
||||
optional and you can use the rest of libarchive without them.
|
||||
|
||||
* The library is _not_ thread aware, however. It does no locking
|
||||
or thread management of any kind. If you create a libarchive
|
||||
object and need to access it from multiple threads, you will
|
||||
need to provide your own locking.
|
||||
|
||||
* On read, the library accepts whatever blocks you hand it.
|
||||
Your read callback is free to pass the library a byte at a time
|
||||
or mmap the entire archive and give it to the library at once.
|
||||
On write, the library always produces correctly-blocked output.
|
||||
|
||||
* The object-style approach allows you to have multiple archive streams
|
||||
open at once. bsdtar uses this in its "@archive" extension.
|
||||
|
||||
* The archive itself is read/written using callback functions.
|
||||
You can read an archive directly from an in-memory buffer or
|
||||
write it to a socket, if you wish. There are some utility
|
||||
functions to provide easy-to-use "open file," etc, capabilities.
|
||||
|
||||
* The read/write APIs are designed to allow individual entries
|
||||
to be read or written to any data source: You can create
|
||||
a block of data in memory and add it to a tar archive without
|
||||
first writing a temporary file. You can also read an entry from
|
||||
an archive and write the data directly to a socket. If you want
|
||||
to read/write entries to disk, there are convenience functions to
|
||||
make this especially easy.
|
||||
|
||||
* Note: The "pax interchange format" is a POSIX standard extended tar
|
||||
format that should be used when the older _ustar_ format is not
|
||||
appropriate. It has many advantages over other tar formats
|
||||
(including the legacy GNU tar format) and is widely supported by
|
||||
current tar implementations.
|
||||
|
||||
@@ -83,7 +83,7 @@ DEFINE_TEST(test_version)
|
||||
if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
|
||||
++q;
|
||||
/* Skip arbitrary third-party version numbers. */
|
||||
while (s > 0 && (*q == ' ' || *q == '/' || *q == '.' || isalnum(*q))) {
|
||||
while (s > 0 && (*q == ' ' || *q == '-' || *q == '/' || *q == '.' || isalnum(*q))) {
|
||||
++q;
|
||||
--s;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ static const struct option {
|
||||
} cpio_longopts[] = {
|
||||
{ "b64encode", 0, OPTION_B64ENCODE },
|
||||
{ "create", 0, 'o' },
|
||||
{ "dereference", 0, 'L' },
|
||||
{ "dot", 0, 'V' },
|
||||
{ "extract", 0, 'i' },
|
||||
{ "file", 1, 'F' },
|
||||
|
||||
@@ -75,7 +75,7 @@ verify(const char *p, size_t s)
|
||||
if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
|
||||
++q;
|
||||
/* Skip arbitrary third-party version numbers. */
|
||||
while (s > 0 && (*q == ' ' || *q == '/' || *q == '.' || isalnum(*q))) {
|
||||
while (s > 0 && (*q == ' ' || *q == '-' || *q == '/' || *q == '.' || isalnum(*q))) {
|
||||
++q;
|
||||
--s;
|
||||
}
|
||||
|
||||
@@ -707,10 +707,11 @@ archive_acl_text_l(struct archive_acl *acl, int flags,
|
||||
if (r != 0)
|
||||
return (-1);
|
||||
*p++ = separator;
|
||||
if (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)
|
||||
if (name == NULL || (flags & ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID)) {
|
||||
id = ap->id;
|
||||
else
|
||||
} else {
|
||||
id = -1;
|
||||
}
|
||||
append_entry(&p, NULL, ap->tag, name,
|
||||
ap->permset, id);
|
||||
count++;
|
||||
|
||||
@@ -655,7 +655,7 @@ add_pattern_from_file(struct archive_match *a, struct match_list *mlist,
|
||||
}
|
||||
}
|
||||
|
||||
/* If something error happend, report it immediately. */
|
||||
/* If an error occurred, report it immediately. */
|
||||
if (r < ARCHIVE_OK) {
|
||||
archive_copy_error(&(a->archive), ar);
|
||||
archive_read_free(ar);
|
||||
|
||||
@@ -159,6 +159,15 @@
|
||||
#define CAN_RESTORE_METADATA_FD
|
||||
#endif
|
||||
|
||||
/*
|
||||
* glibc 2.24 deprecates readdir_r
|
||||
*/
|
||||
#if defined(HAVE_READDIR_R) && (!defined(__GLIBC__) || !defined(__GLIBC_MINOR__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 24))
|
||||
#define USE_READDIR_R 1
|
||||
#else
|
||||
#undef USE_READDIR_R
|
||||
#endif
|
||||
|
||||
/* Set up defaults for internal error codes. */
|
||||
#ifndef ARCHIVE_ERRNO_FILE_FORMAT
|
||||
#if HAVE_EFTYPE
|
||||
|
||||
@@ -19,7 +19,7 @@ If you need the compatibility with original PPMd var.H, you can use external Ran
|
||||
#define PPMD7_MAX_ORDER 64
|
||||
|
||||
#define PPMD7_MIN_MEM_SIZE (1 << 11)
|
||||
#define PPMD7_MAX_MEM_SIZE (0xFFFFFFFF - 12 * 3)
|
||||
#define PPMD7_MAX_MEM_SIZE (0xFFFFFFFFu - 12 * 3)
|
||||
|
||||
struct CPpmd7_Context_;
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ void
|
||||
__archive_read_reset_passphrase(struct archive_read *a)
|
||||
{
|
||||
|
||||
a->passphrases.candiate = -1;
|
||||
a->passphrases.candidate = -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -137,31 +137,31 @@ __archive_read_next_passphrase(struct archive_read *a)
|
||||
struct archive_read_passphrase *p;
|
||||
const char *passphrase;
|
||||
|
||||
if (a->passphrases.candiate < 0) {
|
||||
if (a->passphrases.candidate < 0) {
|
||||
/* Count out how many passphrases we have. */
|
||||
int cnt = 0;
|
||||
|
||||
for (p = a->passphrases.first; p != NULL; p = p->next)
|
||||
cnt++;
|
||||
a->passphrases.candiate = cnt;
|
||||
a->passphrases.candidate = cnt;
|
||||
p = a->passphrases.first;
|
||||
} else if (a->passphrases.candiate > 1) {
|
||||
} else if (a->passphrases.candidate > 1) {
|
||||
/* Rotate a passphrase list. */
|
||||
a->passphrases.candiate--;
|
||||
a->passphrases.candidate--;
|
||||
p = remove_passphrases_from_head(a);
|
||||
add_passphrase_to_tail(a, p);
|
||||
/* Pick a new passphrase candiate up. */
|
||||
/* Pick a new passphrase candidate up. */
|
||||
p = a->passphrases.first;
|
||||
} else if (a->passphrases.candiate == 1) {
|
||||
/* This case is that all cadiates failed to decryption. */
|
||||
a->passphrases.candiate = 0;
|
||||
} else if (a->passphrases.candidate == 1) {
|
||||
/* This case is that all candidates failed to decrypt. */
|
||||
a->passphrases.candidate = 0;
|
||||
if (a->passphrases.first->next != NULL) {
|
||||
/* Rotate a passphrase list. */
|
||||
p = remove_passphrases_from_head(a);
|
||||
add_passphrase_to_tail(a, p);
|
||||
}
|
||||
p = NULL;
|
||||
} else /* There is no passphrase candaite. */
|
||||
} else /* There is no passphrase candidate. */
|
||||
p = NULL;
|
||||
|
||||
if (p != NULL)
|
||||
@@ -177,7 +177,7 @@ __archive_read_next_passphrase(struct archive_read *a)
|
||||
if (p == NULL)
|
||||
return (NULL);
|
||||
insert_passphrase_to_head(a, p);
|
||||
a->passphrases.candiate = 1;
|
||||
a->passphrases.candidate = 1;
|
||||
}
|
||||
} else
|
||||
passphrase = NULL;
|
||||
|
||||
@@ -411,20 +411,38 @@ setup_acls(struct archive_read_disk *a,
|
||||
{
|
||||
const char *accpath;
|
||||
acl_t acl;
|
||||
#if HAVE_ACL_IS_TRIVIAL_NP
|
||||
int r;
|
||||
#endif
|
||||
|
||||
accpath = archive_entry_sourcepath(entry);
|
||||
if (accpath == NULL)
|
||||
accpath = archive_entry_pathname(entry);
|
||||
|
||||
if (*fd < 0 && a->tree != NULL) {
|
||||
if (a->follow_symlinks ||
|
||||
archive_entry_filetype(entry) != AE_IFLNK)
|
||||
*fd = a->open_on_current_dir(a->tree,
|
||||
accpath, O_RDONLY | O_NONBLOCK);
|
||||
if (*fd < 0) {
|
||||
if (a->tree_enter_working_dir(a->tree) != 0) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Couldn't access %s", accpath);
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
archive_entry_acl_clear(entry);
|
||||
|
||||
acl = NULL;
|
||||
|
||||
#ifdef ACL_TYPE_NFS4
|
||||
/* Try NFS4 ACL first. */
|
||||
if (*fd >= 0)
|
||||
#if HAVE_ACL_GET_FD_NP
|
||||
acl = acl_get_fd_np(*fd, ACL_TYPE_NFS4);
|
||||
#else
|
||||
acl = acl_get_fd(*fd);
|
||||
#endif
|
||||
#if HAVE_ACL_GET_LINK_NP
|
||||
else if (!a->follow_symlinks)
|
||||
acl = acl_get_link_np(accpath, ACL_TYPE_NFS4);
|
||||
@@ -437,20 +455,31 @@ setup_acls(struct archive_read_disk *a,
|
||||
#endif
|
||||
else
|
||||
acl = acl_get_file(accpath, ACL_TYPE_NFS4);
|
||||
|
||||
#if HAVE_ACL_IS_TRIVIAL_NP
|
||||
/* Ignore "trivial" ACLs that just mirror the file mode. */
|
||||
acl_is_trivial_np(acl, &r);
|
||||
if (r) {
|
||||
acl_free(acl);
|
||||
acl = NULL;
|
||||
if (acl != NULL && acl_is_trivial_np(acl, &r) == 0) {
|
||||
/* Ignore "trivial" ACLs that just mirror the file mode. */
|
||||
if (r) {
|
||||
acl_free(acl);
|
||||
acl = NULL;
|
||||
/*
|
||||
* Simultaneous NFSv4 and POSIX.1e ACLs for the same
|
||||
* entry are not allowed, so we should return here
|
||||
*/
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (acl != NULL) {
|
||||
translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4);
|
||||
r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4);
|
||||
acl_free(acl);
|
||||
return (ARCHIVE_OK);
|
||||
if (r != ARCHIVE_OK) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Couldn't translate NFSv4 ACLs: %s", accpath);
|
||||
}
|
||||
return (r);
|
||||
}
|
||||
#endif
|
||||
#endif /* ACL_TYPE_NFS4 */
|
||||
|
||||
/* Retrieve access ACL from file. */
|
||||
if (*fd >= 0)
|
||||
@@ -467,19 +496,42 @@ setup_acls(struct archive_read_disk *a,
|
||||
#endif
|
||||
else
|
||||
acl = acl_get_file(accpath, ACL_TYPE_ACCESS);
|
||||
|
||||
#if HAVE_ACL_IS_TRIVIAL_NP
|
||||
/* Ignore "trivial" ACLs that just mirror the file mode. */
|
||||
if (acl != NULL && acl_is_trivial_np(acl, &r) == 0) {
|
||||
if (r) {
|
||||
acl_free(acl);
|
||||
acl = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (acl != NULL) {
|
||||
translate_acl(a, entry, acl,
|
||||
r = translate_acl(a, entry, acl,
|
||||
ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
|
||||
acl_free(acl);
|
||||
acl = NULL;
|
||||
if (r != ARCHIVE_OK) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Couldn't translate access ACLs: %s", accpath);
|
||||
return (r);
|
||||
}
|
||||
}
|
||||
|
||||
/* Only directories can have default ACLs. */
|
||||
if (S_ISDIR(archive_entry_mode(entry))) {
|
||||
acl = acl_get_file(accpath, ACL_TYPE_DEFAULT);
|
||||
if (acl != NULL) {
|
||||
translate_acl(a, entry, acl,
|
||||
r = translate_acl(a, entry, acl,
|
||||
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT);
|
||||
acl_free(acl);
|
||||
if (r != ARCHIVE_OK) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Couldn't translate default ACLs: %s",
|
||||
accpath);
|
||||
return (r);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (ARCHIVE_OK);
|
||||
@@ -535,19 +587,23 @@ translate_acl(struct archive_read_disk *a,
|
||||
#ifdef ACL_TYPE_NFS4
|
||||
acl_entry_type_t acl_type;
|
||||
acl_flagset_t acl_flagset;
|
||||
int brand, r;
|
||||
int brand;
|
||||
#endif
|
||||
acl_entry_t acl_entry;
|
||||
acl_permset_t acl_permset;
|
||||
int i, entry_acl_type;
|
||||
int s, ae_id, ae_tag, ae_perm;
|
||||
int r, s, ae_id, ae_tag, ae_perm;
|
||||
const char *ae_name;
|
||||
|
||||
#ifdef ACL_TYPE_NFS4
|
||||
// FreeBSD "brands" ACLs as POSIX.1e or NFSv4
|
||||
// Make sure the "brand" on this ACL is consistent
|
||||
// with the default_entry_acl_type bits provided.
|
||||
acl_get_brand_np(acl, &brand);
|
||||
if (acl_get_brand_np(acl, &brand) != 0) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Failed to read ACL brand");
|
||||
return (ARCHIVE_WARN);
|
||||
}
|
||||
switch (brand) {
|
||||
case ACL_BRAND_POSIX:
|
||||
switch (default_entry_acl_type) {
|
||||
@@ -555,31 +611,43 @@ translate_acl(struct archive_read_disk *a,
|
||||
case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
|
||||
break;
|
||||
default:
|
||||
// XXX set warning message?
|
||||
return ARCHIVE_FAILED;
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Invalid ACL entry type for POSIX.1e ACL");
|
||||
return (ARCHIVE_WARN);
|
||||
}
|
||||
break;
|
||||
case ACL_BRAND_NFS4:
|
||||
if (default_entry_acl_type & ~ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
|
||||
// XXX set warning message?
|
||||
return ARCHIVE_FAILED;
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Invalid ACL entry type for NFSv4 ACL");
|
||||
return (ARCHIVE_WARN);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// XXX set warning message?
|
||||
return ARCHIVE_FAILED;
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Unknown ACL brand");
|
||||
return (ARCHIVE_WARN);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
s = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry);
|
||||
if (s == -1) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Failed to get first ACL entry");
|
||||
return (ARCHIVE_WARN);
|
||||
}
|
||||
while (s == 1) {
|
||||
ae_id = -1;
|
||||
ae_name = NULL;
|
||||
ae_perm = 0;
|
||||
|
||||
acl_get_tag_type(acl_entry, &acl_tag);
|
||||
if (acl_get_tag_type(acl_entry, &acl_tag) != 0) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Failed to get ACL tag type");
|
||||
return (ARCHIVE_WARN);
|
||||
}
|
||||
switch (acl_tag) {
|
||||
case ACL_USER:
|
||||
ae_id = (int)*(uid_t *)acl_get_qualifier(acl_entry);
|
||||
@@ -614,13 +682,18 @@ translate_acl(struct archive_read_disk *a,
|
||||
continue;
|
||||
}
|
||||
|
||||
// XXX acl type maps to allow/deny/audit/YYYY bits
|
||||
// XXX acl_get_entry_type_np on FreeBSD returns EINVAL for
|
||||
// non-NFSv4 ACLs
|
||||
// XXX acl_type maps to allow/deny/audit/YYYY bits
|
||||
entry_acl_type = default_entry_acl_type;
|
||||
#ifdef ACL_TYPE_NFS4
|
||||
r = acl_get_entry_type_np(acl_entry, &acl_type);
|
||||
if (r == 0) {
|
||||
if (default_entry_acl_type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
|
||||
/*
|
||||
* acl_get_entry_type_np() falis with non-NFSv4 ACLs
|
||||
*/
|
||||
if (acl_get_entry_type_np(acl_entry, &acl_type) != 0) {
|
||||
archive_set_error(&a->archive, errno, "Failed "
|
||||
"to get ACL type from a NFSv4 ACL entry");
|
||||
return (ARCHIVE_WARN);
|
||||
}
|
||||
switch (acl_type) {
|
||||
case ACL_ENTRY_TYPE_ALLOW:
|
||||
entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW;
|
||||
@@ -634,29 +707,53 @@ translate_acl(struct archive_read_disk *a,
|
||||
case ACL_ENTRY_TYPE_ALARM:
|
||||
entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALARM;
|
||||
break;
|
||||
default:
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Invalid NFSv4 ACL entry type");
|
||||
return (ARCHIVE_WARN);
|
||||
}
|
||||
|
||||
/*
|
||||
* Libarchive stores "flag" (NFSv4 inheritance bits)
|
||||
* in the ae_perm bitmap.
|
||||
*
|
||||
* acl_get_flagset_np() fails with non-NFSv4 ACLs
|
||||
*/
|
||||
if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Failed to get flagset from a NFSv4 ACL entry");
|
||||
return (ARCHIVE_WARN);
|
||||
}
|
||||
for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
|
||||
r = acl_get_flag_np(acl_flagset,
|
||||
acl_inherit_map[i].platform_inherit);
|
||||
if (r == -1) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Failed to check flag in a NFSv4 "
|
||||
"ACL flagset");
|
||||
return (ARCHIVE_WARN);
|
||||
} else if (r)
|
||||
ae_perm |= acl_inherit_map[i].archive_inherit;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Libarchive stores "flag" (NFSv4 inheritance bits)
|
||||
* in the ae_perm bitmap.
|
||||
*/
|
||||
acl_get_flagset_np(acl_entry, &acl_flagset);
|
||||
for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
|
||||
if (acl_get_flag_np(acl_flagset,
|
||||
acl_inherit_map[i].platform_inherit))
|
||||
ae_perm |= acl_inherit_map[i].archive_inherit;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
acl_get_permset(acl_entry, &acl_permset);
|
||||
if (acl_get_permset(acl_entry, &acl_permset) != 0) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Failed to get ACL permission set");
|
||||
return (ARCHIVE_WARN);
|
||||
}
|
||||
for (i = 0; i < (int)(sizeof(acl_perm_map) / sizeof(acl_perm_map[0])); ++i) {
|
||||
/*
|
||||
* acl_get_perm() is spelled differently on different
|
||||
* platforms; see above.
|
||||
*/
|
||||
if (ACL_GET_PERM(acl_permset, acl_perm_map[i].platform_perm))
|
||||
r = ACL_GET_PERM(acl_permset, acl_perm_map[i].platform_perm);
|
||||
if (r == -1) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Failed to check permission in an ACL permission set");
|
||||
return (ARCHIVE_WARN);
|
||||
} else if (r)
|
||||
ae_perm |= acl_perm_map[i].archive_perm;
|
||||
}
|
||||
|
||||
@@ -665,6 +762,11 @@ translate_acl(struct archive_read_disk *a,
|
||||
ae_id, ae_name);
|
||||
|
||||
s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
|
||||
if (s == -1) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Failed to get next ACL entry");
|
||||
return (ARCHIVE_WARN);
|
||||
}
|
||||
}
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ struct filesystem {
|
||||
int synthetic;
|
||||
int remote;
|
||||
int noatime;
|
||||
#if defined(HAVE_READDIR_R)
|
||||
#if defined(USE_READDIR_R)
|
||||
size_t name_max;
|
||||
#endif
|
||||
long incr_xfer_size;
|
||||
@@ -200,7 +200,7 @@ struct tree {
|
||||
DIR *d;
|
||||
#define INVALID_DIR_HANDLE NULL
|
||||
struct dirent *de;
|
||||
#if defined(HAVE_READDIR_R)
|
||||
#if defined(USE_READDIR_R)
|
||||
struct dirent *dirent;
|
||||
size_t dirent_allocated;
|
||||
#endif
|
||||
@@ -938,7 +938,7 @@ next_entry(struct archive_read_disk *a, struct tree *t,
|
||||
r = archive_match_path_excluded(a->matching, entry);
|
||||
if (r < 0) {
|
||||
archive_set_error(&(a->archive), errno,
|
||||
"Faild : %s", archive_error_string(a->matching));
|
||||
"Failed : %s", archive_error_string(a->matching));
|
||||
return (r);
|
||||
}
|
||||
if (r) {
|
||||
@@ -1041,7 +1041,7 @@ next_entry(struct archive_read_disk *a, struct tree *t,
|
||||
r = archive_match_time_excluded(a->matching, entry);
|
||||
if (r < 0) {
|
||||
archive_set_error(&(a->archive), errno,
|
||||
"Faild : %s", archive_error_string(a->matching));
|
||||
"Failed : %s", archive_error_string(a->matching));
|
||||
return (r);
|
||||
}
|
||||
if (r) {
|
||||
@@ -1067,7 +1067,7 @@ next_entry(struct archive_read_disk *a, struct tree *t,
|
||||
r = archive_match_owner_excluded(a->matching, entry);
|
||||
if (r < 0) {
|
||||
archive_set_error(&(a->archive), errno,
|
||||
"Faild : %s", archive_error_string(a->matching));
|
||||
"Failed : %s", archive_error_string(a->matching));
|
||||
return (r);
|
||||
}
|
||||
if (r) {
|
||||
@@ -1504,10 +1504,19 @@ setup_current_filesystem(struct archive_read_disk *a)
|
||||
struct tree *t = a->tree;
|
||||
struct statfs sfs;
|
||||
#if defined(HAVE_GETVFSBYNAME) && defined(VFCF_SYNTHETIC)
|
||||
# if defined(HAVE_STRUCT_VFSCONF)
|
||||
struct vfsconf vfc;
|
||||
# else
|
||||
/* TODO: configure should set GETVFSBYNAME_ARG_TYPE to make
|
||||
* this accurate; some platforms have both and we need the one that's
|
||||
* used by getvfsbyname()
|
||||
*
|
||||
* Then the following would become:
|
||||
* #if defined(GETVFSBYNAME_ARG_TYPE)
|
||||
* GETVFSBYNAME_ARG_TYPE vfc;
|
||||
* #endif
|
||||
*/
|
||||
# if defined(HAVE_STRUCT_XVFSCONF)
|
||||
struct xvfsconf vfc;
|
||||
# else
|
||||
struct vfsconf vfc;
|
||||
# endif
|
||||
#endif
|
||||
int r, xr = 0;
|
||||
@@ -1583,7 +1592,7 @@ setup_current_filesystem(struct archive_read_disk *a)
|
||||
#endif
|
||||
t->current_filesystem->noatime = 0;
|
||||
|
||||
#if defined(HAVE_READDIR_R)
|
||||
#if defined(USE_READDIR_R)
|
||||
/* Set maximum filename length. */
|
||||
#if defined(HAVE_STRUCT_STATFS_F_NAMEMAX)
|
||||
t->current_filesystem->name_max = sfs.f_namemax;
|
||||
@@ -1606,7 +1615,7 @@ setup_current_filesystem(struct archive_read_disk *a)
|
||||
else
|
||||
t->current_filesystem->name_max = nm;
|
||||
#endif
|
||||
#endif /* HAVE_READDIR_R */
|
||||
#endif /* USE_READDIR_R */
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
@@ -1808,7 +1817,7 @@ setup_current_filesystem(struct archive_read_disk *a)
|
||||
#endif
|
||||
t->current_filesystem->noatime = 0;
|
||||
|
||||
#if defined(HAVE_READDIR_R)
|
||||
#if defined(USE_READDIR_R)
|
||||
/* Set maximum filename length. */
|
||||
t->current_filesystem->name_max = sfs.f_namelen;
|
||||
#endif
|
||||
@@ -1892,7 +1901,7 @@ setup_current_filesystem(struct archive_read_disk *a)
|
||||
#endif
|
||||
t->current_filesystem->noatime = 0;
|
||||
|
||||
#if defined(HAVE_READDIR_R)
|
||||
#if defined(USE_READDIR_R)
|
||||
/* Set maximum filename length. */
|
||||
t->current_filesystem->name_max = sfs.f_namemax;
|
||||
#endif
|
||||
@@ -1909,7 +1918,7 @@ static int
|
||||
setup_current_filesystem(struct archive_read_disk *a)
|
||||
{
|
||||
struct tree *t = a->tree;
|
||||
#if defined(_PC_NAME_MAX) && defined(HAVE_READDIR_R)
|
||||
#if defined(_PC_NAME_MAX) && defined(USE_READDIR_R)
|
||||
long nm;
|
||||
#endif
|
||||
t->current_filesystem->synthetic = -1;/* Not supported */
|
||||
@@ -1921,7 +1930,7 @@ setup_current_filesystem(struct archive_read_disk *a)
|
||||
t->current_filesystem->min_xfer_size = -1;
|
||||
t->current_filesystem->incr_xfer_size = -1;
|
||||
|
||||
#if defined(HAVE_READDIR_R)
|
||||
#if defined(USE_READDIR_R)
|
||||
/* Set maximum filename length. */
|
||||
# if defined(_PC_NAME_MAX)
|
||||
if (tree_current_is_symblic_link_target(t)) {
|
||||
@@ -1949,7 +1958,7 @@ setup_current_filesystem(struct archive_read_disk *a)
|
||||
else
|
||||
t->current_filesystem->name_max = nm;
|
||||
# endif /* _PC_NAME_MAX */
|
||||
#endif /* HAVE_READDIR_R */
|
||||
#endif /* USE_READDIR_R */
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
@@ -2357,7 +2366,7 @@ tree_dir_next_posix(struct tree *t)
|
||||
size_t namelen;
|
||||
|
||||
if (t->d == NULL) {
|
||||
#if defined(HAVE_READDIR_R)
|
||||
#if defined(USE_READDIR_R)
|
||||
size_t dirent_size;
|
||||
#endif
|
||||
|
||||
@@ -2378,7 +2387,7 @@ tree_dir_next_posix(struct tree *t)
|
||||
t->visit_type = r != 0 ? r : TREE_ERROR_DIR;
|
||||
return (t->visit_type);
|
||||
}
|
||||
#if defined(HAVE_READDIR_R)
|
||||
#if defined(USE_READDIR_R)
|
||||
dirent_size = offsetof(struct dirent, d_name) +
|
||||
t->filesystem_table[t->current->filesystem_id].name_max + 1;
|
||||
if (t->dirent == NULL || t->dirent_allocated < dirent_size) {
|
||||
@@ -2395,11 +2404,11 @@ tree_dir_next_posix(struct tree *t)
|
||||
}
|
||||
t->dirent_allocated = dirent_size;
|
||||
}
|
||||
#endif /* HAVE_READDIR_R */
|
||||
#endif /* USE_READDIR_R */
|
||||
}
|
||||
for (;;) {
|
||||
errno = 0;
|
||||
#if defined(HAVE_READDIR_R)
|
||||
#if defined(USE_READDIR_R)
|
||||
r = readdir_r(t->d, t->dirent, &t->de);
|
||||
#ifdef _AIX
|
||||
/* Note: According to the man page, return value 9 indicates
|
||||
@@ -2651,7 +2660,7 @@ tree_free(struct tree *t)
|
||||
if (t == NULL)
|
||||
return;
|
||||
archive_string_free(&t->path);
|
||||
#if defined(HAVE_READDIR_R)
|
||||
#if defined(USE_READDIR_R)
|
||||
free(t->dirent);
|
||||
#endif
|
||||
free(t->sparse_list);
|
||||
|
||||
@@ -221,7 +221,7 @@ struct archive_read {
|
||||
struct {
|
||||
struct archive_read_passphrase *first;
|
||||
struct archive_read_passphrase **last;
|
||||
int candiate;
|
||||
int candidate;
|
||||
archive_passphrase_callback *callback;
|
||||
void *client_data;
|
||||
} passphrases;
|
||||
|
||||
@@ -595,7 +595,7 @@ lz4_filter_read_data_block(struct archive_read_filter *self, const void **p)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Check if an error happend in decompression process. */
|
||||
/* Check if an error occurred in the decompression process. */
|
||||
if (uncompressed_size < 0) {
|
||||
archive_set_error(&(self->archive->archive),
|
||||
ARCHIVE_ERRNO_MISC, "lz4 decompression failed");
|
||||
|
||||
@@ -1715,8 +1715,11 @@ lha_crc16(uint16_t crc, const void *pp, size_t len)
|
||||
#undef bswap16
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400 /* Visual Studio */
|
||||
# define bswap16(x) _byteswap_ushort(x)
|
||||
#elif (defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 8) \
|
||||
|| defined(__clang__)
|
||||
#elif defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || __GNUC__ > 4)
|
||||
/* GCC 4.8 and later has __builtin_bswap16() */
|
||||
# define bswap16(x) __builtin_bswap16(x)
|
||||
#elif defined(__clang__)
|
||||
/* All clang versions have __builtin_bswap16() */
|
||||
# define bswap16(x) __builtin_bswap16(x)
|
||||
#else
|
||||
# define bswap16(x) ((((x) >> 8) & 0xff) | ((x) << 8))
|
||||
|
||||
@@ -136,6 +136,7 @@ struct tar {
|
||||
int64_t entry_padding;
|
||||
int64_t entry_bytes_unconsumed;
|
||||
int64_t realsize;
|
||||
int sparse_allowed;
|
||||
struct sparse_block *sparse_list;
|
||||
struct sparse_block *sparse_last;
|
||||
int64_t sparse_offset;
|
||||
@@ -1128,8 +1129,15 @@ header_common(struct archive_read *a, struct tar *tar,
|
||||
if (tar->entry_bytes_remaining < 0) {
|
||||
tar->entry_bytes_remaining = 0;
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Tar entry has negative size?");
|
||||
err = ARCHIVE_WARN;
|
||||
"Tar entry has negative size");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
if (tar->entry_bytes_remaining == INT64_MAX) {
|
||||
/* Note: tar_atol returns INT64_MAX on overflow */
|
||||
tar->entry_bytes_remaining = 0;
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Tar entry size overflow");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
tar->realsize = tar->entry_bytes_remaining;
|
||||
archive_entry_set_size(entry, tar->entry_bytes_remaining);
|
||||
@@ -1264,6 +1272,14 @@ header_common(struct archive_read *a, struct tar *tar,
|
||||
* sparse information in the extended area.
|
||||
*/
|
||||
/* FALLTHROUGH */
|
||||
case '0':
|
||||
/*
|
||||
* Enable sparse file "read" support only for regular
|
||||
* files and explicit GNU sparse files. However, we
|
||||
* don't allow non-standard file types to be sparse.
|
||||
*/
|
||||
tar->sparse_allowed = 1;
|
||||
/* FALLTHROUGH */
|
||||
default: /* Regular file and non-standard types */
|
||||
/*
|
||||
* Per POSIX: non-recognized types should always be
|
||||
@@ -1723,6 +1739,14 @@ pax_attribute(struct archive_read *a, struct tar *tar,
|
||||
#endif
|
||||
switch (key[0]) {
|
||||
case 'G':
|
||||
/* Reject GNU.sparse.* headers on non-regular files. */
|
||||
if (strncmp(key, "GNU.sparse", 10) == 0 &&
|
||||
!tar->sparse_allowed) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Non-regular file cannot be sparse");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
/* GNU "0.0" sparse pax format. */
|
||||
if (strcmp(key, "GNU.sparse.numblocks") == 0) {
|
||||
tar->sparse_offset = -1;
|
||||
|
||||
@@ -318,7 +318,7 @@ start_over:
|
||||
}
|
||||
memcpy(w->pool.str, fnam.str, fnam.len);
|
||||
w->pool.str[fnam.len] = '\0';
|
||||
/* let noone else know about the pool, it's a secret, shhh */
|
||||
/* let no one else know about the pool, it's a secret, shhh */
|
||||
fnam.str = w->pool.str;
|
||||
|
||||
/* snarf mtime or deduce from rtime
|
||||
|
||||
@@ -418,18 +418,30 @@ zip_time(const char *p)
|
||||
* id1+size1+data1 + id2+size2+data2 ...
|
||||
* triplets. id and size are 2 bytes each.
|
||||
*/
|
||||
static void
|
||||
process_extra(const char *p, size_t extra_length, struct zip_entry* zip_entry)
|
||||
static int
|
||||
process_extra(struct archive_read *a, const char *p, size_t extra_length, struct zip_entry* zip_entry)
|
||||
{
|
||||
unsigned offset = 0;
|
||||
|
||||
while (offset < extra_length - 4) {
|
||||
if (extra_length == 0) {
|
||||
return ARCHIVE_OK;
|
||||
}
|
||||
|
||||
if (extra_length < 4) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Too-small extra data: Need at least 4 bytes, but only found %d bytes", (int)extra_length);
|
||||
return ARCHIVE_FAILED;
|
||||
}
|
||||
while (offset <= extra_length - 4) {
|
||||
unsigned short headerid = archive_le16dec(p + offset);
|
||||
unsigned short datasize = archive_le16dec(p + offset + 2);
|
||||
|
||||
offset += 4;
|
||||
if (offset + datasize > extra_length) {
|
||||
break;
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Extra data overflow: Need %d bytes but only found %d bytes",
|
||||
(int)datasize, (int)(extra_length - offset));
|
||||
return ARCHIVE_FAILED;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Header id 0x%04x, length %d\n",
|
||||
@@ -715,13 +727,13 @@ process_extra(const char *p, size_t extra_length, struct zip_entry* zip_entry)
|
||||
}
|
||||
offset += datasize;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (offset != extra_length)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Extra data field contents do not match reported size!\n");
|
||||
if (offset != extra_length) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Malformed extra data: Consumed %d bytes of %d bytes",
|
||||
(int)offset, (int)extra_length);
|
||||
return ARCHIVE_FAILED;
|
||||
}
|
||||
#endif
|
||||
return ARCHIVE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -840,7 +852,9 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
process_extra(h, extra_length, zip_entry);
|
||||
if (ARCHIVE_OK != process_extra(a, h, extra_length, zip_entry)) {
|
||||
return ARCHIVE_FATAL;
|
||||
}
|
||||
__archive_read_consume(a, extra_length);
|
||||
|
||||
/* Work around a bug in Info-Zip: When reading from a pipe, it
|
||||
@@ -1293,7 +1307,7 @@ zip_read_data_deflate(struct archive_read *a, const void **buff,
|
||||
&& bytes_avail > zip->entry_bytes_remaining) {
|
||||
bytes_avail = (ssize_t)zip->entry_bytes_remaining;
|
||||
}
|
||||
if (bytes_avail <= 0) {
|
||||
if (bytes_avail < 0) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Truncated ZIP file body");
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -2691,7 +2705,9 @@ slurp_central_directory(struct archive_read *a, struct zip *zip)
|
||||
"Truncated ZIP file header");
|
||||
return ARCHIVE_FATAL;
|
||||
}
|
||||
process_extra(p + filename_length, extra_length, zip_entry);
|
||||
if (ARCHIVE_OK != process_extra(a, p + filename_length, extra_length, zip_entry)) {
|
||||
return ARCHIVE_FATAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Mac resource fork files are stored under the
|
||||
|
||||
@@ -580,7 +580,7 @@ void
|
||||
__archive_ensure_cloexec_flag(int fd)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
(void)fd; /* UNSED */
|
||||
(void)fd; /* UNUSED */
|
||||
#else
|
||||
int flags;
|
||||
|
||||
|
||||
@@ -138,6 +138,7 @@ set_acl(struct archive *a, int fd, const char *name,
|
||||
acl_permset_t acl_permset;
|
||||
#ifdef ACL_TYPE_NFS4
|
||||
acl_flagset_t acl_flagset;
|
||||
int r;
|
||||
#endif
|
||||
int ret;
|
||||
int ae_type, ae_permset, ae_tag, ae_id;
|
||||
@@ -152,9 +153,19 @@ set_acl(struct archive *a, int fd, const char *name,
|
||||
if (entries == 0)
|
||||
return (ARCHIVE_OK);
|
||||
acl = acl_init(entries);
|
||||
if (acl == (acl_t)NULL) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to initialize ACL working storage");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
while (archive_acl_next(a, abstract_acl, ae_requested_type, &ae_type,
|
||||
&ae_permset, &ae_tag, &ae_id, &ae_name) == ARCHIVE_OK) {
|
||||
acl_create_entry(&acl, &acl_entry);
|
||||
if (acl_create_entry(&acl, &acl_entry) != 0) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to create a new ACL entry");
|
||||
ret = ARCHIVE_FAILED;
|
||||
goto exit_free;
|
||||
}
|
||||
|
||||
switch (ae_tag) {
|
||||
case ARCHIVE_ENTRY_ACL_USER:
|
||||
@@ -185,50 +196,97 @@ set_acl(struct archive *a, int fd, const char *name,
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
/* XXX */
|
||||
break;
|
||||
archive_set_error(a, ARCHIVE_ERRNO_MISC,
|
||||
"Unknown ACL tag");
|
||||
ret = ARCHIVE_FAILED;
|
||||
goto exit_free;
|
||||
}
|
||||
|
||||
#ifdef ACL_TYPE_NFS4
|
||||
r = 0;
|
||||
switch (ae_type) {
|
||||
case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
|
||||
acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALLOW);
|
||||
r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALLOW);
|
||||
break;
|
||||
case ARCHIVE_ENTRY_ACL_TYPE_DENY:
|
||||
acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_DENY);
|
||||
r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_DENY);
|
||||
break;
|
||||
case ARCHIVE_ENTRY_ACL_TYPE_AUDIT:
|
||||
acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_AUDIT);
|
||||
r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_AUDIT);
|
||||
break;
|
||||
case ARCHIVE_ENTRY_ACL_TYPE_ALARM:
|
||||
acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALARM);
|
||||
r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALARM);
|
||||
break;
|
||||
case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
|
||||
case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
|
||||
// These don't translate directly into the system ACL.
|
||||
break;
|
||||
default:
|
||||
// XXX error handling here.
|
||||
break;
|
||||
archive_set_error(a, ARCHIVE_ERRNO_MISC,
|
||||
"Unknown ACL entry type");
|
||||
ret = ARCHIVE_FAILED;
|
||||
goto exit_free;
|
||||
}
|
||||
if (r != 0) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to set ACL entry type");
|
||||
ret = ARCHIVE_FAILED;
|
||||
goto exit_free;
|
||||
}
|
||||
#endif
|
||||
|
||||
acl_get_permset(acl_entry, &acl_permset);
|
||||
acl_clear_perms(acl_permset);
|
||||
if (acl_get_permset(acl_entry, &acl_permset) != 0) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to get ACL permission set");
|
||||
ret = ARCHIVE_FAILED;
|
||||
goto exit_free;
|
||||
}
|
||||
if (acl_clear_perms(acl_permset) != 0) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to clear ACL permissions");
|
||||
ret = ARCHIVE_FAILED;
|
||||
goto exit_free;
|
||||
}
|
||||
|
||||
for (i = 0; i < (int)(sizeof(acl_perm_map) / sizeof(acl_perm_map[0])); ++i) {
|
||||
if (ae_permset & acl_perm_map[i].archive_perm)
|
||||
acl_add_perm(acl_permset,
|
||||
acl_perm_map[i].platform_perm);
|
||||
if (acl_add_perm(acl_permset,
|
||||
acl_perm_map[i].platform_perm) != 0) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to add ACL permission");
|
||||
ret = ARCHIVE_FAILED;
|
||||
goto exit_free;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ACL_TYPE_NFS4
|
||||
acl_get_flagset_np(acl_entry, &acl_flagset);
|
||||
acl_clear_flags_np(acl_flagset);
|
||||
for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
|
||||
if (ae_permset & acl_inherit_map[i].archive_inherit)
|
||||
acl_add_flag_np(acl_flagset,
|
||||
acl_inherit_map[i].platform_inherit);
|
||||
if (acl_type == ACL_TYPE_NFS4) {
|
||||
/*
|
||||
* acl_get_flagset_np() fails with non-NFSv4 ACLs
|
||||
*/
|
||||
if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to get flagset from an NFSv4 ACL entry");
|
||||
ret = ARCHIVE_FAILED;
|
||||
goto exit_free;
|
||||
}
|
||||
if (acl_clear_flags_np(acl_flagset) != 0) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to clear flags from an NFSv4 ACL flagset");
|
||||
ret = ARCHIVE_FAILED;
|
||||
goto exit_free;
|
||||
}
|
||||
for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
|
||||
if (ae_permset & acl_inherit_map[i].archive_inherit) {
|
||||
if (acl_add_flag_np(acl_flagset,
|
||||
acl_inherit_map[i].platform_inherit) != 0) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to add flag to NFSv4 ACL flagset");
|
||||
ret = ARCHIVE_FAILED;
|
||||
goto exit_free;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -257,6 +315,7 @@ set_acl(struct archive *a, int fd, const char *name,
|
||||
ret = ARCHIVE_WARN;
|
||||
}
|
||||
#endif
|
||||
exit_free:
|
||||
acl_free(acl);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
@@ -140,7 +140,17 @@ __FBSDID("$FreeBSD$");
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
#ifndef O_CLOEXEC
|
||||
#define O_CLOEXEC 0
|
||||
#define O_CLOEXEC 0
|
||||
#endif
|
||||
|
||||
/* Ignore non-int O_NOFOLLOW constant. */
|
||||
/* gnulib's fcntl.h does this on AIX, but it seems practical everywhere */
|
||||
#if defined O_NOFOLLOW && !(INT_MIN <= O_NOFOLLOW && O_NOFOLLOW <= INT_MAX)
|
||||
#undef O_NOFOLLOW
|
||||
#endif
|
||||
|
||||
#ifndef O_NOFOLLOW
|
||||
#define O_NOFOLLOW 0
|
||||
#endif
|
||||
|
||||
struct fixup_entry {
|
||||
@@ -326,12 +336,14 @@ struct archive_write_disk {
|
||||
|
||||
#define HFS_BLOCKS(s) ((s) >> 12)
|
||||
|
||||
static int check_symlinks_fsobj(char *path, int *error_number, struct archive_string *error_string, int flags);
|
||||
static int check_symlinks(struct archive_write_disk *);
|
||||
static int create_filesystem_object(struct archive_write_disk *);
|
||||
static struct fixup_entry *current_fixup(struct archive_write_disk *, const char *pathname);
|
||||
#if defined(HAVE_FCHDIR) && defined(PATH_MAX)
|
||||
static void edit_deep_directories(struct archive_write_disk *ad);
|
||||
#endif
|
||||
static int cleanup_pathname_fsobj(char *path, int *error_number, struct archive_string *error_string, int flags);
|
||||
static int cleanup_pathname(struct archive_write_disk *);
|
||||
static int create_dir(struct archive_write_disk *, char *);
|
||||
static int create_parent_dir(struct archive_write_disk *, char *);
|
||||
@@ -1796,7 +1808,7 @@ edit_deep_directories(struct archive_write_disk *a)
|
||||
char *tail = a->name;
|
||||
|
||||
/* If path is short, avoid the open() below. */
|
||||
if (strlen(tail) <= PATH_MAX)
|
||||
if (strlen(tail) < PATH_MAX)
|
||||
return;
|
||||
|
||||
/* Try to record our starting dir. */
|
||||
@@ -1806,7 +1818,7 @@ edit_deep_directories(struct archive_write_disk *a)
|
||||
return;
|
||||
|
||||
/* As long as the path is too long... */
|
||||
while (strlen(tail) > PATH_MAX) {
|
||||
while (strlen(tail) >= PATH_MAX) {
|
||||
/* Locate a dir prefix shorter than PATH_MAX. */
|
||||
tail += PATH_MAX - 8;
|
||||
while (tail > a->name && *tail != '/')
|
||||
@@ -2014,6 +2026,10 @@ create_filesystem_object(struct archive_write_disk *a)
|
||||
const char *linkname;
|
||||
mode_t final_mode, mode;
|
||||
int r;
|
||||
/* these for check_symlinks_fsobj */
|
||||
char *linkname_copy; /* non-const copy of linkname */
|
||||
struct archive_string error_string;
|
||||
int error_number;
|
||||
|
||||
/* We identify hard/symlinks according to the link names. */
|
||||
/* Since link(2) and symlink(2) don't handle modes, we're done here. */
|
||||
@@ -2022,6 +2038,27 @@ create_filesystem_object(struct archive_write_disk *a)
|
||||
#if !HAVE_LINK
|
||||
return (EPERM);
|
||||
#else
|
||||
archive_string_init(&error_string);
|
||||
linkname_copy = strdup(linkname);
|
||||
if (linkname_copy == NULL) {
|
||||
return (EPERM);
|
||||
}
|
||||
/* TODO: consider using the cleaned-up path as the link target? */
|
||||
r = cleanup_pathname_fsobj(linkname_copy, &error_number, &error_string, a->flags);
|
||||
if (r != ARCHIVE_OK) {
|
||||
archive_set_error(&a->archive, error_number, "%s", error_string.s);
|
||||
free(linkname_copy);
|
||||
/* EPERM is more appropriate than error_number for our callers */
|
||||
return (EPERM);
|
||||
}
|
||||
r = check_symlinks_fsobj(linkname_copy, &error_number, &error_string, a->flags);
|
||||
if (r != ARCHIVE_OK) {
|
||||
archive_set_error(&a->archive, error_number, "%s", error_string.s);
|
||||
free(linkname_copy);
|
||||
/* EPERM is more appropriate than error_number for our callers */
|
||||
return (EPERM);
|
||||
}
|
||||
free(linkname_copy);
|
||||
r = link(linkname, a->name) ? errno : 0;
|
||||
/*
|
||||
* New cpio and pax formats allow hardlink entries
|
||||
@@ -2040,7 +2077,7 @@ create_filesystem_object(struct archive_write_disk *a)
|
||||
a->deferred = 0;
|
||||
} else if (r == 0 && a->filesize > 0) {
|
||||
a->fd = open(a->name,
|
||||
O_WRONLY | O_TRUNC | O_BINARY | O_CLOEXEC);
|
||||
O_WRONLY | O_TRUNC | O_BINARY | O_CLOEXEC | O_NOFOLLOW);
|
||||
__archive_ensure_cloexec_flag(a->fd);
|
||||
if (a->fd < 0)
|
||||
r = errno;
|
||||
@@ -2351,116 +2388,233 @@ current_fixup(struct archive_write_disk *a, const char *pathname)
|
||||
return (a->current_fixup);
|
||||
}
|
||||
|
||||
/* TODO: Make this work. */
|
||||
/*
|
||||
* TODO: The deep-directory support bypasses this; disable deep directory
|
||||
* support if we're doing symlink checks.
|
||||
*/
|
||||
/*
|
||||
* TODO: Someday, integrate this with the deep dir support; they both
|
||||
* scan the path and both can be optimized by comparing against other
|
||||
* recent paths.
|
||||
*/
|
||||
/* TODO: Extend this to support symlinks on Windows Vista and later. */
|
||||
|
||||
/*
|
||||
* Checks the given path to see if any elements along it are symlinks. Returns
|
||||
* ARCHIVE_OK if there are none, otherwise puts an error in errmsg.
|
||||
*/
|
||||
static int
|
||||
check_symlinks(struct archive_write_disk *a)
|
||||
check_symlinks_fsobj(char *path, int *error_number, struct archive_string *error_string, int flags)
|
||||
{
|
||||
#if !defined(HAVE_LSTAT)
|
||||
/* Platform doesn't have lstat, so we can't look for symlinks. */
|
||||
(void)a; /* UNUSED */
|
||||
(void)path; /* UNUSED */
|
||||
(void)error_number; /* UNUSED */
|
||||
(void)error_string; /* UNUSED */
|
||||
(void)flags; /* UNUSED */
|
||||
return (ARCHIVE_OK);
|
||||
#else
|
||||
char *pn;
|
||||
int res = ARCHIVE_OK;
|
||||
char *tail;
|
||||
char *head;
|
||||
int last;
|
||||
char c;
|
||||
int r;
|
||||
struct stat st;
|
||||
int restore_pwd;
|
||||
|
||||
/* Nothing to do here if name is empty */
|
||||
if(path[0] == '\0')
|
||||
return (ARCHIVE_OK);
|
||||
|
||||
/*
|
||||
* Guard against symlink tricks. Reject any archive entry whose
|
||||
* destination would be altered by a symlink.
|
||||
*
|
||||
* Walk the filename in chunks separated by '/'. For each segment:
|
||||
* - if it doesn't exist, continue
|
||||
* - if it's symlink, abort or remove it
|
||||
* - if it's a directory and it's not the last chunk, cd into it
|
||||
* As we go:
|
||||
* head points to the current (relative) path
|
||||
* tail points to the temporary \0 terminating the segment we're currently examining
|
||||
* c holds what used to be in *tail
|
||||
* last is 1 if this is the last tail
|
||||
*/
|
||||
/* Whatever we checked last time doesn't need to be re-checked. */
|
||||
pn = a->name;
|
||||
if (archive_strlen(&(a->path_safe)) > 0) {
|
||||
char *p = a->path_safe.s;
|
||||
while ((*pn != '\0') && (*p == *pn))
|
||||
++p, ++pn;
|
||||
}
|
||||
restore_pwd = open(".", O_RDONLY | O_BINARY | O_CLOEXEC);
|
||||
__archive_ensure_cloexec_flag(restore_pwd);
|
||||
if (restore_pwd < 0)
|
||||
return (ARCHIVE_FATAL);
|
||||
head = path;
|
||||
tail = path;
|
||||
last = 0;
|
||||
/* TODO: reintroduce a safe cache here? */
|
||||
/* Skip the root directory if the path is absolute. */
|
||||
if(pn == a->name && pn[0] == '/')
|
||||
++pn;
|
||||
c = pn[0];
|
||||
/* Keep going until we've checked the entire name. */
|
||||
while (pn[0] != '\0' && (pn[0] != '/' || pn[1] != '\0')) {
|
||||
if(tail == path && tail[0] == '/')
|
||||
++tail;
|
||||
/* Keep going until we've checked the entire name.
|
||||
* head, tail, path all alias the same string, which is
|
||||
* temporarily zeroed at tail, so be careful restoring the
|
||||
* stashed (c=tail[0]) for error messages.
|
||||
* Exiting the loop with break is okay; continue is not.
|
||||
*/
|
||||
while (!last) {
|
||||
/* Skip the separator we just consumed, plus any adjacent ones */
|
||||
while (*tail == '/')
|
||||
++tail;
|
||||
/* Skip the next path element. */
|
||||
while (*pn != '\0' && *pn != '/')
|
||||
++pn;
|
||||
c = pn[0];
|
||||
pn[0] = '\0';
|
||||
while (*tail != '\0' && *tail != '/')
|
||||
++tail;
|
||||
/* is this the last path component? */
|
||||
last = (tail[0] == '\0') || (tail[0] == '/' && tail[1] == '\0');
|
||||
/* temporarily truncate the string here */
|
||||
c = tail[0];
|
||||
tail[0] = '\0';
|
||||
/* Check that we haven't hit a symlink. */
|
||||
r = lstat(a->name, &st);
|
||||
r = lstat(head, &st);
|
||||
if (r != 0) {
|
||||
tail[0] = c;
|
||||
/* We've hit a dir that doesn't exist; stop now. */
|
||||
if (errno == ENOENT)
|
||||
if (errno == ENOENT) {
|
||||
break;
|
||||
} else {
|
||||
/* Treat any other error as fatal - best to be paranoid here
|
||||
* Note: This effectively disables deep directory
|
||||
* support when security checks are enabled.
|
||||
* Otherwise, very long pathnames that trigger
|
||||
* an error here could evade the sandbox.
|
||||
* TODO: We could do better, but it would probably
|
||||
* require merging the symlink checks with the
|
||||
* deep-directory editing. */
|
||||
if (error_number) *error_number = errno;
|
||||
if (error_string)
|
||||
archive_string_sprintf(error_string,
|
||||
"Could not stat %s",
|
||||
path);
|
||||
res = ARCHIVE_FAILED;
|
||||
break;
|
||||
}
|
||||
} else if (S_ISDIR(st.st_mode)) {
|
||||
if (!last) {
|
||||
if (chdir(head) != 0) {
|
||||
tail[0] = c;
|
||||
if (error_number) *error_number = errno;
|
||||
if (error_string)
|
||||
archive_string_sprintf(error_string,
|
||||
"Could not chdir %s",
|
||||
path);
|
||||
res = (ARCHIVE_FATAL);
|
||||
break;
|
||||
}
|
||||
/* Our view is now from inside this dir: */
|
||||
head = tail + 1;
|
||||
}
|
||||
} else if (S_ISLNK(st.st_mode)) {
|
||||
if (c == '\0') {
|
||||
if (last) {
|
||||
/*
|
||||
* Last element is symlink; remove it
|
||||
* so we can overwrite it with the
|
||||
* item being extracted.
|
||||
*/
|
||||
if (unlink(a->name)) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Could not remove symlink %s",
|
||||
a->name);
|
||||
pn[0] = c;
|
||||
return (ARCHIVE_FAILED);
|
||||
if (unlink(head)) {
|
||||
tail[0] = c;
|
||||
if (error_number) *error_number = errno;
|
||||
if (error_string)
|
||||
archive_string_sprintf(error_string,
|
||||
"Could not remove symlink %s",
|
||||
path);
|
||||
res = ARCHIVE_FAILED;
|
||||
break;
|
||||
}
|
||||
a->pst = NULL;
|
||||
/*
|
||||
* Even if we did remove it, a warning
|
||||
* is in order. The warning is silly,
|
||||
* though, if we're just replacing one
|
||||
* symlink with another symlink.
|
||||
*/
|
||||
if (!S_ISLNK(a->mode)) {
|
||||
archive_set_error(&a->archive, 0,
|
||||
"Removing symlink %s",
|
||||
a->name);
|
||||
tail[0] = c;
|
||||
/* FIXME: not sure how important this is to restore
|
||||
if (!S_ISLNK(path)) {
|
||||
if (error_number) *error_number = 0;
|
||||
if (error_string)
|
||||
archive_string_sprintf(error_string,
|
||||
"Removing symlink %s",
|
||||
path);
|
||||
}
|
||||
*/
|
||||
/* Symlink gone. No more problem! */
|
||||
pn[0] = c;
|
||||
return (0);
|
||||
} else if (a->flags & ARCHIVE_EXTRACT_UNLINK) {
|
||||
res = ARCHIVE_OK;
|
||||
break;
|
||||
} else if (flags & ARCHIVE_EXTRACT_UNLINK) {
|
||||
/* User asked us to remove problems. */
|
||||
if (unlink(a->name) != 0) {
|
||||
archive_set_error(&a->archive, 0,
|
||||
"Cannot remove intervening symlink %s",
|
||||
a->name);
|
||||
pn[0] = c;
|
||||
return (ARCHIVE_FAILED);
|
||||
if (unlink(head) != 0) {
|
||||
tail[0] = c;
|
||||
if (error_number) *error_number = 0;
|
||||
if (error_string)
|
||||
archive_string_sprintf(error_string,
|
||||
"Cannot remove intervening symlink %s",
|
||||
path);
|
||||
res = ARCHIVE_FAILED;
|
||||
break;
|
||||
}
|
||||
a->pst = NULL;
|
||||
tail[0] = c;
|
||||
} else {
|
||||
archive_set_error(&a->archive, 0,
|
||||
"Cannot extract through symlink %s",
|
||||
a->name);
|
||||
pn[0] = c;
|
||||
return (ARCHIVE_FAILED);
|
||||
tail[0] = c;
|
||||
if (error_number) *error_number = 0;
|
||||
if (error_string)
|
||||
archive_string_sprintf(error_string,
|
||||
"Cannot extract through symlink %s",
|
||||
path);
|
||||
res = ARCHIVE_FAILED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
pn[0] = c;
|
||||
if (pn[0] != '\0')
|
||||
pn++; /* Advance to the next segment. */
|
||||
/* be sure to always maintain this */
|
||||
tail[0] = c;
|
||||
if (tail[0] != '\0')
|
||||
tail++; /* Advance to the next segment. */
|
||||
}
|
||||
pn[0] = c;
|
||||
/* We've checked and/or cleaned the whole path, so remember it. */
|
||||
archive_strcpy(&a->path_safe, a->name);
|
||||
return (ARCHIVE_OK);
|
||||
/* Catches loop exits via break */
|
||||
tail[0] = c;
|
||||
#ifdef HAVE_FCHDIR
|
||||
/* If we changed directory above, restore it here. */
|
||||
if (restore_pwd >= 0) {
|
||||
r = fchdir(restore_pwd);
|
||||
if (r != 0) {
|
||||
if(error_number) *error_number = errno;
|
||||
if(error_string)
|
||||
archive_string_sprintf(error_string,
|
||||
"chdir() failure");
|
||||
}
|
||||
close(restore_pwd);
|
||||
restore_pwd = -1;
|
||||
if (r != 0) {
|
||||
res = (ARCHIVE_FATAL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* TODO: reintroduce a safe cache here? */
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Check a->name for symlinks, returning ARCHIVE_OK if its clean, otherwise
|
||||
* calls archive_set_error and returns ARCHIVE_{FATAL,FAILED}
|
||||
*/
|
||||
static int
|
||||
check_symlinks(struct archive_write_disk *a)
|
||||
{
|
||||
struct archive_string error_string;
|
||||
int error_number;
|
||||
int rc;
|
||||
archive_string_init(&error_string);
|
||||
rc = check_symlinks_fsobj(a->name, &error_number, &error_string, a->flags);
|
||||
if (rc != ARCHIVE_OK) {
|
||||
archive_set_error(&a->archive, error_number, "%s", error_string.s);
|
||||
}
|
||||
archive_string_free(&error_string);
|
||||
a->pst = NULL; /* to be safe */
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
/*
|
||||
* 1. Convert a path separator from '\' to '/' .
|
||||
@@ -2534,15 +2688,17 @@ cleanup_pathname_win(struct archive_write_disk *a)
|
||||
* is set) if the path is absolute.
|
||||
*/
|
||||
static int
|
||||
cleanup_pathname(struct archive_write_disk *a)
|
||||
cleanup_pathname_fsobj(char *path, int *error_number, struct archive_string *error_string, int flags)
|
||||
{
|
||||
char *dest, *src;
|
||||
char separator = '\0';
|
||||
|
||||
dest = src = a->name;
|
||||
dest = src = path;
|
||||
if (*src == '\0') {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Invalid empty pathname");
|
||||
if (error_number) *error_number = ARCHIVE_ERRNO_MISC;
|
||||
if (error_string)
|
||||
archive_string_sprintf(error_string,
|
||||
"Invalid empty pathname");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
|
||||
@@ -2551,9 +2707,11 @@ cleanup_pathname(struct archive_write_disk *a)
|
||||
#endif
|
||||
/* Skip leading '/'. */
|
||||
if (*src == '/') {
|
||||
if (a->flags & ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Path is absolute");
|
||||
if (flags & ARCHIVE_EXTRACT_SECURE_NOABSOLUTEPATHS) {
|
||||
if (error_number) *error_number = ARCHIVE_ERRNO_MISC;
|
||||
if (error_string)
|
||||
archive_string_sprintf(error_string,
|
||||
"Path is absolute");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
|
||||
@@ -2580,10 +2738,11 @@ cleanup_pathname(struct archive_write_disk *a)
|
||||
} else if (src[1] == '.') {
|
||||
if (src[2] == '/' || src[2] == '\0') {
|
||||
/* Conditionally warn about '..' */
|
||||
if (a->flags & ARCHIVE_EXTRACT_SECURE_NODOTDOT) {
|
||||
archive_set_error(&a->archive,
|
||||
ARCHIVE_ERRNO_MISC,
|
||||
"Path contains '..'");
|
||||
if (flags & ARCHIVE_EXTRACT_SECURE_NODOTDOT) {
|
||||
if (error_number) *error_number = ARCHIVE_ERRNO_MISC;
|
||||
if (error_string)
|
||||
archive_string_sprintf(error_string,
|
||||
"Path contains '..'");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
}
|
||||
@@ -2614,7 +2773,7 @@ cleanup_pathname(struct archive_write_disk *a)
|
||||
* We've just copied zero or more path elements, not including the
|
||||
* final '/'.
|
||||
*/
|
||||
if (dest == a->name) {
|
||||
if (dest == path) {
|
||||
/*
|
||||
* Nothing got copied. The path must have been something
|
||||
* like '.' or '/' or './' or '/././././/./'.
|
||||
@@ -2629,6 +2788,21 @@ cleanup_pathname(struct archive_write_disk *a)
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
static int
|
||||
cleanup_pathname(struct archive_write_disk *a)
|
||||
{
|
||||
struct archive_string error_string;
|
||||
int error_number;
|
||||
int rc;
|
||||
archive_string_init(&error_string);
|
||||
rc = cleanup_pathname_fsobj(a->name, &error_number, &error_string, a->flags);
|
||||
if (rc != ARCHIVE_OK) {
|
||||
archive_set_error(&a->archive, error_number, "%s", error_string.s);
|
||||
}
|
||||
archive_string_free(&error_string);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the parent directory of the specified path, assuming path
|
||||
* is already in mutable storage.
|
||||
|
||||
@@ -436,7 +436,7 @@ struct iso_option {
|
||||
* Type : string
|
||||
* Default: Auto detect
|
||||
* : We check a size of boot image;
|
||||
* : If ths size is just 1.22M/1.44M/2.88M,
|
||||
* : If the size is just 1.22M/1.44M/2.88M,
|
||||
* : we assume boot_type is 'fd';
|
||||
* : otherwise boot_type is 'no-emulation'.
|
||||
* COMPAT :
|
||||
|
||||
@@ -307,7 +307,7 @@ archive_write_ustar_header(struct archive_write *a, struct archive_entry *entry)
|
||||
* case getting WCS failed. On POSIX, this is a
|
||||
* normal operation.
|
||||
*/
|
||||
if (p != NULL && p[strlen(p) - 1] != '/') {
|
||||
if (p != NULL && p[0] != '\0' && p[strlen(p) - 1] != '/') {
|
||||
struct archive_string as;
|
||||
|
||||
archive_string_init(&as);
|
||||
|
||||
@@ -1440,6 +1440,31 @@ assertion_file_size(const char *file, int line, const char *pathname, long size)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Verify mode of 'pathname'. */
|
||||
int
|
||||
assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode)
|
||||
{
|
||||
int mode;
|
||||
int r;
|
||||
|
||||
assertion_count(file, line);
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
failure_start(file, line, "assertFileMode not yet implemented for Windows");
|
||||
#else
|
||||
{
|
||||
struct stat st;
|
||||
r = lstat(pathname, &st);
|
||||
mode = (int)(st.st_mode & 0777);
|
||||
}
|
||||
if (r == 0 && mode == expected_mode)
|
||||
return (1);
|
||||
failure_start(file, line, "File %s has mode %o, expected %o",
|
||||
pathname, mode, expected_mode);
|
||||
#endif
|
||||
failure_finish(NULL);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Assert that 'pathname' is a dir. If mode >= 0, verify that too. */
|
||||
int
|
||||
assertion_is_dir(const char *file, int line, const char *pathname, int mode)
|
||||
|
||||
@@ -182,6 +182,8 @@
|
||||
assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks)
|
||||
#define assertFileSize(pathname, size) \
|
||||
assertion_file_size(__FILE__, __LINE__, pathname, size)
|
||||
#define assertFileMode(pathname, mode) \
|
||||
assertion_file_mode(__FILE__, __LINE__, pathname, mode)
|
||||
#define assertTextFileContents(text, pathname) \
|
||||
assertion_text_file_contents(__FILE__, __LINE__, text, pathname)
|
||||
#define assertFileContainsLinesAnyOrder(pathname, lines) \
|
||||
@@ -246,6 +248,7 @@ int assertion_file_mtime_recent(const char *, int, const char *);
|
||||
int assertion_file_nlinks(const char *, int, const char *, int);
|
||||
int assertion_file_not_exists(const char *, int, const char *);
|
||||
int assertion_file_size(const char *, int, const char *, long);
|
||||
int assertion_file_mode(const char *, int, const char *, int);
|
||||
int assertion_is_dir(const char *, int, const char *, int);
|
||||
int assertion_is_hardlink(const char *, int, const char *, const char *);
|
||||
int assertion_is_not_hardlink(const char *, int, const char *, const char *);
|
||||
|
||||
@@ -70,15 +70,9 @@ set_acls(struct archive_entry *ae, struct myacl_t *acls)
|
||||
}
|
||||
|
||||
static int
|
||||
acl_match(acl_entry_t aclent, struct myacl_t *myacl)
|
||||
{
|
||||
gid_t g, *gp;
|
||||
uid_t u, *up;
|
||||
acl_tag_t tag_type;
|
||||
acl_permset_t opaque_ps;
|
||||
acl_entry_get_perm(acl_entry_t aclent) {
|
||||
int permset = 0;
|
||||
|
||||
acl_get_tag_type(aclent, &tag_type);
|
||||
acl_permset_t opaque_ps;
|
||||
|
||||
/* translate the silly opaque permset to a bitmap */
|
||||
acl_get_permset(aclent, &opaque_ps);
|
||||
@@ -88,10 +82,61 @@ acl_match(acl_entry_t aclent, struct myacl_t *myacl)
|
||||
permset |= ARCHIVE_ENTRY_ACL_WRITE;
|
||||
if (acl_get_perm_np(opaque_ps, ACL_READ))
|
||||
permset |= ARCHIVE_ENTRY_ACL_READ;
|
||||
return permset;
|
||||
}
|
||||
|
||||
if (permset != myacl->permset)
|
||||
#if 0
|
||||
static int
|
||||
acl_get_specific_entry(acl_t acl, acl_tag_t requested_tag_type, int requested_tag) {
|
||||
int entry_id = ACL_FIRST_ENTRY;
|
||||
acl_entry_t acl_entry;
|
||||
acl_tag_t acl_tag_type;
|
||||
|
||||
while (1 == acl_get_entry(acl, entry_id, &acl_entry)) {
|
||||
/* After the first time... */
|
||||
entry_id = ACL_NEXT_ENTRY;
|
||||
|
||||
/* If this matches, return perm mask */
|
||||
acl_get_tag_type(acl_entry, &acl_tag_type);
|
||||
if (acl_tag_type == requested_tag_type) {
|
||||
switch (acl_tag_type) {
|
||||
case ACL_USER_OBJ:
|
||||
if ((uid_t)requested_tag == *(uid_t *)(acl_get_qualifier(acl_entry))) {
|
||||
return acl_entry_get_perm(acl_entry);
|
||||
}
|
||||
break;
|
||||
case ACL_GROUP_OBJ:
|
||||
if ((gid_t)requested_tag == *(gid_t *)(acl_get_qualifier(acl_entry))) {
|
||||
return acl_entry_get_perm(acl_entry);
|
||||
}
|
||||
break;
|
||||
case ACL_USER:
|
||||
case ACL_GROUP:
|
||||
case ACL_OTHER:
|
||||
return acl_entry_get_perm(acl_entry);
|
||||
default:
|
||||
failure("Unexpected ACL tag type");
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
acl_match(acl_entry_t aclent, struct myacl_t *myacl)
|
||||
{
|
||||
gid_t g, *gp;
|
||||
uid_t u, *up;
|
||||
acl_tag_t tag_type;
|
||||
|
||||
if (myacl->permset != acl_entry_get_perm(aclent))
|
||||
return (0);
|
||||
|
||||
acl_get_tag_type(aclent, &tag_type);
|
||||
switch (tag_type) {
|
||||
case ACL_USER_OBJ:
|
||||
if (myacl->tag != ARCHIVE_ENTRY_ACL_USER_OBJ) return (0);
|
||||
@@ -190,7 +235,7 @@ compare_acls(acl_t acl, struct myacl_t *myacls)
|
||||
* Verify ACL restore-to-disk. This test is FreeBSD-specific.
|
||||
*/
|
||||
|
||||
DEFINE_TEST(test_acl_freebsd_posix1e)
|
||||
DEFINE_TEST(test_acl_freebsd_posix1e_restore)
|
||||
{
|
||||
#if !defined(__FreeBSD__)
|
||||
skipping("FreeBSD-specific ACL restore test");
|
||||
@@ -263,3 +308,111 @@ DEFINE_TEST(test_acl_freebsd_posix1e)
|
||||
acl_free(acl);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify ACL reaed-from-disk. This test is FreeBSD-specific.
|
||||
*/
|
||||
DEFINE_TEST(test_acl_freebsd_posix1e_read)
|
||||
{
|
||||
#if !defined(__FreeBSD__)
|
||||
skipping("FreeBSD-specific ACL read test");
|
||||
#elif __FreeBSD__ < 5
|
||||
skipping("ACL read supported only on FreeBSD 5.0 and later");
|
||||
#else
|
||||
struct archive *a;
|
||||
struct archive_entry *ae;
|
||||
int n, fd;
|
||||
const char *acl1_text, *acl2_text;
|
||||
acl_t acl1, acl2;
|
||||
|
||||
/*
|
||||
* Manually construct a directory and two files with
|
||||
* different ACLs. This also serves to verify that ACLs
|
||||
* are supported on the local filesystem.
|
||||
*/
|
||||
|
||||
/* Create a test file f1 with acl1 */
|
||||
acl1_text = "user::rwx,group::rwx,other::rwx,user:1:rw-,group:15:r-x,mask::rwx";
|
||||
acl1 = acl_from_text(acl1_text);
|
||||
assert((void *)acl1 != NULL);
|
||||
fd = open("f1", O_WRONLY | O_CREAT | O_EXCL, 0777);
|
||||
failure("Could not create test file?!");
|
||||
if (!assert(fd >= 0)) {
|
||||
acl_free(acl1);
|
||||
return;
|
||||
}
|
||||
n = acl_set_fd(fd, acl1);
|
||||
acl_free(acl1);
|
||||
if (n != 0 && errno == EOPNOTSUPP) {
|
||||
close(fd);
|
||||
skipping("ACL tests require that ACL support be enabled on the filesystem");
|
||||
return;
|
||||
}
|
||||
if (n != 0 && errno == EINVAL) {
|
||||
close(fd);
|
||||
skipping("This filesystem does not support POSIX.1e ACLs");
|
||||
return;
|
||||
}
|
||||
failure("acl_set_fd(): errno = %d (%s)",
|
||||
errno, strerror(errno));
|
||||
assertEqualInt(0, n);
|
||||
close(fd);
|
||||
|
||||
assertMakeDir("d", 0700);
|
||||
|
||||
/*
|
||||
* Create file d/f1 with acl2
|
||||
*
|
||||
* This differs from acl1 in the u:1: and g:15: permissions.
|
||||
*
|
||||
* This file deliberately has the same name but a different ACL.
|
||||
* Github Issue #777 explains how libarchive's directory traversal
|
||||
* did not always correctly enter directories before attempting
|
||||
* to read ACLs, resulting in reading the ACL from a like-named
|
||||
* file in the wrong directory.
|
||||
*/
|
||||
acl2_text = "user::rwx,group::rwx,other::---,user:1:r--,group:15:r--,mask::rwx";
|
||||
acl2 = acl_from_text(acl2_text);
|
||||
assert((void *)acl2 != NULL);
|
||||
fd = open("d/f1", O_WRONLY | O_CREAT | O_EXCL, 0777);
|
||||
failure("Could not create test file?!");
|
||||
if (!assert(fd >= 0)) {
|
||||
acl_free(acl2);
|
||||
return;
|
||||
}
|
||||
n = acl_set_fd(fd, acl2);
|
||||
acl_free(acl2);
|
||||
if (n != 0 && errno == EOPNOTSUPP) {
|
||||
close(fd);
|
||||
skipping("ACL tests require that ACL support be enabled on the filesystem");
|
||||
return;
|
||||
}
|
||||
if (n != 0 && errno == EINVAL) {
|
||||
close(fd);
|
||||
skipping("This filesystem does not support POSIX.1e ACLs");
|
||||
return;
|
||||
}
|
||||
failure("acl_set_fd(): errno = %d (%s)",
|
||||
errno, strerror(errno));
|
||||
assertEqualInt(0, n);
|
||||
close(fd);
|
||||
|
||||
/* Create a read-from-disk object. */
|
||||
assert(NULL != (a = archive_read_disk_new()));
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_disk_open(a, "."));
|
||||
assert(NULL != (ae = archive_entry_new()));
|
||||
|
||||
/* Walk the dir until we see both of the files */
|
||||
while (ARCHIVE_OK == archive_read_next_header2(a, ae)) {
|
||||
archive_read_disk_descend(a);
|
||||
if (strcmp(archive_entry_pathname(ae), "./f1") == 0) {
|
||||
assertEqualString(archive_entry_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS), acl1_text);
|
||||
|
||||
} else if (strcmp(archive_entry_pathname(ae), "./d/f1") == 0) {
|
||||
assertEqualString(archive_entry_acl_text(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS), acl2_text);
|
||||
}
|
||||
}
|
||||
|
||||
archive_free(a);
|
||||
#endif
|
||||
}
|
||||
@@ -800,8 +800,8 @@ DEFINE_TEST(test_archive_string_conversion)
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
|
||||
assert((fp = fopen(testdata, "w")) != NULL);
|
||||
while ((size = archive_read_data(a, buff, 512)) > 0)
|
||||
fwrite(buff, 1, size, fp);
|
||||
fclose(fp);
|
||||
assertEqualInt(size, fwrite(buff, 1, size, fp));
|
||||
assertEqualInt(0, fclose(fp));
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
|
||||
|
||||
test_archive_string_normalization_nfc(testdata);
|
||||
|
||||
@@ -110,13 +110,17 @@ test_fuzz(const struct files *filesets)
|
||||
for (i = 0; filesets[n].names[i] != NULL; ++i)
|
||||
{
|
||||
tmp = slurpfile(&size, filesets[n].names[i]);
|
||||
rawimage = (char *)realloc(rawimage, oldsize + size);
|
||||
char *newraw = (char *)realloc(rawimage, oldsize + size);
|
||||
if (!assert(newraw != NULL))
|
||||
{
|
||||
free(rawimage);
|
||||
continue;
|
||||
}
|
||||
rawimage = newraw;
|
||||
memcpy(rawimage + oldsize, tmp, size);
|
||||
oldsize += size;
|
||||
size = oldsize;
|
||||
free(tmp);
|
||||
if (!assert(rawimage != NULL))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (size == 0)
|
||||
|
||||
@@ -3603,7 +3603,7 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
|
||||
assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff)));
|
||||
|
||||
/*
|
||||
* Eigth header.
|
||||
* Eighth header.
|
||||
*/
|
||||
assertA(0 == archive_read_next_header(a, &ae));
|
||||
assertEqualString("testdir/testsymlink6", archive_entry_pathname(ae));
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
/*-
|
||||
* Copyright (c) 2016 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 "test.h"
|
||||
__FBSDID("$FreeBSD");
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
|
||||
/*
|
||||
* Github Issue 748 reported problems with end-of-entry handling
|
||||
* with highly-compressible data. This resulted in the end of the
|
||||
* data being truncated (extracted as zero bytes).
|
||||
*/
|
||||
|
||||
/*
|
||||
* Extract the specific test archive that was used to diagnose
|
||||
* Issue 748:
|
||||
*/
|
||||
DEFINE_TEST(test_read_format_zip_high_compression)
|
||||
{
|
||||
const char *refname = "test_read_format_zip_high_compression.zip";
|
||||
char *p;
|
||||
size_t archive_size;
|
||||
struct archive *a;
|
||||
struct archive_entry *entry;
|
||||
|
||||
const void *pv;
|
||||
size_t s;
|
||||
int64_t o;
|
||||
|
||||
extract_reference_file(refname);
|
||||
p = slurpfile(&archive_size, refname);
|
||||
|
||||
assert((a = archive_read_new()) != NULL);
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
|
||||
assertEqualIntA(a, ARCHIVE_OK, read_open_memory_seek(a, p, archive_size, 16 * 1024));
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &entry));
|
||||
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_data_block(a, &pv, &s, &o));
|
||||
assertEqualInt(262144, s);
|
||||
assertEqualInt(0, o);
|
||||
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_data_block(a, &pv, &s, &o));
|
||||
assertEqualInt(160, s);
|
||||
assertEqualInt(262144, o);
|
||||
|
||||
assertEqualInt(ARCHIVE_EOF, archive_read_data_block(a, &pv, &s, &o));
|
||||
|
||||
assertEqualInt(ARCHIVE_OK, archive_free(a));
|
||||
free(p);
|
||||
}
|
||||
|
||||
/*
|
||||
* Synthesize a lot of varying inputs that are highly compressible.
|
||||
*/
|
||||
DEFINE_TEST(test_read_format_zip_high_compression2)
|
||||
{
|
||||
const size_t body_size = 1024 * 1024;
|
||||
const size_t buff_size = 2 * 1024 * 1024;
|
||||
char *body, *body_read, *buff;
|
||||
int n;
|
||||
|
||||
assert((body = malloc(body_size)) != NULL);
|
||||
assert((body_read = malloc(body_size)) != NULL);
|
||||
assert((buff = malloc(buff_size)) != NULL);
|
||||
|
||||
/* Highly-compressible data: all bytes 255, except for a
|
||||
* single 1 byte.
|
||||
* The body is always 256k + 6 bytes long (the internal deflation
|
||||
* buffer is exactly 256k).
|
||||
*/
|
||||
|
||||
for(n = 1024; n < (int)body_size; n += 1024) {
|
||||
struct archive *a;
|
||||
struct archive_entry *entry;
|
||||
size_t used = 0;
|
||||
const void *pv;
|
||||
size_t s;
|
||||
int64_t o;
|
||||
|
||||
memset(body, 255, body_size);
|
||||
body[n] = 1;
|
||||
|
||||
/* Write an archive with a single entry of n bytes. */
|
||||
assert((a = archive_write_new()) != NULL);
|
||||
assertEqualInt(ARCHIVE_OK, archive_write_set_format_zip(a));
|
||||
assertEqualInt(ARCHIVE_OK, archive_write_open_memory(a, buff, buff_size, &used));
|
||||
|
||||
entry = archive_entry_new2(a);
|
||||
archive_entry_set_pathname(entry, "test");
|
||||
archive_entry_set_filetype(entry, AE_IFREG);
|
||||
archive_entry_set_size(entry, 262150);
|
||||
assertEqualInt(ARCHIVE_OK, archive_write_header(a, entry));
|
||||
archive_entry_free(entry);
|
||||
assertEqualInt(262150, archive_write_data(a, body, 262150));
|
||||
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
|
||||
|
||||
/* Read back the entry and verify the contents. */
|
||||
assert((a = archive_read_new()) != NULL);
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
|
||||
assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, buff, used, 17));
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &entry));
|
||||
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_data_block(a, &pv, &s, &o));
|
||||
assertEqualInt(262144, s);
|
||||
assertEqualInt(0, o);
|
||||
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_data_block(a, &pv, &s, &o));
|
||||
assertEqualInt(6, s);
|
||||
assertEqualInt(262144, o);
|
||||
|
||||
assertEqualInt(ARCHIVE_EOF, archive_read_data_block(a, &pv, &s, &o));
|
||||
|
||||
assertEqualInt(ARCHIVE_OK, archive_free(a));
|
||||
}
|
||||
|
||||
free(body);
|
||||
free(body_read);
|
||||
free(buff);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
begin 644 test_read_format_zip_high_compression.zip
|
||||
M4$L#!!0`"``(`*=Y]4@``````````*``!``(`"``8VAA<BYB:6Y55`T`!\L>
|
||||
MD5>>))%7GB215W5X"P`!!/8!```$%````.W=06K#,!`%T&E)P8LL?*2XC@N%
|
||||
M)#5QO>AM<K0<+2=0:!OBP>@9WDJ6!%\6$K/Q6T3LAX]N/GQ'Z9G&KA^*K1'S
|
||||
M.`[GOIM*[TP_Q_>O0[G_:3X.Y\^^V/X2<<GT&IM=$]OK?[71_LJ],3;1+*(T
|
||||
M_U)99\T+````````````````````````````````````````L`:E?]*S#FVT
|
||||
MJY:='SPB>_]DR\X?`("_R:X_U"Y[_:F;;Q``ZN+L!P"H3W;]$_5G`&!9V?</
|
||||
M````X/FRZP_9LO,'@`S9YR^0P_Z'NF7?/P``````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
MJ%L3VVM-LO,&8/UN4$L'"!<='%^U`0``H``$`%!+`0(4`Q0`"``(`*=Y]4@7
|
||||
M'1Q?M0$``*``!``(`"````````````"D@0````!C:&%R+F)I;E54#0`'RQZ1
|
||||
M5YXDD5>>))%7=7@+``$$]@$```04````4$L%!@`````!``$`5@````L"````
|
||||
!````
|
||||
`
|
||||
end
|
||||
@@ -0,0 +1,95 @@
|
||||
/*-
|
||||
* Copyright (c) 2003-2007,2016 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 "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#define UMASK 022
|
||||
|
||||
/*
|
||||
* Github Issue #744 describes a bug in the sandboxing code that
|
||||
* causes very long pathnames to not get checked for symlinks.
|
||||
*/
|
||||
|
||||
DEFINE_TEST(test_write_disk_secure744)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
skipping("archive_write_disk security checks not supported on Windows");
|
||||
#else
|
||||
struct archive *a;
|
||||
struct archive_entry *ae;
|
||||
size_t buff_size = 8192;
|
||||
char *buff = malloc(buff_size);
|
||||
char *p = buff;
|
||||
int n = 0;
|
||||
int t;
|
||||
|
||||
assert(buff != NULL);
|
||||
|
||||
/* Start with a known umask. */
|
||||
assertUmask(UMASK);
|
||||
|
||||
/* Create an archive_write_disk object. */
|
||||
assert((a = archive_write_disk_new()) != NULL);
|
||||
archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS);
|
||||
|
||||
while (p + 500 < buff + buff_size) {
|
||||
memset(p, 'x', 100);
|
||||
p += 100;
|
||||
p[0] = '\0';
|
||||
|
||||
buff[0] = ((n / 1000) % 10) + '0';
|
||||
buff[1] = ((n / 100) % 10)+ '0';
|
||||
buff[2] = ((n / 10) % 10)+ '0';
|
||||
buff[3] = ((n / 1) % 10)+ '0';
|
||||
buff[4] = '_';
|
||||
++n;
|
||||
|
||||
/* Create a symlink pointing to the testworkdir */
|
||||
assert((ae = archive_entry_new()) != NULL);
|
||||
archive_entry_copy_pathname(ae, buff);
|
||||
archive_entry_set_mode(ae, S_IFREG | 0777);
|
||||
archive_entry_copy_symlink(ae, testworkdir);
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
|
||||
archive_entry_free(ae);
|
||||
|
||||
*p++ = '/';
|
||||
sprintf(p, "target%d", n);
|
||||
|
||||
/* Try to create a file through the symlink, should fail. */
|
||||
assert((ae = archive_entry_new()) != NULL);
|
||||
archive_entry_copy_pathname(ae, buff);
|
||||
archive_entry_set_mode(ae, S_IFDIR | 0777);
|
||||
|
||||
t = archive_write_header(a, ae);
|
||||
archive_entry_free(ae);
|
||||
failure("Attempt to create target%d via %d-character symlink should have failed", n, (int)strlen(buff));
|
||||
if(!assertEqualInt(ARCHIVE_FAILED, t)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
archive_free(a);
|
||||
free(buff);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*-
|
||||
* Copyright (c) 2003-2007,2016 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 "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#define UMASK 022
|
||||
|
||||
/*
|
||||
* Github Issue #745 describes a bug in the sandboxing code that
|
||||
* allows one to use a symlink to edit the permissions on a file or
|
||||
* directory outside of the sandbox.
|
||||
*/
|
||||
|
||||
DEFINE_TEST(test_write_disk_secure745)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
skipping("archive_write_disk security checks not supported on Windows");
|
||||
#else
|
||||
struct archive *a;
|
||||
struct archive_entry *ae;
|
||||
|
||||
/* Start with a known umask. */
|
||||
assertUmask(UMASK);
|
||||
|
||||
/* Create an archive_write_disk object. */
|
||||
assert((a = archive_write_disk_new()) != NULL);
|
||||
archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS);
|
||||
|
||||
/* The target dir: The one we're going to try to change permission on */
|
||||
assertMakeDir("target", 0700);
|
||||
|
||||
/* The sandbox dir we're going to run inside of. */
|
||||
assertMakeDir("sandbox", 0700);
|
||||
assertChdir("sandbox");
|
||||
|
||||
/* Create a symlink pointing to the target directory */
|
||||
assert((ae = archive_entry_new()) != NULL);
|
||||
archive_entry_copy_pathname(ae, "sym");
|
||||
archive_entry_set_mode(ae, AE_IFLNK | 0777);
|
||||
archive_entry_copy_symlink(ae, "../target");
|
||||
assert(0 == archive_write_header(a, ae));
|
||||
archive_entry_free(ae);
|
||||
|
||||
/* Try to alter the target dir through the symlink; this should fail. */
|
||||
assert((ae = archive_entry_new()) != NULL);
|
||||
archive_entry_copy_pathname(ae, "sym");
|
||||
archive_entry_set_mode(ae, S_IFDIR | 0777);
|
||||
assert(0 == archive_write_header(a, ae));
|
||||
archive_entry_free(ae);
|
||||
|
||||
/* Permission of target dir should not have changed. */
|
||||
assertFileMode("../target", 0700);
|
||||
|
||||
assert(0 == archive_write_close(a));
|
||||
archive_write_free(a);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
/*-
|
||||
* Copyright (c) 2003-2007,2016 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 "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#define UMASK 022
|
||||
|
||||
/*
|
||||
* Github Issue #746 describes a problem in which hardlink targets are
|
||||
* not adequately checked and can be used to modify entries outside of
|
||||
* the sandbox.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Verify that ARCHIVE_EXTRACT_SECURE_NODOTDOT disallows '..' in hardlink
|
||||
* targets.
|
||||
*/
|
||||
DEFINE_TEST(test_write_disk_secure746a)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
skipping("archive_write_disk security checks not supported on Windows");
|
||||
#else
|
||||
struct archive *a;
|
||||
struct archive_entry *ae;
|
||||
|
||||
/* Start with a known umask. */
|
||||
assertUmask(UMASK);
|
||||
|
||||
/* The target directory we're going to try to affect. */
|
||||
assertMakeDir("target", 0700);
|
||||
assertMakeFile("target/foo", 0700, "unmodified");
|
||||
|
||||
/* The sandbox dir we're going to work within. */
|
||||
assertMakeDir("sandbox", 0700);
|
||||
assertChdir("sandbox");
|
||||
|
||||
/* Create an archive_write_disk object. */
|
||||
assert((a = archive_write_disk_new()) != NULL);
|
||||
archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_NODOTDOT);
|
||||
|
||||
/* Attempt to hardlink to the target directory. */
|
||||
assert((ae = archive_entry_new()) != NULL);
|
||||
archive_entry_copy_pathname(ae, "bar");
|
||||
archive_entry_set_mode(ae, AE_IFREG | 0777);
|
||||
archive_entry_set_size(ae, 8);
|
||||
archive_entry_copy_hardlink(ae, "../target/foo");
|
||||
assertEqualInt(ARCHIVE_FAILED, archive_write_header(a, ae));
|
||||
assertEqualInt(ARCHIVE_FATAL, archive_write_data(a, "modified", 8));
|
||||
archive_entry_free(ae);
|
||||
|
||||
/* Verify that target file contents are unchanged. */
|
||||
assertTextFileContents("unmodified", "../target/foo");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that ARCHIVE_EXTRACT_SECURE_NOSYMLINK disallows symlinks in hardlink
|
||||
* targets.
|
||||
*/
|
||||
DEFINE_TEST(test_write_disk_secure746b)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
skipping("archive_write_disk security checks not supported on Windows");
|
||||
#else
|
||||
struct archive *a;
|
||||
struct archive_entry *ae;
|
||||
|
||||
/* Start with a known umask. */
|
||||
assertUmask(UMASK);
|
||||
|
||||
/* The target directory we're going to try to affect. */
|
||||
assertMakeDir("target", 0700);
|
||||
assertMakeFile("target/foo", 0700, "unmodified");
|
||||
|
||||
/* The sandbox dir we're going to work within. */
|
||||
assertMakeDir("sandbox", 0700);
|
||||
assertChdir("sandbox");
|
||||
|
||||
/* Create an archive_write_disk object. */
|
||||
assert((a = archive_write_disk_new()) != NULL);
|
||||
archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS);
|
||||
|
||||
/* Create a symlink to the target directory. */
|
||||
assert((ae = archive_entry_new()) != NULL);
|
||||
archive_entry_copy_pathname(ae, "symlink");
|
||||
archive_entry_set_mode(ae, AE_IFLNK | 0777);
|
||||
archive_entry_copy_symlink(ae, "../target");
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
|
||||
archive_entry_free(ae);
|
||||
|
||||
/* Attempt to hardlink to the target directory via the symlink. */
|
||||
assert((ae = archive_entry_new()) != NULL);
|
||||
archive_entry_copy_pathname(ae, "bar");
|
||||
archive_entry_set_mode(ae, AE_IFREG | 0777);
|
||||
archive_entry_set_size(ae, 8);
|
||||
archive_entry_copy_hardlink(ae, "symlink/foo");
|
||||
assertEqualIntA(a, ARCHIVE_FAILED, archive_write_header(a, ae));
|
||||
assertEqualIntA(a, ARCHIVE_FATAL, archive_write_data(a, "modified", 8));
|
||||
archive_entry_free(ae);
|
||||
|
||||
/* Verify that target file contents are unchanged. */
|
||||
assertTextFileContents("unmodified", "../target/foo");
|
||||
|
||||
assertEqualIntA(a, ARCHIVE_FATAL, archive_write_close(a));
|
||||
archive_write_free(a);
|
||||
#endif
|
||||
}
|
||||
@@ -100,6 +100,10 @@ DEFINE_TEST(test_write_format_gnutar_linknames)
|
||||
size_t used;
|
||||
int i;
|
||||
|
||||
#ifdef S_IFLNK
|
||||
assertEqualInt(S_IFLNK, AE_IFLNK);
|
||||
#endif
|
||||
|
||||
buff = malloc(buffsize); /* million bytes of work area */
|
||||
assert(buff != NULL);
|
||||
|
||||
@@ -109,7 +113,7 @@ DEFINE_TEST(test_write_format_gnutar_linknames)
|
||||
archive_entry_set_birthtime(template, 3, 30);
|
||||
archive_entry_set_ctime(template, 4, 40);
|
||||
archive_entry_set_mtime(template, 5, 50);
|
||||
archive_entry_set_mode(template, S_IFLNK | 0755);
|
||||
archive_entry_set_mode(template, AE_IFLNK | 0755);
|
||||
archive_entry_copy_pathname(template, "link");
|
||||
|
||||
for (i = 0; i < 2000; ++i) {
|
||||
|
||||
@@ -68,6 +68,7 @@ static const struct bsdtar_option {
|
||||
{ "auto-compress", 0, 'a' },
|
||||
{ "b64encode", 0, OPTION_B64ENCODE },
|
||||
{ "block-size", 1, 'b' },
|
||||
{ "blocking-factor", 1, 'b' },
|
||||
{ "bunzip2", 0, 'j' },
|
||||
{ "bzip", 0, 'j' },
|
||||
{ "bzip2", 0, 'j' },
|
||||
|
||||
@@ -88,7 +88,7 @@ DEFINE_TEST(test_version)
|
||||
if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
|
||||
++q;
|
||||
/* Skip arbitrary third-party version numbers. */
|
||||
while (s > 0 && (*q == ' ' || *q == '/' || *q == '.' || isalnum(*q))) {
|
||||
while (s > 0 && (*q == ' ' || *q == '-' || *q == '/' || *q == '.' || isalnum(*q))) {
|
||||
++q;
|
||||
--s;
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ safe_fprintf(FILE *f, const char *fmt, ...)
|
||||
}
|
||||
|
||||
/* If our output buffer is full, dump it and keep going. */
|
||||
if (i > (sizeof(outbuff) - 20)) {
|
||||
if (i > (sizeof(outbuff) - 128)) {
|
||||
outbuff[i] = '\0';
|
||||
fprintf(f, "%s", outbuff);
|
||||
i = 0;
|
||||
|
||||
@@ -572,6 +572,19 @@ static void free_exception(char *e)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __LP64__
|
||||
/**
|
||||
* There's an ABI bug in __cxa_exception: unwindHeader requires 16-byte
|
||||
* alignment but it was broken by the addition of the referenceCount.
|
||||
* The unwindHeader is at offset 0x58 in __cxa_exception. In order to keep
|
||||
* compatibility with consumers of the broken __cxa_exception, explicitly add
|
||||
* padding on allocation (and account for it on free).
|
||||
*/
|
||||
static const int exception_alignment_padding = 8;
|
||||
#else
|
||||
static const int exception_alignment_padding = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Allocates an exception structure. Returns a pointer to the space that can
|
||||
* be used to store an object of thrown_size bytes. This function will use an
|
||||
@@ -580,16 +593,19 @@ static void free_exception(char *e)
|
||||
*/
|
||||
extern "C" void *__cxa_allocate_exception(size_t thrown_size)
|
||||
{
|
||||
size_t size = thrown_size + sizeof(__cxa_exception);
|
||||
size_t size = exception_alignment_padding + sizeof(__cxa_exception) +
|
||||
thrown_size;
|
||||
char *buffer = alloc_or_die(size);
|
||||
return buffer+sizeof(__cxa_exception);
|
||||
return buffer + exception_alignment_padding + sizeof(__cxa_exception);
|
||||
}
|
||||
|
||||
extern "C" void *__cxa_allocate_dependent_exception(void)
|
||||
{
|
||||
size_t size = sizeof(__cxa_dependent_exception);
|
||||
size_t size = exception_alignment_padding +
|
||||
sizeof(__cxa_dependent_exception);
|
||||
char *buffer = alloc_or_die(size);
|
||||
return buffer+sizeof(__cxa_dependent_exception);
|
||||
return buffer + exception_alignment_padding +
|
||||
sizeof(__cxa_dependent_exception);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -617,7 +633,8 @@ extern "C" void __cxa_free_exception(void *thrown_exception)
|
||||
}
|
||||
}
|
||||
|
||||
free_exception(reinterpret_cast<char*>(ex));
|
||||
free_exception(reinterpret_cast<char*>(ex) -
|
||||
exception_alignment_padding);
|
||||
}
|
||||
|
||||
static void releaseException(__cxa_exception *exception)
|
||||
@@ -644,7 +661,8 @@ void __cxa_free_dependent_exception(void *thrown_exception)
|
||||
{
|
||||
releaseException(realExceptionFromException(reinterpret_cast<__cxa_exception*>(ex)));
|
||||
}
|
||||
free_exception(reinterpret_cast<char*>(ex));
|
||||
free_exception(reinterpret_cast<char*>(ex) -
|
||||
exception_alignment_padding);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2842,7 +2842,7 @@ again:
|
||||
|
||||
case 'w':
|
||||
/* wchar_t */
|
||||
if (!cpp_demangle_push_str(ddata, "wchar_t", 6))
|
||||
if (!cpp_demangle_push_str(ddata, "wchar_t", 7))
|
||||
goto clean;
|
||||
++ddata->cur;
|
||||
goto rtn;
|
||||
|
||||
@@ -90,6 +90,7 @@ const MCFixupKindInfo &ARMAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
|
||||
{"fixup_arm_movw_lo16", 0, 20, 0},
|
||||
{"fixup_t2_movt_hi16", 0, 20, 0},
|
||||
{"fixup_t2_movw_lo16", 0, 20, 0},
|
||||
{"fixup_arm_mod_imm", 0, 12, 0},
|
||||
};
|
||||
const static MCFixupKindInfo InfosBE[ARM::NumTargetFixupKinds] = {
|
||||
// This table *must* be in the order that the fixup_* kinds are defined in
|
||||
@@ -133,6 +134,7 @@ const MCFixupKindInfo &ARMAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
|
||||
{"fixup_arm_movw_lo16", 12, 20, 0},
|
||||
{"fixup_t2_movt_hi16", 12, 20, 0},
|
||||
{"fixup_t2_movw_lo16", 12, 20, 0},
|
||||
{"fixup_arm_mod_imm", 20, 12, 0},
|
||||
};
|
||||
|
||||
if (Kind < FirstTargetFixupKind)
|
||||
@@ -624,6 +626,13 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCFixup &Fixup, uint64_t Value,
|
||||
|
||||
return Value;
|
||||
}
|
||||
case ARM::fixup_arm_mod_imm:
|
||||
Value = ARM_AM::getSOImmVal(Value);
|
||||
if (Ctx && Value >> 12) {
|
||||
Ctx->reportError(Fixup.getLoc(), "out of range immediate fixup value");
|
||||
return 0;
|
||||
}
|
||||
return Value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -690,6 +699,7 @@ static unsigned getFixupKindNumBytes(unsigned Kind) {
|
||||
case FK_Data_2:
|
||||
case ARM::fixup_arm_thumb_br:
|
||||
case ARM::fixup_arm_thumb_cb:
|
||||
case ARM::fixup_arm_mod_imm:
|
||||
return 2;
|
||||
|
||||
case ARM::fixup_arm_pcrel_10_unscaled:
|
||||
@@ -766,6 +776,7 @@ static unsigned getFixupKindContainerSizeBytes(unsigned Kind) {
|
||||
case ARM::fixup_arm_movw_lo16:
|
||||
case ARM::fixup_t2_movt_hi16:
|
||||
case ARM::fixup_t2_movw_lo16:
|
||||
case ARM::fixup_arm_mod_imm:
|
||||
// Instruction size is 4 bytes.
|
||||
return 4;
|
||||
}
|
||||
|
||||
@@ -100,6 +100,9 @@ enum Fixups {
|
||||
fixup_t2_movt_hi16, // :upper16:
|
||||
fixup_t2_movw_lo16, // :lower16:
|
||||
|
||||
// fixup_arm_mod_imm - Fixup for mod_imm
|
||||
fixup_arm_mod_imm,
|
||||
|
||||
// Marker
|
||||
LastTargetFixupKind,
|
||||
NumTargetFixupKinds = LastTargetFixupKind - FirstTargetFixupKind
|
||||
|
||||
@@ -312,12 +312,8 @@ public:
|
||||
// Support for fixups (MCFixup)
|
||||
if (MO.isExpr()) {
|
||||
const MCExpr *Expr = MO.getExpr();
|
||||
// In instruction code this value always encoded as lowest 12 bits,
|
||||
// so we don't have to perform any specific adjustments.
|
||||
// Due to requirements of relocatable records we have to use FK_Data_4.
|
||||
// See ARMELFObjectWriter::ExplicitRelSym and
|
||||
// ARMELFObjectWriter::GetRelocTypeInner for more details.
|
||||
MCFixupKind Kind = MCFixupKind(FK_Data_4);
|
||||
// Fixups resolve to plain values that need to be encoded.
|
||||
MCFixupKind Kind = MCFixupKind(ARM::fixup_arm_mod_imm);
|
||||
Fixups.push_back(MCFixup::create(0, Expr, Kind, MI.getLoc()));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -576,7 +576,6 @@ def : Proc<"btver1", [
|
||||
FeaturePRFCHW,
|
||||
FeatureLZCNT,
|
||||
FeaturePOPCNT,
|
||||
FeatureXSAVE,
|
||||
FeatureSlowSHLD,
|
||||
FeatureLAHFSAHF
|
||||
]>;
|
||||
|
||||
@@ -17,4 +17,55 @@
|
||||
#define _LIBUNWIND_ARM_EHABI 0
|
||||
#endif
|
||||
|
||||
#if defined(_LIBUNWIND_IS_NATIVE_ONLY)
|
||||
# if defined(__i386__)
|
||||
# define _LIBUNWIND_TARGET_I386 1
|
||||
# define _LIBUNWIND_CONTEXT_SIZE 8
|
||||
# define _LIBUNWIND_CURSOR_SIZE 19
|
||||
# define _LIBUNWIND_MAX_REGISTER 9
|
||||
# elif defined(__x86_64__)
|
||||
# define _LIBUNWIND_TARGET_X86_64 1
|
||||
# define _LIBUNWIND_CONTEXT_SIZE 21
|
||||
# define _LIBUNWIND_CURSOR_SIZE 33
|
||||
# define _LIBUNWIND_MAX_REGISTER 17
|
||||
# elif defined(__ppc__)
|
||||
# define _LIBUNWIND_TARGET_PPC 1
|
||||
# define _LIBUNWIND_CONTEXT_SIZE 117
|
||||
# define _LIBUNWIND_CURSOR_SIZE 128
|
||||
# define _LIBUNWIND_MAX_REGISTER 113
|
||||
# elif defined(__aarch64__)
|
||||
# define _LIBUNWIND_TARGET_AARCH64 1
|
||||
# define _LIBUNWIND_CONTEXT_SIZE 66
|
||||
# define _LIBUNWIND_CURSOR_SIZE 78
|
||||
# define _LIBUNWIND_MAX_REGISTER 96
|
||||
# elif defined(__arm__)
|
||||
# define _LIBUNWIND_TARGET_ARM 1
|
||||
# define _LIBUNWIND_CONTEXT_SIZE 60
|
||||
# define _LIBUNWIND_CURSOR_SIZE 67
|
||||
# define _LIBUNWIND_MAX_REGISTER 96
|
||||
# elif defined(__or1k__)
|
||||
# define _LIBUNWIND_TARGET_OR1K 1
|
||||
# define _LIBUNWIND_CONTEXT_SIZE 16
|
||||
# define _LIBUNWIND_CURSOR_SIZE 28
|
||||
# define _LIBUNWIND_MAX_REGISTER 32
|
||||
# elif defined(__riscv__)
|
||||
# define _LIBUNWIND_TARGET_RISCV 1
|
||||
# define _LIBUNWIND_CONTEXT_SIZE 128 /* XXX */
|
||||
# define _LIBUNWIND_CURSOR_SIZE 140 /* XXX */
|
||||
# define _LIBUNWIND_MAX_REGISTER 96
|
||||
# else
|
||||
# error "Unsupported architecture."
|
||||
# endif
|
||||
#else // !_LIBUNWIND_IS_NATIVE_ONLY
|
||||
# define _LIBUNWIND_TARGET_I386 1
|
||||
# define _LIBUNWIND_TARGET_X86_64 1
|
||||
# define _LIBUNWIND_TARGET_PPC 1
|
||||
# define _LIBUNWIND_TARGET_AARCH64 1
|
||||
# define _LIBUNWIND_TARGET_ARM 1
|
||||
# define _LIBUNWIND_TARGET_OR1K 1
|
||||
# define _LIBUNWIND_CONTEXT_SIZE 128
|
||||
# define _LIBUNWIND_CURSOR_SIZE 140
|
||||
# define _LIBUNWIND_MAX_REGISTER 120
|
||||
#endif // _LIBUNWIND_IS_NATIVE_ONLY
|
||||
|
||||
#endif // ____LIBUNWIND_CONFIG_H__
|
||||
@@ -46,12 +46,12 @@ enum {
|
||||
};
|
||||
|
||||
struct unw_context_t {
|
||||
uint64_t data[128];
|
||||
uint64_t data[_LIBUNWIND_CONTEXT_SIZE];
|
||||
};
|
||||
typedef struct unw_context_t unw_context_t;
|
||||
|
||||
struct unw_cursor_t {
|
||||
uint64_t data[140];
|
||||
uint64_t data[_LIBUNWIND_CURSOR_SIZE];
|
||||
};
|
||||
typedef struct unw_cursor_t unw_cursor_t;
|
||||
|
||||
@@ -151,8 +151,8 @@ enum {
|
||||
UNW_X86_ECX = 1,
|
||||
UNW_X86_EDX = 2,
|
||||
UNW_X86_EBX = 3,
|
||||
UNW_X86_EBP = 4,
|
||||
UNW_X86_ESP = 5,
|
||||
UNW_X86_ESP = 4,
|
||||
UNW_X86_EBP = 5,
|
||||
UNW_X86_ESI = 6,
|
||||
UNW_X86_EDI = 7
|
||||
};
|
||||
@@ -295,77 +295,6 @@ enum {
|
||||
UNW_PPC_SPEFSCR = 112
|
||||
};
|
||||
|
||||
// 64-bit RISC-V registers
|
||||
enum {
|
||||
UNW_RISCV_X0 = 0,
|
||||
UNW_RISCV_X1 = 1,
|
||||
UNW_RISCV_RA = 1,
|
||||
UNW_RISCV_X2 = 2,
|
||||
UNW_RISCV_SP = 2,
|
||||
UNW_RISCV_X3 = 3,
|
||||
UNW_RISCV_X4 = 4,
|
||||
UNW_RISCV_X5 = 5,
|
||||
UNW_RISCV_X6 = 6,
|
||||
UNW_RISCV_X7 = 7,
|
||||
UNW_RISCV_X8 = 8,
|
||||
UNW_RISCV_X9 = 9,
|
||||
UNW_RISCV_X10 = 10,
|
||||
UNW_RISCV_X11 = 11,
|
||||
UNW_RISCV_X12 = 12,
|
||||
UNW_RISCV_X13 = 13,
|
||||
UNW_RISCV_X14 = 14,
|
||||
UNW_RISCV_X15 = 15,
|
||||
UNW_RISCV_X16 = 16,
|
||||
UNW_RISCV_X17 = 17,
|
||||
UNW_RISCV_X18 = 18,
|
||||
UNW_RISCV_X19 = 19,
|
||||
UNW_RISCV_X20 = 20,
|
||||
UNW_RISCV_X21 = 21,
|
||||
UNW_RISCV_X22 = 22,
|
||||
UNW_RISCV_X23 = 23,
|
||||
UNW_RISCV_X24 = 24,
|
||||
UNW_RISCV_X25 = 25,
|
||||
UNW_RISCV_X26 = 26,
|
||||
UNW_RISCV_X27 = 27,
|
||||
UNW_RISCV_X28 = 28,
|
||||
UNW_RISCV_X29 = 29,
|
||||
UNW_RISCV_X30 = 30,
|
||||
UNW_RISCV_X31 = 31,
|
||||
// reserved block
|
||||
UNW_RISCV_D0 = 64,
|
||||
UNW_RISCV_D1 = 65,
|
||||
UNW_RISCV_D2 = 66,
|
||||
UNW_RISCV_D3 = 67,
|
||||
UNW_RISCV_D4 = 68,
|
||||
UNW_RISCV_D5 = 69,
|
||||
UNW_RISCV_D6 = 70,
|
||||
UNW_RISCV_D7 = 71,
|
||||
UNW_RISCV_D8 = 72,
|
||||
UNW_RISCV_D9 = 73,
|
||||
UNW_RISCV_D10 = 74,
|
||||
UNW_RISCV_D11 = 75,
|
||||
UNW_RISCV_D12 = 76,
|
||||
UNW_RISCV_D13 = 77,
|
||||
UNW_RISCV_D14 = 78,
|
||||
UNW_RISCV_D15 = 79,
|
||||
UNW_RISCV_D16 = 80,
|
||||
UNW_RISCV_D17 = 81,
|
||||
UNW_RISCV_D18 = 82,
|
||||
UNW_RISCV_D19 = 83,
|
||||
UNW_RISCV_D20 = 84,
|
||||
UNW_RISCV_D21 = 85,
|
||||
UNW_RISCV_D22 = 86,
|
||||
UNW_RISCV_D23 = 87,
|
||||
UNW_RISCV_D24 = 88,
|
||||
UNW_RISCV_D25 = 89,
|
||||
UNW_RISCV_D26 = 90,
|
||||
UNW_RISCV_D27 = 91,
|
||||
UNW_RISCV_D28 = 92,
|
||||
UNW_RISCV_D29 = 93,
|
||||
UNW_RISCV_D30 = 94,
|
||||
UNW_RISCV_D31 = 95,
|
||||
};
|
||||
|
||||
// 64-bit ARM64 registers
|
||||
enum {
|
||||
UNW_ARM64_X0 = 0,
|
||||
@@ -604,4 +533,75 @@ enum {
|
||||
UNW_OR1K_R31 = 31,
|
||||
};
|
||||
|
||||
// 64-bit RISC-V registers
|
||||
enum {
|
||||
UNW_RISCV_X0 = 0,
|
||||
UNW_RISCV_X1 = 1,
|
||||
UNW_RISCV_RA = 1,
|
||||
UNW_RISCV_X2 = 2,
|
||||
UNW_RISCV_SP = 2,
|
||||
UNW_RISCV_X3 = 3,
|
||||
UNW_RISCV_X4 = 4,
|
||||
UNW_RISCV_X5 = 5,
|
||||
UNW_RISCV_X6 = 6,
|
||||
UNW_RISCV_X7 = 7,
|
||||
UNW_RISCV_X8 = 8,
|
||||
UNW_RISCV_X9 = 9,
|
||||
UNW_RISCV_X10 = 10,
|
||||
UNW_RISCV_X11 = 11,
|
||||
UNW_RISCV_X12 = 12,
|
||||
UNW_RISCV_X13 = 13,
|
||||
UNW_RISCV_X14 = 14,
|
||||
UNW_RISCV_X15 = 15,
|
||||
UNW_RISCV_X16 = 16,
|
||||
UNW_RISCV_X17 = 17,
|
||||
UNW_RISCV_X18 = 18,
|
||||
UNW_RISCV_X19 = 19,
|
||||
UNW_RISCV_X20 = 20,
|
||||
UNW_RISCV_X21 = 21,
|
||||
UNW_RISCV_X22 = 22,
|
||||
UNW_RISCV_X23 = 23,
|
||||
UNW_RISCV_X24 = 24,
|
||||
UNW_RISCV_X25 = 25,
|
||||
UNW_RISCV_X26 = 26,
|
||||
UNW_RISCV_X27 = 27,
|
||||
UNW_RISCV_X28 = 28,
|
||||
UNW_RISCV_X29 = 29,
|
||||
UNW_RISCV_X30 = 30,
|
||||
UNW_RISCV_X31 = 31,
|
||||
// reserved block
|
||||
UNW_RISCV_D0 = 64,
|
||||
UNW_RISCV_D1 = 65,
|
||||
UNW_RISCV_D2 = 66,
|
||||
UNW_RISCV_D3 = 67,
|
||||
UNW_RISCV_D4 = 68,
|
||||
UNW_RISCV_D5 = 69,
|
||||
UNW_RISCV_D6 = 70,
|
||||
UNW_RISCV_D7 = 71,
|
||||
UNW_RISCV_D8 = 72,
|
||||
UNW_RISCV_D9 = 73,
|
||||
UNW_RISCV_D10 = 74,
|
||||
UNW_RISCV_D11 = 75,
|
||||
UNW_RISCV_D12 = 76,
|
||||
UNW_RISCV_D13 = 77,
|
||||
UNW_RISCV_D14 = 78,
|
||||
UNW_RISCV_D15 = 79,
|
||||
UNW_RISCV_D16 = 80,
|
||||
UNW_RISCV_D17 = 81,
|
||||
UNW_RISCV_D18 = 82,
|
||||
UNW_RISCV_D19 = 83,
|
||||
UNW_RISCV_D20 = 84,
|
||||
UNW_RISCV_D21 = 85,
|
||||
UNW_RISCV_D22 = 86,
|
||||
UNW_RISCV_D23 = 87,
|
||||
UNW_RISCV_D24 = 88,
|
||||
UNW_RISCV_D25 = 89,
|
||||
UNW_RISCV_D26 = 90,
|
||||
UNW_RISCV_D27 = 91,
|
||||
UNW_RISCV_D28 = 92,
|
||||
UNW_RISCV_D29 = 93,
|
||||
UNW_RISCV_D30 = 94,
|
||||
UNW_RISCV_D31 = 95,
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -128,7 +128,7 @@ struct _Unwind_Exception {
|
||||
// added for binary compatibility.
|
||||
uint32_t reserved[3];
|
||||
#endif
|
||||
};
|
||||
} __attribute__((__aligned__));
|
||||
|
||||
typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
|
||||
(int version,
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace libunwind {
|
||||
#include "Registers.hpp"
|
||||
|
||||
#if _LIBUNWIND_ARM_EHABI
|
||||
#if defined(__FreeBSD__)
|
||||
#if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
|
||||
#include <sys/link_elf.h>
|
||||
typedef void *_Unwind_Ptr;
|
||||
@@ -62,7 +62,8 @@ extern EHTEntry __exidx_end;
|
||||
#endif // !defined(_LIBUNWIND_IS_BAREMETAL)
|
||||
#endif // _LIBUNWIND_ARM_EHABI
|
||||
|
||||
#if defined(__CloudABI__) || defined(__FreeBSD__) || defined(__linux__)
|
||||
#if defined(__CloudABI__) || defined(__FreeBSD__) || defined(__linux__) || \
|
||||
defined(__NetBSD__)
|
||||
#if _LIBUNWIND_SUPPORT_DWARF_UNWIND && _LIBUNWIND_SUPPORT_DWARF_INDEX
|
||||
#include <link.h>
|
||||
// Macro for machine-independent access to the ELF program headers. This
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
namespace libunwind {
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_I386)
|
||||
/// CompactUnwinder_x86 uses a compact unwind info to virtually "step" (aka
|
||||
/// unwind) by modifying a Registers_x86 register set
|
||||
template <typename A>
|
||||
@@ -255,8 +256,10 @@ void CompactUnwinder_x86<A>::framelessUnwind(
|
||||
// old esp is before return address
|
||||
registers.setSP((uint32_t)returnAddressLocation + 4);
|
||||
}
|
||||
#endif // _LIBUNWIND_TARGET_I386
|
||||
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_X86_64)
|
||||
/// CompactUnwinder_x86_64 uses a compact unwind info to virtually "step" (aka
|
||||
/// unwind) by modifying a Registers_x86_64 register set
|
||||
template <typename A>
|
||||
@@ -484,9 +487,11 @@ void CompactUnwinder_x86_64<A>::framelessUnwind(A &addressSpace,
|
||||
// old esp is before return address
|
||||
registers.setSP(returnAddressLocation + 8);
|
||||
}
|
||||
#endif // _LIBUNWIND_TARGET_X86_64
|
||||
|
||||
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_AARCH64)
|
||||
/// CompactUnwinder_arm64 uses a compact unwind info to virtually "step" (aka
|
||||
/// unwind) by modifying a Registers_arm64 register set
|
||||
template <typename A>
|
||||
@@ -686,6 +691,7 @@ int CompactUnwinder_arm64<A>::stepWithCompactEncodingFrame(
|
||||
|
||||
return UNW_STEP_SUCCESS;
|
||||
}
|
||||
#endif // _LIBUNWIND_TARGET_AARCH64
|
||||
|
||||
|
||||
} // namespace libunwind
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
};
|
||||
|
||||
enum {
|
||||
kMaxRegisterNumber = 120
|
||||
kMaxRegisterNumber = _LIBUNWIND_MAX_REGISTER
|
||||
};
|
||||
enum RegisterSavedWhere {
|
||||
kRegisterUnused,
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace libunwind {
|
||||
struct v128 { uint32_t vec[4]; };
|
||||
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_I386)
|
||||
/// Registers_x86 holds the register state of a thread in a 32-bit intel
|
||||
/// process.
|
||||
class _LIBUNWIND_HIDDEN Registers_x86 {
|
||||
@@ -86,8 +87,8 @@ private:
|
||||
};
|
||||
|
||||
inline Registers_x86::Registers_x86(const void *registers) {
|
||||
static_assert(sizeof(Registers_x86) < sizeof(unw_context_t),
|
||||
"x86 registers do not fit into unw_context_t");
|
||||
static_assert((check_fit<Registers_x86, unw_context_t>::does_fit),
|
||||
"x86 registers do not fit into unw_context_t");
|
||||
memcpy(&_registers, registers, sizeof(_registers));
|
||||
}
|
||||
|
||||
@@ -211,8 +212,10 @@ inline v128 Registers_x86::getVectorRegister(int) const {
|
||||
inline void Registers_x86::setVectorRegister(int, v128) {
|
||||
_LIBUNWIND_ABORT("no x86 vector registers");
|
||||
}
|
||||
#endif // _LIBUNWIND_TARGET_I386
|
||||
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_X86_64)
|
||||
/// Registers_x86_64 holds the register state of a thread in a 64-bit intel
|
||||
/// process.
|
||||
class _LIBUNWIND_HIDDEN Registers_x86_64 {
|
||||
@@ -278,8 +281,8 @@ private:
|
||||
};
|
||||
|
||||
inline Registers_x86_64::Registers_x86_64(const void *registers) {
|
||||
static_assert(sizeof(Registers_x86_64) < sizeof(unw_context_t),
|
||||
"x86_64 registers do not fit into unw_context_t");
|
||||
static_assert((check_fit<Registers_x86_64, unw_context_t>::does_fit),
|
||||
"x86_64 registers do not fit into unw_context_t");
|
||||
memcpy(&_registers, registers, sizeof(_registers));
|
||||
}
|
||||
|
||||
@@ -459,8 +462,10 @@ inline v128 Registers_x86_64::getVectorRegister(int) const {
|
||||
inline void Registers_x86_64::setVectorRegister(int, v128) {
|
||||
_LIBUNWIND_ABORT("no x86_64 vector registers");
|
||||
}
|
||||
#endif // _LIBUNWIND_TARGET_X86_64
|
||||
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_PPC)
|
||||
/// Registers_ppc holds the register state of a thread in a 32-bit PowerPC
|
||||
/// process.
|
||||
class _LIBUNWIND_HIDDEN Registers_ppc {
|
||||
@@ -543,8 +548,8 @@ private:
|
||||
};
|
||||
|
||||
inline Registers_ppc::Registers_ppc(const void *registers) {
|
||||
static_assert(sizeof(Registers_ppc) < sizeof(unw_context_t),
|
||||
"ppc registers do not fit into unw_context_t");
|
||||
static_assert((check_fit<Registers_ppc, unw_context_t>::does_fit),
|
||||
"ppc registers do not fit into unw_context_t");
|
||||
memcpy(&_registers, static_cast<const uint8_t *>(registers),
|
||||
sizeof(_registers));
|
||||
static_assert(sizeof(ppc_thread_state_t) == 160,
|
||||
@@ -1023,266 +1028,10 @@ inline const char *Registers_ppc::getRegisterName(int regNum) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// Registers_riscv holds the register state of a thread in a 64-bit RISC-V
|
||||
/// process.
|
||||
class _LIBUNWIND_HIDDEN Registers_riscv {
|
||||
public:
|
||||
Registers_riscv();
|
||||
Registers_riscv(const void *registers);
|
||||
|
||||
bool validRegister(int num) const;
|
||||
uint64_t getRegister(int num) const;
|
||||
void setRegister(int num, uint64_t value);
|
||||
bool validFloatRegister(int num) const;
|
||||
double getFloatRegister(int num) const;
|
||||
void setFloatRegister(int num, double value);
|
||||
bool validVectorRegister(int num) const;
|
||||
v128 getVectorRegister(int num) const;
|
||||
void setVectorRegister(int num, v128 value);
|
||||
const char *getRegisterName(int num);
|
||||
void jumpto();
|
||||
static int lastDwarfRegNum() { return 95; }
|
||||
|
||||
uint64_t getSP() const { return _registers.__x[2]; }
|
||||
void setSP(uint64_t value) { _registers.__x[2] = value; }
|
||||
uint64_t getIP() const { return _registers.__x[1]; }
|
||||
void setIP(uint64_t value) { _registers.__x[1] = value; }
|
||||
|
||||
private:
|
||||
struct GPRs {
|
||||
uint64_t __x[32]; // x0-x31
|
||||
};
|
||||
|
||||
GPRs _registers;
|
||||
double _vectorHalfRegisters[32];
|
||||
// Currently only the lower double in 128-bit vectore registers
|
||||
// is perserved during unwinding. We could define new register
|
||||
// numbers (> 96) which mean whole vector registers, then this
|
||||
// struct would need to change to contain whole vector registers.
|
||||
};
|
||||
|
||||
inline Registers_riscv::Registers_riscv(const void *registers) {
|
||||
static_assert(sizeof(Registers_riscv) < sizeof(unw_context_t),
|
||||
"riscv registers do not fit into unw_context_t");
|
||||
memcpy(&_registers, registers, sizeof(_registers));
|
||||
static_assert(sizeof(GPRs) == 0x100,
|
||||
"expected VFP registers to be at offset 256");
|
||||
memcpy(_vectorHalfRegisters,
|
||||
static_cast<const uint8_t *>(registers) + sizeof(GPRs),
|
||||
sizeof(_vectorHalfRegisters));
|
||||
}
|
||||
|
||||
inline Registers_riscv::Registers_riscv() {
|
||||
memset(&_registers, 0, sizeof(_registers));
|
||||
memset(&_vectorHalfRegisters, 0, sizeof(_vectorHalfRegisters));
|
||||
}
|
||||
|
||||
inline bool Registers_riscv::validRegister(int regNum) const {
|
||||
if (regNum == UNW_REG_IP)
|
||||
return true;
|
||||
if (regNum == UNW_REG_SP)
|
||||
return true;
|
||||
if (regNum < 0)
|
||||
return false;
|
||||
if (regNum > 95)
|
||||
return false;
|
||||
if ((regNum > 31) && (regNum < 64))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline uint64_t Registers_riscv::getRegister(int regNum) const {
|
||||
if (regNum == UNW_REG_IP)
|
||||
return _registers.__x[1];
|
||||
if (regNum == UNW_REG_SP)
|
||||
return _registers.__x[2];
|
||||
if ((regNum >= 0) && (regNum < 32))
|
||||
return _registers.__x[regNum];
|
||||
_LIBUNWIND_ABORT("unsupported riscv register");
|
||||
}
|
||||
|
||||
inline void Registers_riscv::setRegister(int regNum, uint64_t value) {
|
||||
if (regNum == UNW_REG_IP)
|
||||
_registers.__x[1] = value;
|
||||
else if (regNum == UNW_REG_SP)
|
||||
_registers.__x[2] = value;
|
||||
else if ((regNum >= 0) && (regNum < 32))
|
||||
_registers.__x[regNum] = value;
|
||||
else
|
||||
_LIBUNWIND_ABORT("unsupported riscv register");
|
||||
}
|
||||
|
||||
inline const char *Registers_riscv::getRegisterName(int regNum) {
|
||||
switch (regNum) {
|
||||
case UNW_REG_IP:
|
||||
return "ra";
|
||||
case UNW_REG_SP:
|
||||
return "sp";
|
||||
case UNW_RISCV_X0:
|
||||
return "x0";
|
||||
case UNW_RISCV_X1:
|
||||
return "ra";
|
||||
case UNW_RISCV_X2:
|
||||
return "sp";
|
||||
case UNW_RISCV_X3:
|
||||
return "x3";
|
||||
case UNW_RISCV_X4:
|
||||
return "x4";
|
||||
case UNW_RISCV_X5:
|
||||
return "x5";
|
||||
case UNW_RISCV_X6:
|
||||
return "x6";
|
||||
case UNW_RISCV_X7:
|
||||
return "x7";
|
||||
case UNW_RISCV_X8:
|
||||
return "x8";
|
||||
case UNW_RISCV_X9:
|
||||
return "x9";
|
||||
case UNW_RISCV_X10:
|
||||
return "x10";
|
||||
case UNW_RISCV_X11:
|
||||
return "x11";
|
||||
case UNW_RISCV_X12:
|
||||
return "x12";
|
||||
case UNW_RISCV_X13:
|
||||
return "x13";
|
||||
case UNW_RISCV_X14:
|
||||
return "x14";
|
||||
case UNW_RISCV_X15:
|
||||
return "x15";
|
||||
case UNW_RISCV_X16:
|
||||
return "x16";
|
||||
case UNW_RISCV_X17:
|
||||
return "x17";
|
||||
case UNW_RISCV_X18:
|
||||
return "x18";
|
||||
case UNW_RISCV_X19:
|
||||
return "x19";
|
||||
case UNW_RISCV_X20:
|
||||
return "x20";
|
||||
case UNW_RISCV_X21:
|
||||
return "x21";
|
||||
case UNW_RISCV_X22:
|
||||
return "x22";
|
||||
case UNW_RISCV_X23:
|
||||
return "x23";
|
||||
case UNW_RISCV_X24:
|
||||
return "x24";
|
||||
case UNW_RISCV_X25:
|
||||
return "x25";
|
||||
case UNW_RISCV_X26:
|
||||
return "x26";
|
||||
case UNW_RISCV_X27:
|
||||
return "x27";
|
||||
case UNW_RISCV_X28:
|
||||
return "x28";
|
||||
case UNW_RISCV_X29:
|
||||
return "x29";
|
||||
case UNW_RISCV_X30:
|
||||
return "x30";
|
||||
case UNW_RISCV_X31:
|
||||
return "x31";
|
||||
case UNW_RISCV_D0:
|
||||
return "d0";
|
||||
case UNW_RISCV_D1:
|
||||
return "d1";
|
||||
case UNW_RISCV_D2:
|
||||
return "d2";
|
||||
case UNW_RISCV_D3:
|
||||
return "d3";
|
||||
case UNW_RISCV_D4:
|
||||
return "d4";
|
||||
case UNW_RISCV_D5:
|
||||
return "d5";
|
||||
case UNW_RISCV_D6:
|
||||
return "d6";
|
||||
case UNW_RISCV_D7:
|
||||
return "d7";
|
||||
case UNW_RISCV_D8:
|
||||
return "d8";
|
||||
case UNW_RISCV_D9:
|
||||
return "d9";
|
||||
case UNW_RISCV_D10:
|
||||
return "d10";
|
||||
case UNW_RISCV_D11:
|
||||
return "d11";
|
||||
case UNW_RISCV_D12:
|
||||
return "d12";
|
||||
case UNW_RISCV_D13:
|
||||
return "d13";
|
||||
case UNW_RISCV_D14:
|
||||
return "d14";
|
||||
case UNW_RISCV_D15:
|
||||
return "d15";
|
||||
case UNW_RISCV_D16:
|
||||
return "d16";
|
||||
case UNW_RISCV_D17:
|
||||
return "d17";
|
||||
case UNW_RISCV_D18:
|
||||
return "d18";
|
||||
case UNW_RISCV_D19:
|
||||
return "d19";
|
||||
case UNW_RISCV_D20:
|
||||
return "d20";
|
||||
case UNW_RISCV_D21:
|
||||
return "d21";
|
||||
case UNW_RISCV_D22:
|
||||
return "d22";
|
||||
case UNW_RISCV_D23:
|
||||
return "d23";
|
||||
case UNW_RISCV_D24:
|
||||
return "d24";
|
||||
case UNW_RISCV_D25:
|
||||
return "d25";
|
||||
case UNW_RISCV_D26:
|
||||
return "d26";
|
||||
case UNW_RISCV_D27:
|
||||
return "d27";
|
||||
case UNW_RISCV_D28:
|
||||
return "d28";
|
||||
case UNW_RISCV_D29:
|
||||
return "d29";
|
||||
case UNW_RISCV_D30:
|
||||
return "d30";
|
||||
case UNW_RISCV_D31:
|
||||
return "d31";
|
||||
default:
|
||||
return "unknown register";
|
||||
}
|
||||
}
|
||||
|
||||
inline bool Registers_riscv::validFloatRegister(int regNum) const {
|
||||
if (regNum < UNW_RISCV_D0)
|
||||
return false;
|
||||
if (regNum > UNW_RISCV_D31)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline double Registers_riscv::getFloatRegister(int regNum) const {
|
||||
assert(validFloatRegister(regNum));
|
||||
return _vectorHalfRegisters[regNum - UNW_RISCV_D0];
|
||||
}
|
||||
|
||||
inline void Registers_riscv::setFloatRegister(int regNum, double value) {
|
||||
assert(validFloatRegister(regNum));
|
||||
_vectorHalfRegisters[regNum - UNW_RISCV_D0] = value;
|
||||
}
|
||||
|
||||
inline bool Registers_riscv::validVectorRegister(int) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
inline v128 Registers_riscv::getVectorRegister(int) const {
|
||||
_LIBUNWIND_ABORT("no riscv vector register support yet");
|
||||
}
|
||||
|
||||
inline void Registers_riscv::setVectorRegister(int, v128) {
|
||||
_LIBUNWIND_ABORT("no riscv vector register support yet");
|
||||
}
|
||||
#endif // _LIBUNWIND_TARGET_PPC
|
||||
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_AARCH64)
|
||||
/// Registers_arm64 holds the register state of a thread in a 64-bit arm
|
||||
/// process.
|
||||
class _LIBUNWIND_HIDDEN Registers_arm64 {
|
||||
@@ -1329,8 +1078,8 @@ private:
|
||||
};
|
||||
|
||||
inline Registers_arm64::Registers_arm64(const void *registers) {
|
||||
static_assert(sizeof(Registers_arm64) < sizeof(unw_context_t),
|
||||
"arm64 registers do not fit into unw_context_t");
|
||||
static_assert((check_fit<Registers_arm64, unw_context_t>::does_fit),
|
||||
"arm64 registers do not fit into unw_context_t");
|
||||
memcpy(&_registers, registers, sizeof(_registers));
|
||||
static_assert(sizeof(GPRs) == 0x110,
|
||||
"expected VFP registers to be at offset 272");
|
||||
@@ -1547,7 +1296,9 @@ inline v128 Registers_arm64::getVectorRegister(int) const {
|
||||
inline void Registers_arm64::setVectorRegister(int, v128) {
|
||||
_LIBUNWIND_ABORT("no arm64 vector register support yet");
|
||||
}
|
||||
#endif // _LIBUNWIND_TARGET_AARCH64
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_ARM)
|
||||
/// Registers_arm holds the register state of a thread in a 32-bit arm
|
||||
/// process.
|
||||
///
|
||||
@@ -1653,8 +1404,8 @@ inline Registers_arm::Registers_arm(const void *registers)
|
||||
_saved_vfp_d16_d31(false),
|
||||
_saved_iwmmx(false),
|
||||
_saved_iwmmx_control(false) {
|
||||
static_assert(sizeof(Registers_arm) < sizeof(unw_context_t),
|
||||
"arm registers do not fit into unw_context_t");
|
||||
static_assert((check_fit<Registers_arm, unw_context_t>::does_fit),
|
||||
"arm registers do not fit into unw_context_t");
|
||||
// See unw_getcontext() note about data.
|
||||
memcpy(&_registers, registers, sizeof(_registers));
|
||||
memset(&_vfp_d0_d15_pad, 0, sizeof(_vfp_d0_d15_pad));
|
||||
@@ -1969,6 +1720,10 @@ inline v128 Registers_arm::getVectorRegister(int) const {
|
||||
inline void Registers_arm::setVectorRegister(int, v128) {
|
||||
_LIBUNWIND_ABORT("ARM vector support not implemented");
|
||||
}
|
||||
#endif // _LIBUNWIND_TARGET_ARM
|
||||
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_OR1K)
|
||||
/// Registers_or1k holds the register state of a thread in an OpenRISC1000
|
||||
/// process.
|
||||
class _LIBUNWIND_HIDDEN Registers_or1k {
|
||||
@@ -2003,8 +1758,8 @@ private:
|
||||
};
|
||||
|
||||
inline Registers_or1k::Registers_or1k(const void *registers) {
|
||||
static_assert(sizeof(Registers_or1k) < sizeof(unw_context_t),
|
||||
"or1k registers do not fit into unw_context_t");
|
||||
static_assert((check_fit<Registers_or1k, unw_context_t>::does_fit),
|
||||
"or1k registers do not fit into unw_context_t");
|
||||
memcpy(&_registers, static_cast<const uint8_t *>(registers),
|
||||
sizeof(_registers));
|
||||
}
|
||||
@@ -2151,6 +1906,268 @@ inline const char *Registers_or1k::getRegisterName(int regNum) {
|
||||
}
|
||||
|
||||
}
|
||||
#endif // _LIBUNWIND_TARGET_OR1K
|
||||
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_RISCV)
|
||||
/// Registers_riscv holds the register state of a thread in a 64-bit RISC-V
|
||||
/// process.
|
||||
class _LIBUNWIND_HIDDEN Registers_riscv {
|
||||
public:
|
||||
Registers_riscv();
|
||||
Registers_riscv(const void *registers);
|
||||
|
||||
bool validRegister(int num) const;
|
||||
uint64_t getRegister(int num) const;
|
||||
void setRegister(int num, uint64_t value);
|
||||
bool validFloatRegister(int num) const;
|
||||
double getFloatRegister(int num) const;
|
||||
void setFloatRegister(int num, double value);
|
||||
bool validVectorRegister(int num) const;
|
||||
v128 getVectorRegister(int num) const;
|
||||
void setVectorRegister(int num, v128 value);
|
||||
const char *getRegisterName(int num);
|
||||
void jumpto();
|
||||
static int lastDwarfRegNum() { return 95; }
|
||||
|
||||
uint64_t getSP() const { return _registers.__x[2]; }
|
||||
void setSP(uint64_t value) { _registers.__x[2] = value; }
|
||||
uint64_t getIP() const { return _registers.__x[1]; }
|
||||
void setIP(uint64_t value) { _registers.__x[1] = value; }
|
||||
|
||||
private:
|
||||
struct GPRs {
|
||||
uint64_t __x[32]; // x0-x31
|
||||
};
|
||||
|
||||
GPRs _registers;
|
||||
double _vectorHalfRegisters[32];
|
||||
// Currently only the lower double in 128-bit vectore registers
|
||||
// is perserved during unwinding. We could define new register
|
||||
// numbers (> 96) which mean whole vector registers, then this
|
||||
// struct would need to change to contain whole vector registers.
|
||||
};
|
||||
|
||||
inline Registers_riscv::Registers_riscv(const void *registers) {
|
||||
static_assert((check_fit<Registers_riscv, unw_context_t>::does_fit),
|
||||
"riscv registers do not fit into unw_context_t");
|
||||
memcpy(&_registers, registers, sizeof(_registers));
|
||||
static_assert(sizeof(GPRs) == 0x100,
|
||||
"expected VFP registers to be at offset 256");
|
||||
memcpy(_vectorHalfRegisters,
|
||||
static_cast<const uint8_t *>(registers) + sizeof(GPRs),
|
||||
sizeof(_vectorHalfRegisters));
|
||||
}
|
||||
|
||||
inline Registers_riscv::Registers_riscv() {
|
||||
memset(&_registers, 0, sizeof(_registers));
|
||||
memset(&_vectorHalfRegisters, 0, sizeof(_vectorHalfRegisters));
|
||||
}
|
||||
|
||||
inline bool Registers_riscv::validRegister(int regNum) const {
|
||||
if (regNum == UNW_REG_IP)
|
||||
return true;
|
||||
if (regNum == UNW_REG_SP)
|
||||
return true;
|
||||
if (regNum < 0)
|
||||
return false;
|
||||
if (regNum > 95)
|
||||
return false;
|
||||
if ((regNum > 31) && (regNum < 64))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline uint64_t Registers_riscv::getRegister(int regNum) const {
|
||||
if (regNum == UNW_REG_IP)
|
||||
return _registers.__x[1];
|
||||
if (regNum == UNW_REG_SP)
|
||||
return _registers.__x[2];
|
||||
if ((regNum >= 0) && (regNum < 32))
|
||||
return _registers.__x[regNum];
|
||||
_LIBUNWIND_ABORT("unsupported riscv register");
|
||||
}
|
||||
|
||||
inline void Registers_riscv::setRegister(int regNum, uint64_t value) {
|
||||
if (regNum == UNW_REG_IP)
|
||||
_registers.__x[1] = value;
|
||||
else if (regNum == UNW_REG_SP)
|
||||
_registers.__x[2] = value;
|
||||
else if ((regNum >= 0) && (regNum < 32))
|
||||
_registers.__x[regNum] = value;
|
||||
else
|
||||
_LIBUNWIND_ABORT("unsupported riscv register");
|
||||
}
|
||||
|
||||
inline const char *Registers_riscv::getRegisterName(int regNum) {
|
||||
switch (regNum) {
|
||||
case UNW_REG_IP:
|
||||
return "ra";
|
||||
case UNW_REG_SP:
|
||||
return "sp";
|
||||
case UNW_RISCV_X0:
|
||||
return "x0";
|
||||
case UNW_RISCV_X1:
|
||||
return "ra";
|
||||
case UNW_RISCV_X2:
|
||||
return "sp";
|
||||
case UNW_RISCV_X3:
|
||||
return "x3";
|
||||
case UNW_RISCV_X4:
|
||||
return "x4";
|
||||
case UNW_RISCV_X5:
|
||||
return "x5";
|
||||
case UNW_RISCV_X6:
|
||||
return "x6";
|
||||
case UNW_RISCV_X7:
|
||||
return "x7";
|
||||
case UNW_RISCV_X8:
|
||||
return "x8";
|
||||
case UNW_RISCV_X9:
|
||||
return "x9";
|
||||
case UNW_RISCV_X10:
|
||||
return "x10";
|
||||
case UNW_RISCV_X11:
|
||||
return "x11";
|
||||
case UNW_RISCV_X12:
|
||||
return "x12";
|
||||
case UNW_RISCV_X13:
|
||||
return "x13";
|
||||
case UNW_RISCV_X14:
|
||||
return "x14";
|
||||
case UNW_RISCV_X15:
|
||||
return "x15";
|
||||
case UNW_RISCV_X16:
|
||||
return "x16";
|
||||
case UNW_RISCV_X17:
|
||||
return "x17";
|
||||
case UNW_RISCV_X18:
|
||||
return "x18";
|
||||
case UNW_RISCV_X19:
|
||||
return "x19";
|
||||
case UNW_RISCV_X20:
|
||||
return "x20";
|
||||
case UNW_RISCV_X21:
|
||||
return "x21";
|
||||
case UNW_RISCV_X22:
|
||||
return "x22";
|
||||
case UNW_RISCV_X23:
|
||||
return "x23";
|
||||
case UNW_RISCV_X24:
|
||||
return "x24";
|
||||
case UNW_RISCV_X25:
|
||||
return "x25";
|
||||
case UNW_RISCV_X26:
|
||||
return "x26";
|
||||
case UNW_RISCV_X27:
|
||||
return "x27";
|
||||
case UNW_RISCV_X28:
|
||||
return "x28";
|
||||
case UNW_RISCV_X29:
|
||||
return "x29";
|
||||
case UNW_RISCV_X30:
|
||||
return "x30";
|
||||
case UNW_RISCV_X31:
|
||||
return "x31";
|
||||
case UNW_RISCV_D0:
|
||||
return "d0";
|
||||
case UNW_RISCV_D1:
|
||||
return "d1";
|
||||
case UNW_RISCV_D2:
|
||||
return "d2";
|
||||
case UNW_RISCV_D3:
|
||||
return "d3";
|
||||
case UNW_RISCV_D4:
|
||||
return "d4";
|
||||
case UNW_RISCV_D5:
|
||||
return "d5";
|
||||
case UNW_RISCV_D6:
|
||||
return "d6";
|
||||
case UNW_RISCV_D7:
|
||||
return "d7";
|
||||
case UNW_RISCV_D8:
|
||||
return "d8";
|
||||
case UNW_RISCV_D9:
|
||||
return "d9";
|
||||
case UNW_RISCV_D10:
|
||||
return "d10";
|
||||
case UNW_RISCV_D11:
|
||||
return "d11";
|
||||
case UNW_RISCV_D12:
|
||||
return "d12";
|
||||
case UNW_RISCV_D13:
|
||||
return "d13";
|
||||
case UNW_RISCV_D14:
|
||||
return "d14";
|
||||
case UNW_RISCV_D15:
|
||||
return "d15";
|
||||
case UNW_RISCV_D16:
|
||||
return "d16";
|
||||
case UNW_RISCV_D17:
|
||||
return "d17";
|
||||
case UNW_RISCV_D18:
|
||||
return "d18";
|
||||
case UNW_RISCV_D19:
|
||||
return "d19";
|
||||
case UNW_RISCV_D20:
|
||||
return "d20";
|
||||
case UNW_RISCV_D21:
|
||||
return "d21";
|
||||
case UNW_RISCV_D22:
|
||||
return "d22";
|
||||
case UNW_RISCV_D23:
|
||||
return "d23";
|
||||
case UNW_RISCV_D24:
|
||||
return "d24";
|
||||
case UNW_RISCV_D25:
|
||||
return "d25";
|
||||
case UNW_RISCV_D26:
|
||||
return "d26";
|
||||
case UNW_RISCV_D27:
|
||||
return "d27";
|
||||
case UNW_RISCV_D28:
|
||||
return "d28";
|
||||
case UNW_RISCV_D29:
|
||||
return "d29";
|
||||
case UNW_RISCV_D30:
|
||||
return "d30";
|
||||
case UNW_RISCV_D31:
|
||||
return "d31";
|
||||
default:
|
||||
return "unknown register";
|
||||
}
|
||||
}
|
||||
|
||||
inline bool Registers_riscv::validFloatRegister(int regNum) const {
|
||||
if (regNum < UNW_RISCV_D0)
|
||||
return false;
|
||||
if (regNum > UNW_RISCV_D31)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline double Registers_riscv::getFloatRegister(int regNum) const {
|
||||
assert(validFloatRegister(regNum));
|
||||
return _vectorHalfRegisters[regNum - UNW_RISCV_D0];
|
||||
}
|
||||
|
||||
inline void Registers_riscv::setFloatRegister(int regNum, double value) {
|
||||
assert(validFloatRegister(regNum));
|
||||
_vectorHalfRegisters[regNum - UNW_RISCV_D0] = value;
|
||||
}
|
||||
|
||||
inline bool Registers_riscv::validVectorRegister(int) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
inline v128 Registers_riscv::getVectorRegister(int) const {
|
||||
_LIBUNWIND_ABORT("no riscv vector register support yet");
|
||||
}
|
||||
|
||||
inline void Registers_riscv::setVectorRegister(int, v128) {
|
||||
_LIBUNWIND_ABORT("no riscv vector register support yet");
|
||||
}
|
||||
#endif // _LIBUNWIND_TARGET_RISCV
|
||||
} // namespace libunwind
|
||||
|
||||
#endif // __REGISTERS_HPP__
|
||||
@@ -438,39 +438,21 @@ extern "C" _Unwind_Reason_Code __aeabi_unwind_cpp_pr2(
|
||||
}
|
||||
|
||||
static _Unwind_Reason_Code
|
||||
unwind_phase1(unw_context_t *uc, _Unwind_Exception *exception_object) {
|
||||
unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
|
||||
// EHABI #7.3 discusses preserving the VRS in a "temporary VRS" during
|
||||
// phase 1 and then restoring it to the "primary VRS" for phase 2. The
|
||||
// effect is phase 2 doesn't see any of the VRS manipulations from phase 1.
|
||||
// In this implementation, the phases don't share the VRS backing store.
|
||||
// Instead, they are passed the original |uc| and they create a new VRS
|
||||
// from scratch thus achieving the same effect.
|
||||
unw_cursor_t cursor1;
|
||||
unw_init_local(&cursor1, uc);
|
||||
unw_init_local(cursor, uc);
|
||||
|
||||
// Walk each frame looking for a place to stop.
|
||||
for (bool handlerNotFound = true; handlerNotFound;) {
|
||||
|
||||
#if !_LIBUNWIND_ARM_EHABI
|
||||
// Ask libuwind to get next frame (skip over first which is
|
||||
// _Unwind_RaiseException).
|
||||
int stepResult = unw_step(&cursor1);
|
||||
if (stepResult == 0) {
|
||||
_LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_step() reached "
|
||||
"bottom => _URC_END_OF_STACK\n",
|
||||
static_cast<void *>(exception_object));
|
||||
return _URC_END_OF_STACK;
|
||||
} else if (stepResult < 0) {
|
||||
_LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_step failed => "
|
||||
"_URC_FATAL_PHASE1_ERROR\n",
|
||||
static_cast<void *>(exception_object));
|
||||
return _URC_FATAL_PHASE1_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
// See if frame has code to run (has personality routine).
|
||||
unw_proc_info_t frameInfo;
|
||||
if (unw_get_proc_info(&cursor1, &frameInfo) != UNW_ESUCCESS) {
|
||||
if (unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
|
||||
_LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_get_proc_info "
|
||||
"failed => _URC_FATAL_PHASE1_ERROR\n",
|
||||
static_cast<void *>(exception_object));
|
||||
@@ -482,12 +464,12 @@ unwind_phase1(unw_context_t *uc, _Unwind_Exception *exception_object) {
|
||||
char functionBuf[512];
|
||||
const char *functionName = functionBuf;
|
||||
unw_word_t offset;
|
||||
if ((unw_get_proc_name(&cursor1, functionBuf, sizeof(functionBuf),
|
||||
if ((unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
|
||||
&offset) != UNW_ESUCCESS) ||
|
||||
(frameInfo.start_ip + offset > frameInfo.end_ip))
|
||||
functionName = ".anonymous.";
|
||||
unw_word_t pc;
|
||||
unw_get_reg(&cursor1, UNW_REG_IP, &pc);
|
||||
unw_get_reg(cursor, UNW_REG_IP, &pc);
|
||||
_LIBUNWIND_TRACE_UNWINDING(
|
||||
"unwind_phase1(ex_ojb=%p): pc=0x%llX, start_ip=0x%llX, func=%s, "
|
||||
"lsda=0x%llX, personality=0x%llX\n",
|
||||
@@ -505,7 +487,7 @@ unwind_phase1(unw_context_t *uc, _Unwind_Exception *exception_object) {
|
||||
"unwind_phase1(ex_ojb=%p): calling personality function %p\n",
|
||||
static_cast<void *>(exception_object),
|
||||
reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(p)));
|
||||
struct _Unwind_Context *context = (struct _Unwind_Context *)(&cursor1);
|
||||
struct _Unwind_Context *context = (struct _Unwind_Context *)(cursor);
|
||||
exception_object->pr_cache.fnstart = frameInfo.start_ip;
|
||||
exception_object->pr_cache.ehtp =
|
||||
(_Unwind_EHT_Header *)frameInfo.unwind_info;
|
||||
@@ -553,12 +535,11 @@ unwind_phase1(unw_context_t *uc, _Unwind_Exception *exception_object) {
|
||||
return _URC_NO_REASON;
|
||||
}
|
||||
|
||||
static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc,
|
||||
static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor,
|
||||
_Unwind_Exception *exception_object,
|
||||
bool resume) {
|
||||
// See comment at the start of unwind_phase1 regarding VRS integrity.
|
||||
unw_cursor_t cursor2;
|
||||
unw_init_local(&cursor2, uc);
|
||||
unw_init_local(cursor, uc);
|
||||
|
||||
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p)\n",
|
||||
static_cast<void *>(exception_object));
|
||||
@@ -580,33 +561,18 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc,
|
||||
// for. After this, continue unwinding as if normal.
|
||||
//
|
||||
// See #7.4.6 for details.
|
||||
unw_set_reg(&cursor2, UNW_REG_IP,
|
||||
unw_set_reg(cursor, UNW_REG_IP,
|
||||
exception_object->unwinder_cache.reserved2);
|
||||
resume = false;
|
||||
}
|
||||
|
||||
#if !_LIBUNWIND_ARM_EHABI
|
||||
int stepResult = unw_step(&cursor2);
|
||||
if (stepResult == 0) {
|
||||
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step() reached "
|
||||
"bottom => _URC_END_OF_STACK\n",
|
||||
static_cast<void *>(exception_object));
|
||||
return _URC_END_OF_STACK;
|
||||
} else if (stepResult < 0) {
|
||||
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step failed => "
|
||||
"_URC_FATAL_PHASE1_ERROR\n",
|
||||
static_cast<void *>(exception_object));
|
||||
return _URC_FATAL_PHASE2_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Get info about this frame.
|
||||
unw_word_t sp;
|
||||
unw_proc_info_t frameInfo;
|
||||
unw_get_reg(&cursor2, UNW_REG_SP, &sp);
|
||||
if (unw_get_proc_info(&cursor2, &frameInfo) != UNW_ESUCCESS) {
|
||||
unw_get_reg(cursor, UNW_REG_SP, &sp);
|
||||
if (unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
|
||||
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_get_proc_info "
|
||||
"failed => _URC_FATAL_PHASE1_ERROR\n",
|
||||
"failed => _URC_FATAL_PHASE2_ERROR\n",
|
||||
static_cast<void *>(exception_object));
|
||||
return _URC_FATAL_PHASE2_ERROR;
|
||||
}
|
||||
@@ -616,7 +582,7 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc,
|
||||
char functionBuf[512];
|
||||
const char *functionName = functionBuf;
|
||||
unw_word_t offset;
|
||||
if ((unw_get_proc_name(&cursor2, functionBuf, sizeof(functionBuf),
|
||||
if ((unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
|
||||
&offset) != UNW_ESUCCESS) ||
|
||||
(frameInfo.start_ip + offset > frameInfo.end_ip))
|
||||
functionName = ".anonymous.";
|
||||
@@ -632,7 +598,7 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc,
|
||||
if (frameInfo.handler != 0) {
|
||||
__personality_routine p =
|
||||
(__personality_routine)(long)(frameInfo.handler);
|
||||
struct _Unwind_Context *context = (struct _Unwind_Context *)(&cursor2);
|
||||
struct _Unwind_Context *context = (struct _Unwind_Context *)(cursor);
|
||||
// EHABI #7.2
|
||||
exception_object->pr_cache.fnstart = frameInfo.start_ip;
|
||||
exception_object->pr_cache.ehtp =
|
||||
@@ -661,8 +627,8 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc,
|
||||
// We may get control back if landing pad calls _Unwind_Resume().
|
||||
if (_LIBUNWIND_TRACING_UNWINDING) {
|
||||
unw_word_t pc;
|
||||
unw_get_reg(&cursor2, UNW_REG_IP, &pc);
|
||||
unw_get_reg(&cursor2, UNW_REG_SP, &sp);
|
||||
unw_get_reg(cursor, UNW_REG_IP, &pc);
|
||||
unw_get_reg(cursor, UNW_REG_SP, &sp);
|
||||
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): re-entering "
|
||||
"user code with ip=0x%llX, sp=0x%llX\n",
|
||||
static_cast<void *>(exception_object),
|
||||
@@ -673,10 +639,10 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc,
|
||||
// EHABI #7.4.1 says we need to preserve pc for when _Unwind_Resume
|
||||
// is called back, to find this same frame.
|
||||
unw_word_t pc;
|
||||
unw_get_reg(&cursor2, UNW_REG_IP, &pc);
|
||||
unw_get_reg(cursor, UNW_REG_IP, &pc);
|
||||
exception_object->unwinder_cache.reserved2 = (uint32_t)pc;
|
||||
}
|
||||
unw_resume(&cursor2);
|
||||
unw_resume(cursor);
|
||||
// unw_resume() only returns if there was an error.
|
||||
return _URC_FATAL_PHASE2_ERROR;
|
||||
|
||||
@@ -705,6 +671,7 @@ _Unwind_RaiseException(_Unwind_Exception *exception_object) {
|
||||
_LIBUNWIND_TRACE_API("_Unwind_RaiseException(ex_obj=%p)\n",
|
||||
static_cast<void *>(exception_object));
|
||||
unw_context_t uc;
|
||||
unw_cursor_t cursor;
|
||||
unw_getcontext(&uc);
|
||||
|
||||
// This field for is for compatibility with GCC to say this isn't a forced
|
||||
@@ -712,12 +679,12 @@ _Unwind_RaiseException(_Unwind_Exception *exception_object) {
|
||||
exception_object->unwinder_cache.reserved1 = 0;
|
||||
|
||||
// phase 1: the search phase
|
||||
_Unwind_Reason_Code phase1 = unwind_phase1(&uc, exception_object);
|
||||
_Unwind_Reason_Code phase1 = unwind_phase1(&uc, &cursor, exception_object);
|
||||
if (phase1 != _URC_NO_REASON)
|
||||
return phase1;
|
||||
|
||||
// phase 2: the clean up phase
|
||||
return unwind_phase2(&uc, exception_object, false);
|
||||
return unwind_phase2(&uc, &cursor, exception_object, false);
|
||||
}
|
||||
|
||||
_LIBUNWIND_EXPORT void _Unwind_Complete(_Unwind_Exception* exception_object) {
|
||||
@@ -742,12 +709,13 @@ _Unwind_Resume(_Unwind_Exception *exception_object) {
|
||||
_LIBUNWIND_TRACE_API("_Unwind_Resume(ex_obj=%p)\n",
|
||||
static_cast<void *>(exception_object));
|
||||
unw_context_t uc;
|
||||
unw_cursor_t cursor;
|
||||
unw_getcontext(&uc);
|
||||
|
||||
// _Unwind_RaiseException on EHABI will always set the reserved1 field to 0,
|
||||
// which is in the same position as private_1 below.
|
||||
// TODO(ajwong): Who wronte the above? Why is it true?
|
||||
unwind_phase2(&uc, exception_object, true);
|
||||
unwind_phase2(&uc, &cursor, exception_object, true);
|
||||
|
||||
// Clients assume _Unwind_Resume() does not return, so all we can do is abort.
|
||||
_LIBUNWIND_ABORT("_Unwind_Resume() can't return");
|
||||
|
||||
@@ -481,30 +481,39 @@ private:
|
||||
return stepWithCompactEncoding(dummy);
|
||||
}
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_X86_64)
|
||||
int stepWithCompactEncoding(Registers_x86_64 &) {
|
||||
return CompactUnwinder_x86_64<A>::stepWithCompactEncoding(
|
||||
_info.format, _info.start_ip, _addressSpace, _registers);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_I386)
|
||||
int stepWithCompactEncoding(Registers_x86 &) {
|
||||
return CompactUnwinder_x86<A>::stepWithCompactEncoding(
|
||||
_info.format, (uint32_t)_info.start_ip, _addressSpace, _registers);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_PPC)
|
||||
int stepWithCompactEncoding(Registers_ppc &) {
|
||||
return UNW_EINVAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_AARCH64)
|
||||
int stepWithCompactEncoding(Registers_arm64 &) {
|
||||
return CompactUnwinder_arm64<A>::stepWithCompactEncoding(
|
||||
_info.format, _info.start_ip, _addressSpace, _registers);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool compactSaysUseDwarf(uint32_t *offset=NULL) const {
|
||||
R dummy;
|
||||
return compactSaysUseDwarf(dummy, offset);
|
||||
}
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_X86_64)
|
||||
bool compactSaysUseDwarf(Registers_x86_64 &, uint32_t *offset) const {
|
||||
if ((_info.format & UNWIND_X86_64_MODE_MASK) == UNWIND_X86_64_MODE_DWARF) {
|
||||
if (offset)
|
||||
@@ -513,7 +522,9 @@ private:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_I386)
|
||||
bool compactSaysUseDwarf(Registers_x86 &, uint32_t *offset) const {
|
||||
if ((_info.format & UNWIND_X86_MODE_MASK) == UNWIND_X86_MODE_DWARF) {
|
||||
if (offset)
|
||||
@@ -522,11 +533,15 @@ private:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_PPC)
|
||||
bool compactSaysUseDwarf(Registers_ppc &, uint32_t *) const {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_AARCH64)
|
||||
bool compactSaysUseDwarf(Registers_arm64 &, uint32_t *offset) const {
|
||||
if ((_info.format & UNWIND_ARM64_MODE_MASK) == UNWIND_ARM64_MODE_DWARF) {
|
||||
if (offset)
|
||||
@@ -535,6 +550,7 @@ private:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBUNWIND_SUPPORT_COMPACT_UNWIND
|
||||
|
||||
#if _LIBUNWIND_SUPPORT_DWARF_UNWIND
|
||||
@@ -543,29 +559,41 @@ private:
|
||||
return dwarfEncoding(dummy);
|
||||
}
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_X86_64)
|
||||
compact_unwind_encoding_t dwarfEncoding(Registers_x86_64 &) const {
|
||||
return UNWIND_X86_64_MODE_DWARF;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_I386)
|
||||
compact_unwind_encoding_t dwarfEncoding(Registers_x86 &) const {
|
||||
return UNWIND_X86_MODE_DWARF;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_PPC)
|
||||
compact_unwind_encoding_t dwarfEncoding(Registers_ppc &) const {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_LIBUNWIND_TARGET_AARCH64)
|
||||
compact_unwind_encoding_t dwarfEncoding(Registers_arm64 &) const {
|
||||
return UNWIND_ARM64_MODE_DWARF;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (_LIBUNWIND_TARGET_OR1K)
|
||||
compact_unwind_encoding_t dwarfEncoding(Registers_or1k &) const {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (_LIBUNWIND_TARGET_RISCV)
|
||||
compact_unwind_encoding_t dwarfEncoding(Registers_riscv &) const {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif // _LIBUNWIND_SUPPORT_DWARF_UNWIND
|
||||
|
||||
|
||||
@@ -581,7 +609,7 @@ template <typename A, typename R>
|
||||
UnwindCursor<A, R>::UnwindCursor(unw_context_t *context, A &as)
|
||||
: _addressSpace(as), _registers(context), _unwindInfoMissing(false),
|
||||
_isSignalFrame(false) {
|
||||
static_assert(sizeof(UnwindCursor<A, R>) < sizeof(unw_cursor_t),
|
||||
static_assert((check_fit<UnwindCursor<A, R>, unw_cursor_t>::does_fit),
|
||||
"UnwindCursor<> does not fit in unw_cursor_t");
|
||||
memset(&_info, 0, sizeof(_info));
|
||||
}
|
||||
|
||||
@@ -33,16 +33,15 @@
|
||||
#if !_LIBUNWIND_ARM_EHABI
|
||||
|
||||
static _Unwind_Reason_Code
|
||||
unwind_phase1(unw_context_t *uc, _Unwind_Exception *exception_object) {
|
||||
unw_cursor_t cursor1;
|
||||
unw_init_local(&cursor1, uc);
|
||||
unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
|
||||
unw_init_local(cursor, uc);
|
||||
|
||||
// Walk each frame looking for a place to stop.
|
||||
bool handlerNotFound = true;
|
||||
while (handlerNotFound) {
|
||||
// Ask libuwind to get next frame (skip over first which is
|
||||
// _Unwind_RaiseException).
|
||||
int stepResult = unw_step(&cursor1);
|
||||
int stepResult = unw_step(cursor);
|
||||
if (stepResult == 0) {
|
||||
_LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_step() reached "
|
||||
"bottom => _URC_END_OF_STACK\n",
|
||||
@@ -58,7 +57,7 @@ unwind_phase1(unw_context_t *uc, _Unwind_Exception *exception_object) {
|
||||
// See if frame has code to run (has personality routine).
|
||||
unw_proc_info_t frameInfo;
|
||||
unw_word_t sp;
|
||||
if (unw_get_proc_info(&cursor1, &frameInfo) != UNW_ESUCCESS) {
|
||||
if (unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
|
||||
_LIBUNWIND_TRACE_UNWINDING("unwind_phase1(ex_ojb=%p): unw_get_proc_info "
|
||||
"failed => _URC_FATAL_PHASE1_ERROR\n",
|
||||
(void *)exception_object);
|
||||
@@ -70,12 +69,12 @@ unwind_phase1(unw_context_t *uc, _Unwind_Exception *exception_object) {
|
||||
char functionBuf[512];
|
||||
const char *functionName = functionBuf;
|
||||
unw_word_t offset;
|
||||
if ((unw_get_proc_name(&cursor1, functionBuf, sizeof(functionBuf),
|
||||
if ((unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
|
||||
&offset) != UNW_ESUCCESS) ||
|
||||
(frameInfo.start_ip + offset > frameInfo.end_ip))
|
||||
functionName = ".anonymous.";
|
||||
unw_word_t pc;
|
||||
unw_get_reg(&cursor1, UNW_REG_IP, &pc);
|
||||
unw_get_reg(cursor, UNW_REG_IP, &pc);
|
||||
_LIBUNWIND_TRACE_UNWINDING(
|
||||
"unwind_phase1(ex_ojb=%p): pc=0x%" PRIx64 ", start_ip=0x%" PRIx64
|
||||
", func=%s, lsda=0x%" PRIx64 ", personality=0x%" PRIx64 "\n",
|
||||
@@ -93,13 +92,13 @@ unwind_phase1(unw_context_t *uc, _Unwind_Exception *exception_object) {
|
||||
(void *)exception_object, (void *)(uintptr_t)p);
|
||||
_Unwind_Reason_Code personalityResult =
|
||||
(*p)(1, _UA_SEARCH_PHASE, exception_object->exception_class,
|
||||
exception_object, (struct _Unwind_Context *)(&cursor1));
|
||||
exception_object, (struct _Unwind_Context *)(cursor));
|
||||
switch (personalityResult) {
|
||||
case _URC_HANDLER_FOUND:
|
||||
// found a catch clause or locals that need destructing in this frame
|
||||
// stop search and remember stack pointer at the frame
|
||||
handlerNotFound = false;
|
||||
unw_get_reg(&cursor1, UNW_REG_SP, &sp);
|
||||
unw_get_reg(cursor, UNW_REG_SP, &sp);
|
||||
exception_object->private_2 = (uintptr_t)sp;
|
||||
_LIBUNWIND_TRACE_UNWINDING(
|
||||
"unwind_phase1(ex_ojb=%p): _URC_HANDLER_FOUND \n",
|
||||
@@ -127,9 +126,8 @@ unwind_phase1(unw_context_t *uc, _Unwind_Exception *exception_object) {
|
||||
|
||||
|
||||
static _Unwind_Reason_Code
|
||||
unwind_phase2(unw_context_t *uc, _Unwind_Exception *exception_object) {
|
||||
unw_cursor_t cursor2;
|
||||
unw_init_local(&cursor2, uc);
|
||||
unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) {
|
||||
unw_init_local(cursor, uc);
|
||||
|
||||
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p)\n",
|
||||
(void *)exception_object);
|
||||
@@ -139,7 +137,7 @@ unwind_phase2(unw_context_t *uc, _Unwind_Exception *exception_object) {
|
||||
|
||||
// Ask libuwind to get next frame (skip over first which is
|
||||
// _Unwind_RaiseException).
|
||||
int stepResult = unw_step(&cursor2);
|
||||
int stepResult = unw_step(cursor);
|
||||
if (stepResult == 0) {
|
||||
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step() reached "
|
||||
"bottom => _URC_END_OF_STACK\n",
|
||||
@@ -155,8 +153,8 @@ unwind_phase2(unw_context_t *uc, _Unwind_Exception *exception_object) {
|
||||
// Get info about this frame.
|
||||
unw_word_t sp;
|
||||
unw_proc_info_t frameInfo;
|
||||
unw_get_reg(&cursor2, UNW_REG_SP, &sp);
|
||||
if (unw_get_proc_info(&cursor2, &frameInfo) != UNW_ESUCCESS) {
|
||||
unw_get_reg(cursor, UNW_REG_SP, &sp);
|
||||
if (unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
|
||||
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_get_proc_info "
|
||||
"failed => _URC_FATAL_PHASE1_ERROR\n",
|
||||
(void *)exception_object);
|
||||
@@ -168,7 +166,7 @@ unwind_phase2(unw_context_t *uc, _Unwind_Exception *exception_object) {
|
||||
char functionBuf[512];
|
||||
const char *functionName = functionBuf;
|
||||
unw_word_t offset;
|
||||
if ((unw_get_proc_name(&cursor2, functionBuf, sizeof(functionBuf),
|
||||
if ((unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
|
||||
&offset) != UNW_ESUCCESS) ||
|
||||
(frameInfo.start_ip + offset > frameInfo.end_ip))
|
||||
functionName = ".anonymous.";
|
||||
@@ -191,7 +189,7 @@ unwind_phase2(unw_context_t *uc, _Unwind_Exception *exception_object) {
|
||||
}
|
||||
_Unwind_Reason_Code personalityResult =
|
||||
(*p)(1, action, exception_object->exception_class, exception_object,
|
||||
(struct _Unwind_Context *)(&cursor2));
|
||||
(struct _Unwind_Context *)(cursor));
|
||||
switch (personalityResult) {
|
||||
case _URC_CONTINUE_UNWIND:
|
||||
// Continue unwinding
|
||||
@@ -212,14 +210,14 @@ unwind_phase2(unw_context_t *uc, _Unwind_Exception *exception_object) {
|
||||
// We may get control back if landing pad calls _Unwind_Resume().
|
||||
if (_LIBUNWIND_TRACING_UNWINDING) {
|
||||
unw_word_t pc;
|
||||
unw_get_reg(&cursor2, UNW_REG_IP, &pc);
|
||||
unw_get_reg(&cursor2, UNW_REG_SP, &sp);
|
||||
unw_get_reg(cursor, UNW_REG_IP, &pc);
|
||||
unw_get_reg(cursor, UNW_REG_SP, &sp);
|
||||
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): re-entering "
|
||||
"user code with ip=0x%" PRIx64
|
||||
", sp=0x%" PRIx64 "\n",
|
||||
(void *)exception_object, pc, sp);
|
||||
}
|
||||
unw_resume(&cursor2);
|
||||
unw_resume(cursor);
|
||||
// unw_resume() only returns if there was an error.
|
||||
return _URC_FATAL_PHASE2_ERROR;
|
||||
default:
|
||||
@@ -237,18 +235,17 @@ unwind_phase2(unw_context_t *uc, _Unwind_Exception *exception_object) {
|
||||
}
|
||||
|
||||
static _Unwind_Reason_Code
|
||||
unwind_phase2_forced(unw_context_t *uc,
|
||||
unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor,
|
||||
_Unwind_Exception *exception_object,
|
||||
_Unwind_Stop_Fn stop, void *stop_parameter) {
|
||||
unw_cursor_t cursor2;
|
||||
unw_init_local(&cursor2, uc);
|
||||
unw_init_local(cursor, uc);
|
||||
|
||||
// Walk each frame until we reach where search phase said to stop
|
||||
while (unw_step(&cursor2) > 0) {
|
||||
while (unw_step(cursor) > 0) {
|
||||
|
||||
// Update info about this frame.
|
||||
unw_proc_info_t frameInfo;
|
||||
if (unw_get_proc_info(&cursor2, &frameInfo) != UNW_ESUCCESS) {
|
||||
if (unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) {
|
||||
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): unw_step "
|
||||
"failed => _URC_END_OF_STACK\n",
|
||||
(void *)exception_object);
|
||||
@@ -260,7 +257,7 @@ unwind_phase2_forced(unw_context_t *uc,
|
||||
char functionBuf[512];
|
||||
const char *functionName = functionBuf;
|
||||
unw_word_t offset;
|
||||
if ((unw_get_proc_name(&cursor2, functionBuf, sizeof(functionBuf),
|
||||
if ((unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf),
|
||||
&offset) != UNW_ESUCCESS) ||
|
||||
(frameInfo.start_ip + offset > frameInfo.end_ip))
|
||||
functionName = ".anonymous.";
|
||||
@@ -276,7 +273,7 @@ unwind_phase2_forced(unw_context_t *uc,
|
||||
(_Unwind_Action)(_UA_FORCE_UNWIND | _UA_CLEANUP_PHASE);
|
||||
_Unwind_Reason_Code stopResult =
|
||||
(*stop)(1, action, exception_object->exception_class, exception_object,
|
||||
(struct _Unwind_Context *)(&cursor2), stop_parameter);
|
||||
(struct _Unwind_Context *)(cursor), stop_parameter);
|
||||
_LIBUNWIND_TRACE_UNWINDING(
|
||||
"unwind_phase2_forced(ex_ojb=%p): stop function returned %d\n",
|
||||
(void *)exception_object, stopResult);
|
||||
@@ -296,7 +293,7 @@ unwind_phase2_forced(unw_context_t *uc,
|
||||
(void *)exception_object, (void *)(uintptr_t)p);
|
||||
_Unwind_Reason_Code personalityResult =
|
||||
(*p)(1, action, exception_object->exception_class, exception_object,
|
||||
(struct _Unwind_Context *)(&cursor2));
|
||||
(struct _Unwind_Context *)(cursor));
|
||||
switch (personalityResult) {
|
||||
case _URC_CONTINUE_UNWIND:
|
||||
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): "
|
||||
@@ -311,7 +308,7 @@ unwind_phase2_forced(unw_context_t *uc,
|
||||
"_URC_INSTALL_CONTEXT\n",
|
||||
(void *)exception_object);
|
||||
// We may get control back if landing pad calls _Unwind_Resume().
|
||||
unw_resume(&cursor2);
|
||||
unw_resume(cursor);
|
||||
break;
|
||||
default:
|
||||
// Personality routine returned an unknown result code.
|
||||
@@ -332,7 +329,7 @@ unwind_phase2_forced(unw_context_t *uc,
|
||||
_Unwind_Action lastAction =
|
||||
(_Unwind_Action)(_UA_FORCE_UNWIND | _UA_CLEANUP_PHASE | _UA_END_OF_STACK);
|
||||
(*stop)(1, lastAction, exception_object->exception_class, exception_object,
|
||||
(struct _Unwind_Context *)(&cursor2), stop_parameter);
|
||||
(struct _Unwind_Context *)(cursor), stop_parameter);
|
||||
|
||||
// Clean up phase did not resume at the frame that the search phase said it
|
||||
// would.
|
||||
@@ -346,6 +343,7 @@ _Unwind_RaiseException(_Unwind_Exception *exception_object) {
|
||||
_LIBUNWIND_TRACE_API("_Unwind_RaiseException(ex_obj=%p)\n",
|
||||
(void *)exception_object);
|
||||
unw_context_t uc;
|
||||
unw_cursor_t cursor;
|
||||
unw_getcontext(&uc);
|
||||
|
||||
// Mark that this is a non-forced unwind, so _Unwind_Resume()
|
||||
@@ -354,12 +352,12 @@ _Unwind_RaiseException(_Unwind_Exception *exception_object) {
|
||||
exception_object->private_2 = 0;
|
||||
|
||||
// phase 1: the search phase
|
||||
_Unwind_Reason_Code phase1 = unwind_phase1(&uc, exception_object);
|
||||
_Unwind_Reason_Code phase1 = unwind_phase1(&uc, &cursor, exception_object);
|
||||
if (phase1 != _URC_NO_REASON)
|
||||
return phase1;
|
||||
|
||||
// phase 2: the clean up phase
|
||||
return unwind_phase2(&uc, exception_object);
|
||||
return unwind_phase2(&uc, &cursor, exception_object);
|
||||
}
|
||||
|
||||
|
||||
@@ -379,14 +377,15 @@ _LIBUNWIND_EXPORT void
|
||||
_Unwind_Resume(_Unwind_Exception *exception_object) {
|
||||
_LIBUNWIND_TRACE_API("_Unwind_Resume(ex_obj=%p)\n", (void *)exception_object);
|
||||
unw_context_t uc;
|
||||
unw_cursor_t cursor;
|
||||
unw_getcontext(&uc);
|
||||
|
||||
if (exception_object->private_1 != 0)
|
||||
unwind_phase2_forced(&uc, exception_object,
|
||||
unwind_phase2_forced(&uc, &cursor, exception_object,
|
||||
(_Unwind_Stop_Fn) exception_object->private_1,
|
||||
(void *)exception_object->private_2);
|
||||
else
|
||||
unwind_phase2(&uc, exception_object);
|
||||
unwind_phase2(&uc, &cursor, exception_object);
|
||||
|
||||
// Clients assume _Unwind_Resume() does not return, so all we can do is abort.
|
||||
_LIBUNWIND_ABORT("_Unwind_Resume() can't return");
|
||||
@@ -403,6 +402,7 @@ _Unwind_ForcedUnwind(_Unwind_Exception *exception_object,
|
||||
_LIBUNWIND_TRACE_API("_Unwind_ForcedUnwind(ex_obj=%p, stop=%p)\n",
|
||||
(void *)exception_object, (void *)(uintptr_t)stop);
|
||||
unw_context_t uc;
|
||||
unw_cursor_t cursor;
|
||||
unw_getcontext(&uc);
|
||||
|
||||
// Mark that this is a forced unwind, so _Unwind_Resume() can do
|
||||
@@ -411,7 +411,7 @@ _Unwind_ForcedUnwind(_Unwind_Exception *exception_object,
|
||||
exception_object->private_2 = (uintptr_t) stop_parameter;
|
||||
|
||||
// do it
|
||||
return unwind_phase2_forced(&uc, exception_object, stop, stop_parameter);
|
||||
return unwind_phase2_forced(&uc, &cursor, exception_object, stop, stop_parameter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -282,8 +282,8 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)
|
||||
ldp x22,x23, [x0, #0x0B0]
|
||||
ldp x24,x25, [x0, #0x0C0]
|
||||
ldp x26,x27, [x0, #0x0D0]
|
||||
ldp x28,fp, [x0, #0x0E0]
|
||||
ldr lr, [x0, #0x100] // restore pc into lr
|
||||
ldp x28,x29, [x0, #0x0E0]
|
||||
ldr x30, [x0, #0x100] // restore pc into lr
|
||||
ldr x1, [x0, #0x0F8]
|
||||
mov sp,x1 // restore sp
|
||||
|
||||
@@ -306,7 +306,7 @@ DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)
|
||||
ldr d31, [x0, #0x208]
|
||||
|
||||
ldp x0, x1, [x0, #0x000] // restore x0,x1
|
||||
ret lr // jump to pc
|
||||
ret x30 // jump to pc
|
||||
|
||||
#elif defined(__arm__) && !defined(__APPLE__)
|
||||
|
||||
|
||||
@@ -263,11 +263,11 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
|
||||
stp x22,x23, [x0, #0x0B0]
|
||||
stp x24,x25, [x0, #0x0C0]
|
||||
stp x26,x27, [x0, #0x0D0]
|
||||
stp x28,fp, [x0, #0x0E0]
|
||||
str lr, [x0, #0x0F0]
|
||||
stp x28,x29, [x0, #0x0E0]
|
||||
str x30, [x0, #0x0F0]
|
||||
mov x1,sp
|
||||
str x1, [x0, #0x0F8]
|
||||
str lr, [x0, #0x100] // store return address as pc
|
||||
str x30, [x0, #0x100] // store return address as pc
|
||||
// skip cpsr
|
||||
stp d0, d1, [x0, #0x110]
|
||||
stp d2, d3, [x0, #0x120]
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// Define static_assert() unless already defined by compiler.
|
||||
#ifndef __has_feature
|
||||
@@ -29,28 +30,6 @@
|
||||
|
||||
// Platform specific configuration defines.
|
||||
#ifdef __APPLE__
|
||||
#include <Availability.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void __assert_rtn(const char *, const char *, int, const char *)
|
||||
__attribute__((noreturn));
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#define _LIBUNWIND_BUILD_ZERO_COST_APIS (defined(__i386__) || \
|
||||
defined(__x86_64__) || \
|
||||
defined(__arm64__) || \
|
||||
defined(__mips__))
|
||||
#define _LIBUNWIND_BUILD_SJLJ_APIS defined(__arm__)
|
||||
#define _LIBUNWIND_SUPPORT_FRAME_APIS (defined(__i386__) || \
|
||||
defined(__x86_64__))
|
||||
#define _LIBUNWIND_EXPORT __attribute__((visibility("default")))
|
||||
#define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden")))
|
||||
#define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libuwind: " msg, __VA_ARGS__)
|
||||
#define _LIBUNWIND_ABORT(msg) __assert_rtn(__func__, __FILE__, __LINE__, msg)
|
||||
|
||||
#if defined(FOR_DYLD)
|
||||
#define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 1
|
||||
#define _LIBUNWIND_SUPPORT_DWARF_UNWIND 0
|
||||
@@ -60,36 +39,52 @@
|
||||
#define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
|
||||
#define _LIBUNWIND_SUPPORT_DWARF_INDEX 0
|
||||
#endif
|
||||
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
|
||||
static inline void assert_rtn(const char* func, const char* file, int line, const char* msg) __attribute__ ((noreturn));
|
||||
static inline void assert_rtn(const char* func, const char* file, int line, const char* msg) {
|
||||
fprintf(stderr, "libunwind: %s %s:%d - %s\n", func, file, line, msg);
|
||||
assert(false);
|
||||
abort();
|
||||
}
|
||||
|
||||
#define _LIBUNWIND_BUILD_ZERO_COST_APIS (defined(__i386__) || \
|
||||
defined(__x86_64__) || \
|
||||
defined(__arm__) || \
|
||||
defined(__aarch64__) || \
|
||||
defined(__riscv__))
|
||||
#define _LIBUNWIND_BUILD_SJLJ_APIS 0
|
||||
#define _LIBUNWIND_SUPPORT_FRAME_APIS (defined(__i386__) || \
|
||||
defined(__x86_64__))
|
||||
#define _LIBUNWIND_EXPORT __attribute__((visibility("default")))
|
||||
#define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden")))
|
||||
#define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libuwind: " msg, __VA_ARGS__)
|
||||
#define _LIBUNWIND_ABORT(msg) assert_rtn(__func__, __FILE__, __LINE__, msg)
|
||||
|
||||
#define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 0
|
||||
#define _LIBUNWIND_SUPPORT_DWARF_UNWIND !defined(__arm__) || \
|
||||
defined(__ARM_DWARF_EH__)
|
||||
#define _LIBUNWIND_SUPPORT_DWARF_INDEX _LIBUNWIND_SUPPORT_DWARF_UNWIND
|
||||
#if defined(__ARM_DWARF_EH__) || !defined(__arm__)
|
||||
#define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 0
|
||||
#define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
|
||||
#define _LIBUNWIND_SUPPORT_DWARF_INDEX 1
|
||||
#else
|
||||
#define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 0
|
||||
#define _LIBUNWIND_SUPPORT_DWARF_UNWIND 0
|
||||
#define _LIBUNWIND_SUPPORT_DWARF_INDEX 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// FIXME: these macros are not correct for COFF targets
|
||||
#define _LIBUNWIND_EXPORT __attribute__((visibility("default")))
|
||||
#define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden")))
|
||||
|
||||
#if (defined(__APPLE__) && defined(__arm__)) || defined(__USING_SJLJ_EXCEPTIONS__)
|
||||
#define _LIBUNWIND_BUILD_SJLJ_APIS 1
|
||||
#else
|
||||
#define _LIBUNWIND_BUILD_SJLJ_APIS 0
|
||||
#endif
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
#define _LIBUNWIND_SUPPORT_FRAME_APIS 1
|
||||
#else
|
||||
#define _LIBUNWIND_SUPPORT_FRAME_APIS 0
|
||||
#endif
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__) || \
|
||||
(!defined(__APPLE__) && defined(__arm__)) || \
|
||||
(defined(__arm64__) || defined(__aarch64__)) || \
|
||||
(defined(__APPLE__) && defined(__mips__)) || \
|
||||
defined(__riscv__)
|
||||
#define _LIBUNWIND_BUILD_ZERO_COST_APIS 1
|
||||
#else
|
||||
#define _LIBUNWIND_BUILD_ZERO_COST_APIS 0
|
||||
#endif
|
||||
|
||||
#define _LIBUNWIND_ABORT(msg) \
|
||||
do { \
|
||||
fprintf(stderr, "libunwind: %s %s:%d - %s\n", __func__, __FILE__, \
|
||||
__LINE__, msg); \
|
||||
fflush(stderr); \
|
||||
abort(); \
|
||||
} while (0)
|
||||
#define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libuwind: " msg, __VA_ARGS__)
|
||||
|
||||
// Macros that define away in non-Debug builds
|
||||
#ifdef NDEBUG
|
||||
@@ -125,5 +120,25 @@
|
||||
#define _LIBUNWIND_TRACING_UNWINDING logUnwinding()
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
// Used to fit UnwindCursor and Registers_xxx types against unw_context_t /
|
||||
// unw_cursor_t sized memory blocks.
|
||||
#if defined(_LIBUNWIND_IS_NATIVE_ONLY)
|
||||
# define COMP_OP ==
|
||||
#else
|
||||
# define COMP_OP <
|
||||
#endif
|
||||
template <typename _Type, typename _Mem>
|
||||
struct check_fit {
|
||||
template <typename T>
|
||||
struct blk_count {
|
||||
static const size_t count =
|
||||
(sizeof(T) + sizeof(uint64_t) - 1) / sizeof(uint64_t);
|
||||
};
|
||||
static const bool does_fit =
|
||||
(blk_count<_Type>::count COMP_OP blk_count<_Mem>::count);
|
||||
};
|
||||
#undef COMP_OP
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // LIBUNWIND_CONFIG_H
|
||||
@@ -45,33 +45,29 @@ _LIBUNWIND_EXPORT int unw_init_local(unw_cursor_t *cursor,
|
||||
_LIBUNWIND_TRACE_API("unw_init_local(cursor=%p, context=%p)\n",
|
||||
static_cast<void *>(cursor),
|
||||
static_cast<void *>(context));
|
||||
// Use "placement new" to allocate UnwindCursor in the cursor buffer.
|
||||
#if defined(__i386__)
|
||||
new ((void *)cursor) UnwindCursor<LocalAddressSpace, Registers_x86>(
|
||||
context, LocalAddressSpace::sThisAddressSpace);
|
||||
# define REGISTER_KIND Registers_x86
|
||||
#elif defined(__x86_64__)
|
||||
new ((void *)cursor) UnwindCursor<LocalAddressSpace, Registers_x86_64>(
|
||||
context, LocalAddressSpace::sThisAddressSpace);
|
||||
# define REGISTER_KIND Registers_x86_64
|
||||
#elif defined(__ppc__)
|
||||
new ((void *)cursor) UnwindCursor<LocalAddressSpace, Registers_ppc>(
|
||||
context, LocalAddressSpace::sThisAddressSpace);
|
||||
#elif defined(__arm64__) || defined(__aarch64__)
|
||||
new ((void *)cursor) UnwindCursor<LocalAddressSpace, Registers_arm64>(
|
||||
context, LocalAddressSpace::sThisAddressSpace);
|
||||
# define REGISTER_KIND Registers_ppc
|
||||
#elif defined(__aarch64__)
|
||||
# define REGISTER_KIND Registers_arm64
|
||||
#elif _LIBUNWIND_ARM_EHABI
|
||||
new ((void *)cursor) UnwindCursor<LocalAddressSpace, Registers_arm>(
|
||||
context, LocalAddressSpace::sThisAddressSpace);
|
||||
# define REGISTER_KIND Registers_arm
|
||||
#elif defined(__or1k__)
|
||||
new ((void *)cursor) UnwindCursor<LocalAddressSpace, Registers_or1k>(
|
||||
context, LocalAddressSpace::sThisAddressSpace);
|
||||
#elif defined(__mips__)
|
||||
#warning The MIPS architecture is not supported.
|
||||
# define REGISTER_KIND Registers_or1k
|
||||
#elif defined(__riscv__)
|
||||
new ((void *)cursor) UnwindCursor<LocalAddressSpace, Registers_riscv>(
|
||||
context, LocalAddressSpace::sThisAddressSpace);
|
||||
# define REGISTER_KIND Registers_riscv
|
||||
#elif defined(__mips__)
|
||||
# warning The MIPS architecture is not supported.
|
||||
#else
|
||||
#error Architecture not supported
|
||||
# error Architecture not supported
|
||||
#endif
|
||||
// Use "placement new" to allocate UnwindCursor in the cursor buffer.
|
||||
new ((void *)cursor) UnwindCursor<LocalAddressSpace, REGISTER_KIND>(
|
||||
context, LocalAddressSpace::sThisAddressSpace);
|
||||
#undef REGISTER_KIND
|
||||
AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
|
||||
co->setInfoBasedOnIPRegister();
|
||||
|
||||
|
||||
@@ -2731,7 +2731,6 @@ bool X86TargetInfo::initFeatureMap(
|
||||
setFeatureEnabledImpl(Features, "prfchw", true);
|
||||
setFeatureEnabledImpl(Features, "cx16", true);
|
||||
setFeatureEnabledImpl(Features, "fxsr", true);
|
||||
setFeatureEnabledImpl(Features, "xsave", true);
|
||||
break;
|
||||
case CK_BDVER4:
|
||||
setFeatureEnabledImpl(Features, "avx2", true);
|
||||
|
||||
@@ -7922,12 +7922,12 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
if (IsPIE)
|
||||
CmdArgs.push_back("-pie");
|
||||
|
||||
CmdArgs.push_back("--eh-frame-hdr");
|
||||
if (Args.hasArg(options::OPT_static)) {
|
||||
CmdArgs.push_back("-Bstatic");
|
||||
} else {
|
||||
if (Args.hasArg(options::OPT_rdynamic))
|
||||
CmdArgs.push_back("-export-dynamic");
|
||||
CmdArgs.push_back("--eh-frame-hdr");
|
||||
if (Args.hasArg(options::OPT_shared)) {
|
||||
CmdArgs.push_back("-Bshareable");
|
||||
} else {
|
||||
|
||||
@@ -142,30 +142,25 @@
|
||||
Support for TCP wrappers was removed in upstream 6.7p1. We've
|
||||
added it back by porting the 6.6p1 code forward.
|
||||
|
||||
6) DSA keys
|
||||
|
||||
DSA keys were disabled by default in upstream 6.9p1. We've added
|
||||
them back.
|
||||
|
||||
7) Agent client reference counting
|
||||
6) Agent client reference counting
|
||||
|
||||
We've added code to ssh-agent.c to implement client reference
|
||||
counting; the agent will automatically exit when the last client
|
||||
disconnects.
|
||||
|
||||
8) Class-based login restrictions
|
||||
7) Class-based login restrictions
|
||||
|
||||
We've added code to auth2.c to enforce the host.allow, host.deny,
|
||||
times.allow and times.deny login class capabilities.
|
||||
|
||||
9) HPN
|
||||
8) HPN
|
||||
|
||||
We no longer have the HPN patches (adaptive buffer size for
|
||||
increased throughput on high-BxD links), but we recognize and
|
||||
ignore HPN-related configuration options to avoid breaking existing
|
||||
configurations.
|
||||
|
||||
A) AES-CBC
|
||||
9) AES-CBC
|
||||
|
||||
The AES-CBC ciphers were removed from the server-side proposal list
|
||||
in 6.7p1 due to theoretical weaknesses and the availability of
|
||||
|
||||
@@ -1701,7 +1701,7 @@
|
||||
/* #undef WITH_SELINUX */
|
||||
|
||||
/* include SSH protocol version 1 support */
|
||||
#define WITH_SSH1 1
|
||||
/* #undef WITH_SSH1 */
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
|
||||
@@ -123,7 +123,7 @@ AC_CHECK_DECL([PR_SET_NO_NEW_PRIVS], [have_linux_no_new_privs=1], , [
|
||||
])
|
||||
|
||||
openssl=yes
|
||||
ssh1=yes
|
||||
ssh1=no
|
||||
AC_ARG_WITH([openssl],
|
||||
[ --without-openssl Disable use of OpenSSL; use only limited internal crypto **EXPERIMENTAL** ],
|
||||
[ if test "x$withval" = "xno" ; then
|
||||
|
||||
@@ -100,13 +100,11 @@
|
||||
HOSTKEY_ECDSA_CERT_METHODS \
|
||||
"[email protected]," \
|
||||
"[email protected]," \
|
||||
"[email protected]," \
|
||||
HOSTKEY_ECDSA_METHODS \
|
||||
"ssh-ed25519," \
|
||||
"rsa-sha2-512," \
|
||||
"rsa-sha2-256," \
|
||||
"ssh-rsa," \
|
||||
"ssh-dss"
|
||||
"ssh-rsa"
|
||||
|
||||
/* the actual algorithms */
|
||||
|
||||
|
||||
+15
-12
@@ -22,6 +22,7 @@ __RCSID("$FreeBSD$");
|
||||
#include <netinet/ip.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
@@ -206,26 +207,28 @@ fill_default_server_options(ServerOptions *options)
|
||||
/* Standard Options */
|
||||
if (options->protocol == SSH_PROTO_UNKNOWN)
|
||||
options->protocol = SSH_PROTO_2;
|
||||
if (options->protocol & SSH_PROTO_1)
|
||||
error("WARNING: SSH protocol version 1 enabled");
|
||||
#define add_host_key_file(path) \
|
||||
do { \
|
||||
if (access((path), O_RDONLY) == 0) \
|
||||
options->host_key_files \
|
||||
[options->num_host_key_files++] = (path); \
|
||||
} while (0)
|
||||
if (options->num_host_key_files == 0) {
|
||||
/* fill default hostkeys for protocols */
|
||||
if (options->protocol & SSH_PROTO_1)
|
||||
options->host_key_files[options->num_host_key_files++] =
|
||||
_PATH_HOST_KEY_FILE;
|
||||
add_host_key_file(_PATH_HOST_KEY_FILE);
|
||||
if (options->protocol & SSH_PROTO_2) {
|
||||
options->host_key_files[options->num_host_key_files++] =
|
||||
_PATH_HOST_RSA_KEY_FILE;
|
||||
options->host_key_files[options->num_host_key_files++] =
|
||||
_PATH_HOST_DSA_KEY_FILE;
|
||||
add_host_key_file(_PATH_HOST_RSA_KEY_FILE);
|
||||
add_host_key_file(_PATH_HOST_DSA_KEY_FILE);
|
||||
#ifdef OPENSSL_HAS_ECC
|
||||
options->host_key_files[options->num_host_key_files++] =
|
||||
_PATH_HOST_ECDSA_KEY_FILE;
|
||||
add_host_key_file(_PATH_HOST_ECDSA_KEY_FILE);
|
||||
#endif
|
||||
options->host_key_files[options->num_host_key_files++] =
|
||||
_PATH_HOST_ED25519_KEY_FILE;
|
||||
add_host_key_file(_PATH_HOST_ED25519_KEY_FILE);
|
||||
}
|
||||
}
|
||||
#undef add_host_key_file
|
||||
if (options->num_host_key_files == 0)
|
||||
fatal("No host key files found");
|
||||
/* No certificates by default */
|
||||
if (options->num_ports == 0)
|
||||
options->ports[options->num_ports++] = SSH_DEFAULT_PORT;
|
||||
|
||||
@@ -871,10 +871,8 @@ [email protected],
|
||||
[email protected],
|
||||
[email protected],
|
||||
[email protected],
|
||||
[email protected],
|
||||
ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,
|
||||
ecdsa-sha2-nistp521,ssh-ed25519,
|
||||
ssh-rsa,ssh-dss
|
||||
ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
|
||||
ssh-ed25519,ssh-rsa
|
||||
.Ed
|
||||
.Pp
|
||||
The
|
||||
@@ -896,10 +894,8 @@ [email protected],
|
||||
[email protected],
|
||||
[email protected],
|
||||
[email protected],
|
||||
[email protected],
|
||||
ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,
|
||||
ecdsa-sha2-nistp521,ssh-ed25519,
|
||||
ssh-rsa,ssh-dss
|
||||
ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
|
||||
ssh-ed25519,ssh-rsa
|
||||
.Ed
|
||||
.Pp
|
||||
If hostkeys are known for the destination host then this default is modified
|
||||
@@ -1336,10 +1332,8 @@ [email protected],
|
||||
[email protected],
|
||||
[email protected],
|
||||
[email protected],
|
||||
[email protected],
|
||||
ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,
|
||||
ecdsa-sha2-nistp521,ssh-ed25519,
|
||||
ssh-rsa,ssh-dss
|
||||
ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
|
||||
ssh-ed25519,ssh-rsa
|
||||
.Ed
|
||||
.Pp
|
||||
The
|
||||
|
||||
@@ -659,10 +659,8 @@ [email protected],
|
||||
[email protected],
|
||||
[email protected],
|
||||
[email protected],
|
||||
[email protected],
|
||||
ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,
|
||||
ecdsa-sha2-nistp521,ssh-ed25519,
|
||||
ssh-rsa,ssh-dss
|
||||
ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
|
||||
ssh-ed25519,ssh-rsa
|
||||
.Ed
|
||||
.Pp
|
||||
The
|
||||
@@ -753,10 +751,8 @@ [email protected],
|
||||
[email protected],
|
||||
[email protected],
|
||||
[email protected],
|
||||
[email protected],
|
||||
ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,
|
||||
ecdsa-sha2-nistp521,ssh-ed25519,
|
||||
ssh-rsa,ssh-dss
|
||||
ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
|
||||
ssh-ed25519,ssh-rsa
|
||||
.Ed
|
||||
.Pp
|
||||
The list of available key types may also be obtained using the
|
||||
@@ -1372,10 +1368,8 @@ [email protected],
|
||||
[email protected],
|
||||
[email protected],
|
||||
[email protected],
|
||||
[email protected],
|
||||
ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,
|
||||
ecdsa-sha2-nistp521,ssh-ed25519,
|
||||
ssh-rsa,ssh-dss
|
||||
ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
|
||||
ssh-ed25519,ssh-rsa
|
||||
.Ed
|
||||
.Pp
|
||||
The
|
||||
|
||||
@@ -2,6 +2,178 @@
|
||||
OpenSSL CHANGES
|
||||
_______________
|
||||
|
||||
Changes between 1.0.2i and 1.0.2j [26 Sep 2016]
|
||||
|
||||
*) Missing CRL sanity check
|
||||
|
||||
A bug fix which included a CRL sanity check was added to OpenSSL 1.1.0
|
||||
but was omitted from OpenSSL 1.0.2i. As a result any attempt to use
|
||||
CRLs in OpenSSL 1.0.2i will crash with a null pointer exception.
|
||||
|
||||
This issue only affects the OpenSSL 1.0.2i
|
||||
(CVE-2016-7052)
|
||||
[Matt Caswell]
|
||||
|
||||
Changes between 1.0.2h and 1.0.2i [22 Sep 2016]
|
||||
|
||||
*) OCSP Status Request extension unbounded memory growth
|
||||
|
||||
A malicious client can send an excessively large OCSP Status Request
|
||||
extension. If that client continually requests renegotiation, sending a
|
||||
large OCSP Status Request extension each time, then there will be unbounded
|
||||
memory growth on the server. This will eventually lead to a Denial Of
|
||||
Service attack through memory exhaustion. Servers with a default
|
||||
configuration are vulnerable even if they do not support OCSP. Builds using
|
||||
the "no-ocsp" build time option are not affected.
|
||||
|
||||
This issue was reported to OpenSSL by Shi Lei (Gear Team, Qihoo 360 Inc.)
|
||||
(CVE-2016-6304)
|
||||
[Matt Caswell]
|
||||
|
||||
*) In order to mitigate the SWEET32 attack, the DES ciphers were moved from
|
||||
HIGH to MEDIUM.
|
||||
|
||||
This issue was reported to OpenSSL Karthikeyan Bhargavan and Gaetan
|
||||
Leurent (INRIA)
|
||||
(CVE-2016-2183)
|
||||
[Rich Salz]
|
||||
|
||||
*) OOB write in MDC2_Update()
|
||||
|
||||
An overflow can occur in MDC2_Update() either if called directly or
|
||||
through the EVP_DigestUpdate() function using MDC2. If an attacker
|
||||
is able to supply very large amounts of input data after a previous
|
||||
call to EVP_EncryptUpdate() with a partial block then a length check
|
||||
can overflow resulting in a heap corruption.
|
||||
|
||||
The amount of data needed is comparable to SIZE_MAX which is impractical
|
||||
on most platforms.
|
||||
|
||||
This issue was reported to OpenSSL by Shi Lei (Gear Team, Qihoo 360 Inc.)
|
||||
(CVE-2016-6303)
|
||||
[Stephen Henson]
|
||||
|
||||
*) Malformed SHA512 ticket DoS
|
||||
|
||||
If a server uses SHA512 for TLS session ticket HMAC it is vulnerable to a
|
||||
DoS attack where a malformed ticket will result in an OOB read which will
|
||||
ultimately crash.
|
||||
|
||||
The use of SHA512 in TLS session tickets is comparatively rare as it requires
|
||||
a custom server callback and ticket lookup mechanism.
|
||||
|
||||
This issue was reported to OpenSSL by Shi Lei (Gear Team, Qihoo 360 Inc.)
|
||||
(CVE-2016-6302)
|
||||
[Stephen Henson]
|
||||
|
||||
*) OOB write in BN_bn2dec()
|
||||
|
||||
The function BN_bn2dec() does not check the return value of BN_div_word().
|
||||
This can cause an OOB write if an application uses this function with an
|
||||
overly large BIGNUM. This could be a problem if an overly large certificate
|
||||
or CRL is printed out from an untrusted source. TLS is not affected because
|
||||
record limits will reject an oversized certificate before it is parsed.
|
||||
|
||||
This issue was reported to OpenSSL by Shi Lei (Gear Team, Qihoo 360 Inc.)
|
||||
(CVE-2016-2182)
|
||||
[Stephen Henson]
|
||||
|
||||
*) OOB read in TS_OBJ_print_bio()
|
||||
|
||||
The function TS_OBJ_print_bio() misuses OBJ_obj2txt(): the return value is
|
||||
the total length the OID text representation would use and not the amount
|
||||
of data written. This will result in OOB reads when large OIDs are
|
||||
presented.
|
||||
|
||||
This issue was reported to OpenSSL by Shi Lei (Gear Team, Qihoo 360 Inc.)
|
||||
(CVE-2016-2180)
|
||||
[Stephen Henson]
|
||||
|
||||
*) Pointer arithmetic undefined behaviour
|
||||
|
||||
Avoid some undefined pointer arithmetic
|
||||
|
||||
A common idiom in the codebase is to check limits in the following manner:
|
||||
"p + len > limit"
|
||||
|
||||
Where "p" points to some malloc'd data of SIZE bytes and
|
||||
limit == p + SIZE
|
||||
|
||||
"len" here could be from some externally supplied data (e.g. from a TLS
|
||||
message).
|
||||
|
||||
The rules of C pointer arithmetic are such that "p + len" is only well
|
||||
defined where len <= SIZE. Therefore the above idiom is actually
|
||||
undefined behaviour.
|
||||
|
||||
For example this could cause problems if some malloc implementation
|
||||
provides an address for "p" such that "p + len" actually overflows for
|
||||
values of len that are too big and therefore p + len < limit.
|
||||
|
||||
This issue was reported to OpenSSL by Guido Vranken
|
||||
(CVE-2016-2177)
|
||||
[Matt Caswell]
|
||||
|
||||
*) Constant time flag not preserved in DSA signing
|
||||
|
||||
Operations in the DSA signing algorithm should run in constant time in
|
||||
order to avoid side channel attacks. A flaw in the OpenSSL DSA
|
||||
implementation means that a non-constant time codepath is followed for
|
||||
certain operations. This has been demonstrated through a cache-timing
|
||||
attack to be sufficient for an attacker to recover the private DSA key.
|
||||
|
||||
This issue was reported by César Pereida (Aalto University), Billy Brumley
|
||||
(Tampere University of Technology), and Yuval Yarom (The University of
|
||||
Adelaide and NICTA).
|
||||
(CVE-2016-2178)
|
||||
[César Pereida]
|
||||
|
||||
*) DTLS buffered message DoS
|
||||
|
||||
In a DTLS connection where handshake messages are delivered out-of-order
|
||||
those messages that OpenSSL is not yet ready to process will be buffered
|
||||
for later use. Under certain circumstances, a flaw in the logic means that
|
||||
those messages do not get removed from the buffer even though the handshake
|
||||
has been completed. An attacker could force up to approx. 15 messages to
|
||||
remain in the buffer when they are no longer required. These messages will
|
||||
be cleared when the DTLS connection is closed. The default maximum size for
|
||||
a message is 100k. Therefore the attacker could force an additional 1500k
|
||||
to be consumed per connection. By opening many simulataneous connections an
|
||||
attacker could cause a DoS attack through memory exhaustion.
|
||||
|
||||
This issue was reported to OpenSSL by Quan Luo.
|
||||
(CVE-2016-2179)
|
||||
[Matt Caswell]
|
||||
|
||||
*) DTLS replay protection DoS
|
||||
|
||||
A flaw in the DTLS replay attack protection mechanism means that records
|
||||
that arrive for future epochs update the replay protection "window" before
|
||||
the MAC for the record has been validated. This could be exploited by an
|
||||
attacker by sending a record for the next epoch (which does not have to
|
||||
decrypt or have a valid MAC), with a very large sequence number. This means
|
||||
that all subsequent legitimate packets are dropped causing a denial of
|
||||
service for a specific DTLS connection.
|
||||
|
||||
This issue was reported to OpenSSL by the OCAP audit team.
|
||||
(CVE-2016-2181)
|
||||
[Matt Caswell]
|
||||
|
||||
*) Certificate message OOB reads
|
||||
|
||||
In OpenSSL 1.0.2 and earlier some missing message length checks can result
|
||||
in OOB reads of up to 2 bytes beyond an allocated buffer. There is a
|
||||
theoretical DoS risk but this has not been observed in practice on common
|
||||
platforms.
|
||||
|
||||
The messages affected are client certificate, client certificate request
|
||||
and server certificate. As a result the attack can only be performed
|
||||
against a client or a server which enables client authentication.
|
||||
|
||||
This issue was reported to OpenSSL by Shi Lei (Gear Team, Qihoo 360 Inc.)
|
||||
(CVE-2016-6306)
|
||||
[Stephen Henson]
|
||||
|
||||
Changes between 1.0.2g and 1.0.2h [3 May 2016]
|
||||
|
||||
*) Prevent padding oracle in AES-NI CBC MAC check
|
||||
|
||||
+65
-28
@@ -1,38 +1,75 @@
|
||||
HOW TO CONTRIBUTE TO OpenSSL
|
||||
----------------------------
|
||||
HOW TO CONTRIBUTE TO PATCHES OpenSSL
|
||||
------------------------------------
|
||||
|
||||
Development is coordinated on the openssl-dev mailing list (see
|
||||
http://www.openssl.org for information on subscribing). If you
|
||||
would like to submit a patch, send it to [email protected] with
|
||||
the string "[PATCH]" in the subject. Please be sure to include a
|
||||
textual explanation of what your patch does.
|
||||
|
||||
You can also make GitHub pull requests. If you do this, please also send
|
||||
mail to [email protected] with a brief description and a link to the PR so
|
||||
that we can more easily keep track of it.
|
||||
(Please visit https://www.openssl.org/community/getting-started.html for
|
||||
other ideas about how to contribute.)
|
||||
|
||||
Development is coordinated on the openssl-dev mailing list (see the
|
||||
above link or https://mta.openssl.org for information on subscribing).
|
||||
If you are unsure as to whether a feature will be useful for the general
|
||||
OpenSSL community please discuss it on the openssl-dev mailing list first.
|
||||
Someone may be already working on the same thing or there may be a good
|
||||
reason as to why that feature isn't implemented.
|
||||
OpenSSL community you might want to discuss it on the openssl-dev mailing
|
||||
list first. Someone may be already working on the same thing or there
|
||||
may be a good reason as to why that feature isn't implemented.
|
||||
|
||||
Patches should be as up to date as possible, preferably relative to the
|
||||
current Git or the last snapshot. They should follow our coding style
|
||||
(see https://www.openssl.org/policies/codingstyle.html) and compile without
|
||||
warnings using the --strict-warnings flag. OpenSSL compiles on many varied
|
||||
platforms: try to ensure you only use portable features.
|
||||
The best way to submit a patch is to make a pull request on GitHub.
|
||||
(It is not necessary to send mail to [email protected] to open a ticket!)
|
||||
If you think the patch could use feedback from the community, please
|
||||
start a thread on openssl-dev.
|
||||
|
||||
Our preferred format for patch files is "git format-patch" output. For example
|
||||
to provide a patch file containing the last commit in your local git repository
|
||||
use the following command:
|
||||
You can also submit patches by sending it as mail to [email protected].
|
||||
Please include the word "PATCH" and an explanation of what the patch
|
||||
does in the subject line. If you do this, our preferred format is "git
|
||||
format-patch" output. For example to provide a patch file containing the
|
||||
last commit in your local git repository use the following command:
|
||||
|
||||
# git format-patch --stdout HEAD^ >mydiffs.patch
|
||||
% git format-patch --stdout HEAD^ >mydiffs.patch
|
||||
|
||||
Another method of creating an acceptable patch file without using git is as
|
||||
follows:
|
||||
|
||||
# cd openssl-work
|
||||
# [your changes]
|
||||
# ./Configure dist; make clean
|
||||
# cd ..
|
||||
# diff -ur openssl-orig openssl-work > mydiffs.patch
|
||||
% cd openssl-work
|
||||
...make your changes...
|
||||
% ./Configure dist; make clean
|
||||
% cd ..
|
||||
% diff -ur openssl-orig openssl-work >mydiffs.patch
|
||||
|
||||
Note that pull requests are generally easier for the team, and community, to
|
||||
work with. Pull requests benefit from all of the standard GitHub features,
|
||||
including code review tools, simpler integration, and CI build support.
|
||||
|
||||
No matter how a patch is submitted, the following items will help make
|
||||
the acceptance and review process faster:
|
||||
|
||||
1. Anything other than trivial contributions will require a contributor
|
||||
licensing agreement, giving us permission to use your code. See
|
||||
https://www.openssl.org/policies/cla.html for details.
|
||||
|
||||
2. All source files should start with the following text (with
|
||||
appropriate comment characters at the start of each line and the
|
||||
year(s) updated):
|
||||
|
||||
Copyright 20xx-20yy The OpenSSL Project Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the OpenSSL license (the "License"). You may not use
|
||||
this file except in compliance with the License. You can obtain a copy
|
||||
in the file LICENSE in the source distribution or at
|
||||
https://www.openssl.org/source/license.html
|
||||
|
||||
3. Patches should be as current as possible. When using GitHub, please
|
||||
expect to have to rebase and update often. Note that we do not accept merge
|
||||
commits. You will be asked to remove them before a patch is considered
|
||||
acceptable.
|
||||
|
||||
4. Patches should follow our coding style (see
|
||||
https://www.openssl.org/policies/codingstyle.html) and compile without
|
||||
warnings. Where gcc or clang is availble you should use the
|
||||
--strict-warnings Configure option. OpenSSL compiles on many varied
|
||||
platforms: try to ensure you only use portable features.
|
||||
|
||||
5. When at all possible, patches should include tests. These can either be
|
||||
added to an existing test, or completely new. Please see test/README
|
||||
for information on the test framework.
|
||||
|
||||
6. New features or changed functionality must include documentation. Please
|
||||
look at the "pod" files in doc/apps, doc/crypto and doc/ssl for examples of
|
||||
our style.
|
||||
@@ -799,7 +799,7 @@ my @experimental = ();
|
||||
|
||||
# This is what $depflags will look like with the above defaults
|
||||
# (we need this to see if we should advise the user to run "make depend"):
|
||||
my $default_depflags = " -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST";
|
||||
my $default_depflags = " -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_SSL2 -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST -DOPENSSL_NO_WEAK_SSL_CIPHERS";
|
||||
|
||||
# Explicit "no-..." options will be collected in %disabled along with the defaults.
|
||||
# To remove something from %disabled, use "enable-foo" (unless it's experimental).
|
||||
@@ -1082,11 +1082,6 @@ if (defined($disabled{"md5"}) || defined($disabled{"sha"})
|
||||
$disabled{"tls1"} = "forced";
|
||||
}
|
||||
|
||||
if (defined($disabled{"tls1"}))
|
||||
{
|
||||
$disabled{"tlsext"} = "forced";
|
||||
}
|
||||
|
||||
if (defined($disabled{"ec"}) || defined($disabled{"dsa"})
|
||||
|| defined($disabled{"dh"}))
|
||||
{
|
||||
@@ -1254,6 +1249,7 @@ my $shared_extension = $fields[$idx_shared_extension];
|
||||
my $ranlib = $ENV{'RANLIB'} || $fields[$idx_ranlib];
|
||||
my $ar = $ENV{'AR'} || "ar";
|
||||
my $arflags = $fields[$idx_arflags];
|
||||
my $windres = $ENV{'RC'} || $ENV{'WINDRES'} || "windres";
|
||||
my $multilib = $fields[$idx_multilib];
|
||||
|
||||
# if $prefix/lib$multilib is not an existing directory, then
|
||||
@@ -1562,8 +1558,15 @@ $cpuid_obj="mem_clr.o" unless ($cpuid_obj =~ /\.o$/);
|
||||
$des_obj=$des_enc unless ($des_obj =~ /\.o$/);
|
||||
$bf_obj=$bf_enc unless ($bf_obj =~ /\.o$/);
|
||||
$cast_obj=$cast_enc unless ($cast_obj =~ /\.o$/);
|
||||
$rc4_obj=$rc4_enc unless ($rc4_obj =~ /\.o$/);
|
||||
$rc5_obj=$rc5_enc unless ($rc5_obj =~ /\.o$/);
|
||||
if ($rc4_obj =~ /\.o$/)
|
||||
{
|
||||
$cflags.=" -DRC4_ASM";
|
||||
}
|
||||
else
|
||||
{
|
||||
$rc4_obj=$rc4_enc;
|
||||
}
|
||||
if ($sha1_obj =~ /\.o$/)
|
||||
{
|
||||
# $sha1_obj=$sha1_enc;
|
||||
@@ -1717,12 +1720,14 @@ while (<IN>)
|
||||
s/^AR=\s*/AR= \$\(CROSS_COMPILE\)/;
|
||||
s/^NM=\s*/NM= \$\(CROSS_COMPILE\)/;
|
||||
s/^RANLIB=\s*/RANLIB= \$\(CROSS_COMPILE\)/;
|
||||
s/^RC=\s*/RC= \$\(CROSS_COMPILE\)/;
|
||||
s/^MAKEDEPPROG=.*$/MAKEDEPPROG= \$\(CROSS_COMPILE\)$cc/ if $cc eq "gcc";
|
||||
}
|
||||
else {
|
||||
s/^CC=.*$/CC= $cc/;
|
||||
s/^AR=\s*ar/AR= $ar/;
|
||||
s/^RANLIB=.*/RANLIB= $ranlib/;
|
||||
s/^RC=.*/RC= $windres/;
|
||||
s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $cc eq "gcc";
|
||||
s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $ecc eq "gcc" || $ecc eq "clang";
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
## Makefile for OpenSSL
|
||||
##
|
||||
|
||||
VERSION=1.0.2h
|
||||
VERSION=1.0.2j
|
||||
MAJOR=1
|
||||
MINOR=0.2
|
||||
SHLIB_VERSION_NUMBER=1.0.0
|
||||
@@ -68,6 +68,7 @@ EXE_EXT=
|
||||
ARFLAGS=
|
||||
AR= ar $(ARFLAGS) r
|
||||
RANLIB= /usr/bin/ranlib
|
||||
RC= windres
|
||||
NM= nm
|
||||
PERL= /usr/bin/perl
|
||||
TAR= tar
|
||||
@@ -210,6 +211,7 @@ BUILDENV= LC_ALL=C PLATFORM='$(PLATFORM)' PROCESSOR='$(PROCESSOR)'\
|
||||
CC='$(CC)' CFLAG='$(CFLAG)' \
|
||||
AS='$(CC)' ASFLAG='$(CFLAG) -c' \
|
||||
AR='$(AR)' NM='$(NM)' RANLIB='$(RANLIB)' \
|
||||
RC='$(RC)' \
|
||||
CROSS_COMPILE='$(CROSS_COMPILE)' \
|
||||
PERL='$(PERL)' ENGDIRS='$(ENGDIRS)' \
|
||||
SDIRS='$(SDIRS)' LIBRPATH='$(INSTALLTOP)/$(LIBDIR)' \
|
||||
@@ -368,6 +370,7 @@ libcrypto.pc: Makefile
|
||||
echo 'exec_prefix=$${prefix}'; \
|
||||
echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
|
||||
echo 'includedir=$${prefix}/include'; \
|
||||
echo 'enginesdir=$${libdir}/engines'; \
|
||||
echo ''; \
|
||||
echo 'Name: OpenSSL-libcrypto'; \
|
||||
echo 'Description: OpenSSL cryptography library'; \
|
||||
|
||||
@@ -66,6 +66,7 @@ EXE_EXT=
|
||||
ARFLAGS?= r
|
||||
AR=ar $(ARFLAGS)
|
||||
RANLIB= ranlib
|
||||
RC= windres
|
||||
NM= nm
|
||||
PERL= perl
|
||||
TAR= tar
|
||||
@@ -208,6 +209,7 @@ BUILDENV= LC_ALL=C PLATFORM='$(PLATFORM)' PROCESSOR='$(PROCESSOR)'\
|
||||
CC='$(CC)' CFLAG='$(CFLAG)' \
|
||||
AS='$(CC)' ASFLAG='$(CFLAG) -c' \
|
||||
AR='$(AR)' NM='$(NM)' RANLIB='$(RANLIB)' \
|
||||
RC='$(RC)' \
|
||||
CROSS_COMPILE='$(CROSS_COMPILE)' \
|
||||
PERL='$(PERL)' ENGDIRS='$(ENGDIRS)' \
|
||||
SDIRS='$(SDIRS)' LIBRPATH='$(INSTALLTOP)/$(LIBDIR)' \
|
||||
@@ -366,6 +368,7 @@ libcrypto.pc: Makefile
|
||||
echo 'exec_prefix=$${prefix}'; \
|
||||
echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
|
||||
echo 'includedir=$${prefix}/include'; \
|
||||
echo 'enginesdir=$${libdir}/engines'; \
|
||||
echo ''; \
|
||||
echo 'Name: OpenSSL-libcrypto'; \
|
||||
echo 'Description: OpenSSL cryptography library'; \
|
||||
|
||||
@@ -293,7 +293,7 @@ link_a.cygwin:
|
||||
fi; \
|
||||
dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
|
||||
$(PERL) util/mkrc.pl $$dll_name | \
|
||||
$(CROSS_COMPILE)windres -o rc.o; \
|
||||
$(RC) -o rc.o; \
|
||||
extras="$$extras rc.o"; \
|
||||
ALLSYMSFLAGS='-Wl,--whole-archive'; \
|
||||
NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
|
||||
|
||||
@@ -5,6 +5,24 @@
|
||||
This file gives a brief overview of the major changes between each OpenSSL
|
||||
release. For more details please read the CHANGES file.
|
||||
|
||||
Major changes between OpenSSL 1.0.2i and OpenSSL 1.0.2j [26 Sep 2016]
|
||||
|
||||
o Fix Use After Free for large message sizes (CVE-2016-6309)
|
||||
|
||||
Major changes between OpenSSL 1.0.2h and OpenSSL 1.0.2i [22 Sep 2016]
|
||||
|
||||
o OCSP Status Request extension unbounded memory growth (CVE-2016-6304)
|
||||
o SWEET32 Mitigation (CVE-2016-2183)
|
||||
o OOB write in MDC2_Update() (CVE-2016-6303)
|
||||
o Malformed SHA512 ticket DoS (CVE-2016-6302)
|
||||
o OOB write in BN_bn2dec() (CVE-2016-2182)
|
||||
o OOB read in TS_OBJ_print_bio() (CVE-2016-2180)
|
||||
o Pointer arithmetic undefined behaviour (CVE-2016-2177)
|
||||
o Constant time flag not preserved in DSA signing (CVE-2016-2178)
|
||||
o DTLS buffered message DoS (CVE-2016-2179)
|
||||
o DTLS replay protection DoS (CVE-2016-2181)
|
||||
o Certificate message OOB reads (CVE-2016-6306)
|
||||
|
||||
Major changes between OpenSSL 1.0.2g and OpenSSL 1.0.2h [3 May 2016]
|
||||
|
||||
o Prevent padding oracle in AES-NI CBC MAC check (CVE-2016-2107)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
OpenSSL 1.0.2h 3 May 2016
|
||||
OpenSSL 1.0.2j 26 Sep 2016
|
||||
|
||||
Copyright (c) 1998-2015 The OpenSSL Project
|
||||
Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
|
||||
|
||||
@@ -64,7 +64,7 @@ $RET = 0;
|
||||
|
||||
foreach (@ARGV) {
|
||||
if ( /^(-\?|-h|-help)$/ ) {
|
||||
print STDERR "usage: CA -newcert|-newreq|-newreq-nodes|-newca|-sign|-verify\n";
|
||||
print STDERR "usage: CA -newcert|-newreq|-newreq-nodes|-newca|-sign|-signcert|-verify\n";
|
||||
exit 0;
|
||||
} elsif (/^-newcert$/) {
|
||||
# create a certificate
|
||||
@@ -186,4 +186,3 @@ while (<IN>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ $RET = 0;
|
||||
|
||||
foreach (@ARGV) {
|
||||
if ( /^(-\?|-h|-help)$/ ) {
|
||||
print STDERR "usage: CA -newcert|-newreq|-newreq-nodes|-newca|-sign|-verify\n";
|
||||
print STDERR "usage: CA -newcert|-newreq|-newreq-nodes|-newca|-sign|-signcert|-verify\n";
|
||||
exit 0;
|
||||
} elsif (/^-newcert$/) {
|
||||
# create a certificate
|
||||
@@ -186,4 +186,3 @@ while (<IN>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +215,8 @@ int args_from_file(char *file, int *argc, char **argv[])
|
||||
if (arg != NULL)
|
||||
OPENSSL_free(arg);
|
||||
arg = (char **)OPENSSL_malloc(sizeof(char *) * (i * 2));
|
||||
|
||||
if (arg == NULL)
|
||||
return 0;
|
||||
*argv = arg;
|
||||
num = 0;
|
||||
p = buf;
|
||||
@@ -2374,6 +2375,8 @@ int args_verify(char ***pargs, int *pargc,
|
||||
flags |= X509_V_FLAG_PARTIAL_CHAIN;
|
||||
else if (!strcmp(arg, "-no_alt_chains"))
|
||||
flags |= X509_V_FLAG_NO_ALT_CHAINS;
|
||||
else if (!strcmp(arg, "-allow_proxy_certs"))
|
||||
flags |= X509_V_FLAG_ALLOW_PROXY_CERTS;
|
||||
else
|
||||
return 0;
|
||||
|
||||
@@ -3195,6 +3198,36 @@ int app_isdir(const char *name)
|
||||
#endif
|
||||
|
||||
/* raw_read|write section */
|
||||
#if defined(__VMS)
|
||||
# include "vms_term_sock.h"
|
||||
static int stdin_sock = -1;
|
||||
|
||||
static void close_stdin_sock(void)
|
||||
{
|
||||
TerminalSocket (TERM_SOCK_DELETE, &stdin_sock);
|
||||
}
|
||||
|
||||
int fileno_stdin(void)
|
||||
{
|
||||
if (stdin_sock == -1) {
|
||||
TerminalSocket(TERM_SOCK_CREATE, &stdin_sock);
|
||||
atexit(close_stdin_sock);
|
||||
}
|
||||
|
||||
return stdin_sock;
|
||||
}
|
||||
#else
|
||||
int fileno_stdin(void)
|
||||
{
|
||||
return fileno(stdin);
|
||||
}
|
||||
#endif
|
||||
|
||||
int fileno_stdout(void)
|
||||
{
|
||||
return fileno(stdout);
|
||||
}
|
||||
|
||||
#if defined(_WIN32) && defined(STD_INPUT_HANDLE)
|
||||
int raw_read_stdin(void *buf, int siz)
|
||||
{
|
||||
@@ -3204,10 +3237,17 @@ int raw_read_stdin(void *buf, int siz)
|
||||
else
|
||||
return (-1);
|
||||
}
|
||||
#elif defined(__VMS)
|
||||
#include <sys/socket.h>
|
||||
|
||||
int raw_read_stdin(void *buf, int siz)
|
||||
{
|
||||
return recv(fileno_stdin(), buf, siz, 0);
|
||||
}
|
||||
#else
|
||||
int raw_read_stdin(void *buf, int siz)
|
||||
{
|
||||
return read(fileno(stdin), buf, siz);
|
||||
return read(fileno_stdin(), buf, siz);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3223,6 +3263,6 @@ int raw_write_stdout(const void *buf, int siz)
|
||||
#else
|
||||
int raw_write_stdout(const void *buf, int siz)
|
||||
{
|
||||
return write(fileno(stdout), buf, siz);
|
||||
return write(fileno_stdout(), buf, siz);
|
||||
}
|
||||
#endif
|
||||
@@ -375,6 +375,8 @@ void store_setup_crl_download(X509_STORE *st);
|
||||
# define SERIAL_RAND_BITS 64
|
||||
|
||||
int app_isdir(const char *);
|
||||
int fileno_stdin(void);
|
||||
int fileno_stdout(void);
|
||||
int raw_read_stdin(void *, int);
|
||||
int raw_write_stdout(const void *, int);
|
||||
|
||||
|
||||
+11
-12
@@ -2103,25 +2103,23 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
|
||||
goto err;
|
||||
|
||||
/* We now just add it to the database */
|
||||
row[DB_type] = (char *)OPENSSL_malloc(2);
|
||||
|
||||
tm = X509_get_notAfter(ret);
|
||||
row[DB_exp_date] = (char *)OPENSSL_malloc(tm->length + 1);
|
||||
memcpy(row[DB_exp_date], tm->data, tm->length);
|
||||
row[DB_exp_date][tm->length] = '\0';
|
||||
|
||||
row[DB_rev_date] = NULL;
|
||||
|
||||
/* row[DB_serial] done already */
|
||||
row[DB_file] = (char *)OPENSSL_malloc(8);
|
||||
row[DB_type] = OPENSSL_malloc(2);
|
||||
row[DB_exp_date] = OPENSSL_malloc(tm->length + 1);
|
||||
row[DB_rev_date] = OPENSSL_malloc(1);
|
||||
row[DB_file] = OPENSSL_malloc(8);
|
||||
row[DB_name] = X509_NAME_oneline(X509_get_subject_name(ret), NULL, 0);
|
||||
|
||||
if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) ||
|
||||
(row[DB_rev_date] == NULL) ||
|
||||
(row[DB_file] == NULL) || (row[DB_name] == NULL)) {
|
||||
BIO_printf(bio_err, "Memory allocation failure\n");
|
||||
goto err;
|
||||
}
|
||||
BUF_strlcpy(row[DB_file], "unknown", 8);
|
||||
|
||||
memcpy(row[DB_exp_date], tm->data, tm->length);
|
||||
row[DB_exp_date][tm->length] = '\0';
|
||||
row[DB_rev_date][0] = '\0';
|
||||
strcpy(row[DB_file], "unknown");
|
||||
row[DB_type][0] = 'V';
|
||||
row[DB_type][1] = '\0';
|
||||
|
||||
@@ -2307,6 +2305,7 @@ static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey,
|
||||
|
||||
j = NETSCAPE_SPKI_verify(spki, pktmp);
|
||||
if (j <= 0) {
|
||||
EVP_PKEY_free(pktmp);
|
||||
BIO_printf(bio_err,
|
||||
"signature verification failed on SPKAC public key\n");
|
||||
goto err;
|
||||
|
||||
@@ -243,6 +243,11 @@ int MAIN(int argc, char **argv)
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (keyfile != NULL && argc > 1) {
|
||||
BIO_printf(bio_err, "Can only sign or verify one file\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (do_verify && !sigfile) {
|
||||
BIO_printf(bio_err,
|
||||
"No signature to verify: use the -signature option\n");
|
||||
|
||||
@@ -509,7 +509,7 @@ int MAIN(int argc, char **argv)
|
||||
BIO_printf(bio_err, "invalid hex salt value\n");
|
||||
goto end;
|
||||
}
|
||||
} else if (RAND_pseudo_bytes(salt, sizeof salt) < 0)
|
||||
} else if (RAND_bytes(salt, sizeof salt) <= 0)
|
||||
goto end;
|
||||
/*
|
||||
* If -P option then don't bother writing
|
||||
|
||||
@@ -416,7 +416,7 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
|
||||
if (*salt_malloc_p == NULL)
|
||||
goto err;
|
||||
}
|
||||
if (RAND_pseudo_bytes((unsigned char *)*salt_p, 2) < 0)
|
||||
if (RAND_bytes((unsigned char *)*salt_p, 2) <= 0)
|
||||
goto err;
|
||||
(*salt_p)[0] = cov_2char[(*salt_p)[0] & 0x3f]; /* 6 bits */
|
||||
(*salt_p)[1] = cov_2char[(*salt_p)[1] & 0x3f]; /* 6 bits */
|
||||
@@ -437,7 +437,7 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
|
||||
if (*salt_malloc_p == NULL)
|
||||
goto err;
|
||||
}
|
||||
if (RAND_pseudo_bytes((unsigned char *)*salt_p, 8) < 0)
|
||||
if (RAND_bytes((unsigned char *)*salt_p, 8) <= 0)
|
||||
goto err;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
|
||||
Loaded 100 of 1259 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user