Compare commits

..
Author SHA1 Message Date
Glen Barber f2877ac4fb release: update to -RELEASE
- Switch releng/12.4 from RC2 to RELEASE.
 - Add the anticipated 12.4-RELEASE date to UPDATING.
 - Set a static __FreeBSD_version.

Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-11-29 19:02:48 -05:00
Gordon Tetlow 4e1a2eb30b Add UPDATING entries and bump version.
Approved by:	so, re (implicit)
2022-11-29 15:17:48 -08:00
Cy Schubert 4ff214b2f2 heimdal: Fix: Too large time skew, client time 1970-01-01T01:00:00
Part of ed549cb0c5 zeroed out a data structure in the resulting code-file
when a TUTCTime type was freed. This part of the patch applies to Heimdal
7.1+ and not our Heimdal 1.5.2.

PR:		267827
Reported by:	Peter Much <[email protected]>
Tested by:	Peter Much <[email protected]>
Approved by:	so, re (implicit)
Security:	FreeBSD-EN-22:28.heimdal
Fixes:		ed549cb0c5

(cherry picked from commit f556a05c49)
(cherry picked from commit 5afe36c8b7)
2022-11-29 15:17:39 -08:00
Tom Jones 1d66ec7d51 ping: Fix handling of IP packet sizes
Ping reads raw IP packets to parse ICMP responses. When reading the
IP Header Len (IHL) ping was was taking the value from the provided
packet without any validation. This could lead to remotely triggerable
stack corruption.

Validate the IHL against expected and recieved data sizes when reading
from the received packet and when reading any quoted packets from within
the ICMP response.

Approved by:	so, re (implicit)
Reviewed by:	markj, asomers
Security:	FreeBSD-SA-22:15.ping
Security:	CVE-2022-23093
Sponsored by:   NetApp, Inc.
Sponsored by:   Klara, Inc.
X-NetApp-PR:    #77
Differential Revision: https://reviews.freebsd.org/D37195

(cherry picked from commit 46d7b45a26)
(cherry picked from commit 94395be05c)
2022-11-29 15:17:20 -08:00
Ed Maste 84c657e5e1 Add UPDATING entries and bump version
Approved by:	so, re (implicit)
2022-11-15 20:46:31 -05:00
Cy Schubert 1d5a25432b heimdal: Fix multiple security vulnerabilities
The following issues are patched:

 - CVE-2022-42898 PAC parse integer overflows
 - CVE-2022-3437 Overflows and non-constant time leaks in DES{,3} and arcfour
 - CVE-2021-44758 NULL dereference DoS in SPNEGO acceptors
 - CVE-2022-44640 Heimdal KDC: invalid free in ASN.1 codec

    Note that CVE-2022-44640 is a severe vulnerability, possibly a 10.0
    on the Common Vulnerability Scoring System (CVSS) v3, as we believe
    it should be possible to get an RCE on a KDC, which means that
    credentials can be compromised that can be used to impersonate
    anyone in a realm or forest of realms.

    Heimdal's ASN.1 compiler generates code that allows specially
    crafted DER encodings of CHOICEs to invoke the wrong free function
    on the decoded structure upon decode error.  This is known to impact
    the Heimdal KDC, leading to an invalid free() of an address partly
    or wholly under the control of the attacker, in turn leading to a
    potential remote code execution (RCE) vulnerability.

    This error affects the DER codec for all extensible CHOICE types
    used in Heimdal, though not all cases will be exploitable.  We have
    not completed a thorough analysis of all the Heimdal components
    affected, thus the Kerberos client, the X.509 library, and other
    parts, may be affected as well.

    This bug has been in Heimdal's ASN.1 compiler since 2005, but it may
    only affect Heimdal 1.6 and up.  It was first reported by Douglas
    Bagnall, though it had been found independently by the Heimdal
    maintainers via fuzzing a few weeks earlier.

    While no zero-day exploit is known, such an exploit will likely be
    available soon after public disclosure.

 - CVE-2019-14870: Validate client attributes in protocol-transition
 - CVE-2019-14870: Apply forwardable policy in protocol-transition
 - CVE-2019-14870: Always lookup impersonate client in DB

Sponsored by:	so (philip)
Obtained from:	so (philip)
Tested by:	philip, cy

(cherry picked from commit ed549cb0c5)
(cherry picked from commit f8a825bde7)

Approved by:	so, re (implicit)
Security:	FreeBSD-SA-22:14.heimdal
2022-11-15 20:46:20 -05:00
Glen Barber 7b05f19e97 release: fix on-disc pkg binary symbolic links
Note: As this change was tested during the 13.1 cycle, but never
merged back to stable/12, this change does not warrant an RC3.

Approved by:	re (cperciva)
PR:		263574
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 68b0a79b7c)
(cherry picked from commit f398c2d832)
2022-11-15 14:21:49 -05:00
Glen Barber 87ce501fcd release: use release_4 for the remainder of the 12.4 cycle
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-11-11 13:14:27 -05:00
Glen Barber a2c8e84554 release: update to RC2
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-11-10 19:05:48 -05:00
Richard Scheffenegger 86bdbdece4 ipfw: Have NAT steal the TH_RES1 bit, instead of the TH_AE bit
The NAT module use of the tcphdr.th_x2 field now collides with the
use of this TCP header flag as AccECN (AE) bit. Use the topmost
bit instead to allow negotiation of AccECN across a NAT device.

Event:			IETF 115 Hackathon
Reviewed By:		#transport, tuexen
MFC after:		3 days
Approved by:		re (gjb)
Sponsored by:		NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D37300

(cherry picked from commit 0b00b80149)
(cherry picked from commit 9839a5ad3a)
2022-11-10 16:01:21 +01:00
Ed Maste 495850ff5a ssh: correct parse_cert_times case for hex "to" time
This appeared to be a copy-paste error from the "from" time case above.

Reported by:	Coverity Scan
CID:		1500407
Reviewed by:	markj
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37252

(cherry picked from commit 0657b2325d)
(cherry picked from commit 4718d86b3b)
(cherry picked from commit a841c0c240)

Approved by:	re (gjb)
2022-11-06 09:21:36 -05:00
Piotr Kubaj 369e3367d6 ofed: allow using IPv6 address in rc_pingpong server
Summary:
The current OFED code allows binding server to IPv6 address. It was added back in https://github.com/linux-rdma/rdma-core/commit/91fc39561d04903cd5b1665d9215a184baa66ba9

Sponsored by:	Intel Corporation
MFC after:	3 days

Reviewers: hselasky

Subscribers: imp

Differential Revision: https://reviews.freebsd.org/D37196
Approved by:	re (gjb)

(cherry picked from commit 35c87c070a)
(cherry picked from commit a8c06a9de0)
(cherry picked from commit a43afddd43)
2022-11-04 16:57:11 +01:00
Zhenlei Huang a9c3d5de9a if_vxlan(4): Check the size of data available in mbuf before using them
PR:		261711
Reviewed by:	kp
Tested by:	Alfa (burak.sn at outlook.com)
Approved by:    re (gjb), kp (mentor)
Differential Revision:	https://reviews.freebsd.org/D36794

(cherry picked from commit 8707cb19e6)
(cherry picked from commit 639aebb2aa)
2022-11-04 13:21:45 +01:00
Glen Barber 3cef626d8e 12.4: update to RC1
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-11-03 20:06:17 -04:00
Dag-Erling Smørgrav 73ab1c87c2 sh: read more profile files.
Differential Revision: https://reviews.freebsd.org/D36505
MFC after:	1 month

(cherry picked from commit 497cdf9673)

sh: when loading profile, skip obvious scratch files.

Differential Revision: https://reviews.freebsd.org/D36856

(cherry picked from commit d3890a547d)

sh: when loading profile, read only .sh files.

Reviewers: jilles, eugen_grosbein.net, cy

Subscribers: imp

Differential Revision: https://reviews.freebsd.org/D37034

(cherry picked from commit 8d7221ca2d)
(cherry picked from commit 4ea49af3af)

Approved by:	re (gjb)
2022-11-02 15:51:05 +00:00
Philip Paeps df5c24d590 contrib/tzdata: import tzdata 2022f
Changes: https://github.com/eggert/tz/blob/2022f/NEWS

Approved by:	re (gjb)

(cherry picked from commit 9142a2a37b)
(cherry picked from commit 6f2acba996)
2022-11-01 17:00:36 -04:00
Kirk McKusick 0f58c5454c Add a description of soft updates journaling to newfs(8).
Requested by: Graham Perrin
PR:           261944
Approved by:  re (gjb)
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 0929a153fc)
(cherry picked from commit 759ee86540)
2022-10-31 17:11:22 -07:00
Kirk McKusick aff7cd295f Update date in tunefs(8) manual page.
PR:           261944
Approved by:  re (gjb)
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 128b0398a1)
(cherry picked from commit 1639fa2cd5)
2022-10-31 17:04:18 -07:00
Kirk McKusick a1017358b3 Add a description of soft updates journaling to tunefs(8).
Requested by: Graham Perrin
PR:           261944
Approved by:  re (gjb)
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 82493ff700)
(cherry picked from commit de1f80e4c1)
2022-10-31 17:01:40 -07:00
Ed Maste 990aa6476e OpenBSM: fix free() in au_read_rec error case
buf is a char ** and *buf is the allocated buffer.

PR:		267050
Reported by:	Robert Morris <[email protected]>
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c61b3f7de9)
(cherry picked from commit 889dcb5e9b)
(cherry picked from commit 2b25564af6)

Approved by:	re (gjb)
2022-10-31 13:16:28 -04:00
Ed Maste 1ccfac2381 sendmail: fix auth with cyrus-sasl-2.1.28
Apply patch extracted from sendmail-8-17.1.9 snapshot by dinoex@.

PR:		262935
Reviewed by:	gshapiro
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37119

(cherry picked from commit c898b54aff)
(cherry picked from commit 2123b467b4)
(cherry picked from commit 7dfe3b0981)

Approved by:	re (gjb)
2022-10-31 13:16:20 -04:00
Ed Maste 50cb877af1 ssh: update to OpenSSH 9.1p1
Release notes are available at https://www.openssh.com/txt/release-9.1

9.1 contains fixes for three minor memory safety problems; these have
lready been merged to the copy of OpenSSH 9.0 that is in the FreeBSD base
system.

Some highlights copied from the release notes:

Potentially-incompatible changes
--------------------------------

 * ssh(1), sshd(8): SetEnv directives in ssh_config and sshd_config
   are now first-match-wins to match other directives. Previously
   if an environment variable was multiply specified the last set
   value would have been used. bz3438

 * ssh-keygen(8): ssh-keygen -A (generate all default host key types)
   will no longer generate DSA keys, as these are insecure and have
   not been used by default for some years.

New features
------------

 * ssh(1), sshd(8): add a RequiredRSASize directive to set a minimum
   RSA key length. Keys below this length will be ignored for user
   authentication and for host authentication in sshd(8).

 * sftp-server(8): add a "[email protected]" extension
   request that allows the client to obtain user/group names that
   correspond to a set of uids/gids.

 * sftp(1): use "[email protected]" sftp-server
   extension (when available) to fill in user/group names for
   directory listings.

 * sftp-server(8): support the "home-directory" extension request
   defined in draft-ietf-secsh-filexfer-extensions-00. This overlaps
   a bit with the existing "[email protected]", but some other
   clients support it.

 * ssh-keygen(1), sshd(8): allow certificate validity intervals,
   sshsig verification times and authorized_keys expiry-time options
   to accept dates in the UTC time zone in addition to the default
   of interpreting them in the system time zone. YYYYMMDD and
   YYMMDDHHMM[SS] dates/times will be interpreted as UTC if suffixed
   with a 'Z' character.

   Also allow certificate validity intervals to be specified in raw
   seconds-since-epoch as hex value, e.g. -V 0x1234:0x4567890. This
   is intended for use by regress tests and other tools that call
   ssh-keygen as part of a CA workflow. bz3468

 * sftp(1): allow arguments to the sftp -D option, e.g. sftp -D
   "/usr/libexec/sftp-server -el debug3"

 * ssh-keygen(1): allow the existing -U (use agent) flag to work
   with "-Y sign" operations, where it will be interpreted to require
   that the private keys is hosted in an agent; bz3429

MFC after:	2 weeks
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 38a52bd3b5)
(cherry picked from commit ac5c465b9fdff74d1a73f63d157820887ff1787f)
(cherry picked from commit 4aee71578a)

Approved by:	re (gjb)
2022-10-31 13:15:47 -04:00
Xin LI 28f11883e8 MFV: Restore the ability to process files from stdin immediately.
PR:		bin/267221
Approved by:	re (gjb)
(cherry picked from commit 07dfb236c8)
(cherry picked from commit 97a6bb4a3f)
2022-10-30 12:43:13 -07:00
Warner Losh 6df8e6aef5 UPDATING: We're on releng 12.4
Note the branch date and that we're on releng/12.4 now at the top.

Approved by:		re@ (gjb implicit)
Sponsored by:		Netflix
2022-10-20 20:27:07 -06:00
Glen Barber fce871fe35 12.4: create releng/12.4 branch
Update from PRERELEASE to BETA1
Switch pkg(8) configuration to use 'quarterly'
Bump __FreeBSD_version

Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-10-20 13:49:59 -04:00
3397 changed files with 119071 additions and 180325 deletions

No files matched your search

-15
View File
@@ -38,21 +38,6 @@
# xargs -n1 | sort | uniq -d;
# done
# 20230909: caroot bundle updated
OLD_FILES+=usr/share/certs/trusted/E-Tugra_Certification_Authority.pem
OLD_FILES+=usr/share/certs/trusted/E-Tugra_Global_Root_CA_ECC_v3.pem
OLD_FILES+=usr/share/certs/trusted/E-Tugra_Global_Root_CA_RSA_v3.pem
OLD_FILES+=usr/share/certs/trusted/Hongkong_Post_Root_CA_1.pem
OLD_FILES+=usr/share/certs/trusted/Cybertrust_Global_Root.pem
OLD_FILES+=usr/share/certs/trusted/DST_Root_CA_X3.pem
OLD_FILES+=usr/share/certs/trusted/GlobalSign_Root_CA_-_R2.pem
OLD_FILES+=usr/share/certs/trusted/Hellenic_Academic_and_Research_Institutions_RootCA_2011.pem
OLD_FILES+=usr/share/certs/trusted/Network_Solutions_Certificate_Authority.pem
OLD_FILES+=usr/share/certs/trusted/Staat_der_Nederlanden_EV_Root_CA.pem
OLD_FILES+=usr/share/certs/trusted/TrustCor_ECA-1.pem
OLD_FILES+=usr/share/certs/trusted/TrustCor_RootCert_CA-1.pem
OLD_FILES+=usr/share/certs/trusted/TrustCor_RootCert_CA-2.pem
# 20220410: zlib 1.0.4 removed from kernel
OLD_FILES+=/usr/include/sys/zlib.h
OLD_FILES+=/usr/include/sys/zutil.h
+81
View File
@@ -0,0 +1,81 @@
This is the top level of the FreeBSD source directory. This file
was last revised on:
$FreeBSD$
FreeBSD is an operating system used to power modern servers,
desktops, and embedded platforms. A large community has
continually developed it for more than thirty years. Its
advanced networking, security, and storage features have
made FreeBSD the platform of choice for many of the
busiest web sites and most pervasive embedded networking
and storage devices.
For copyright information, please see the file COPYRIGHT in this
directory. Additional copyright information also exists for some
sources in this tree - please see the specific source directories for
more information.
The Makefile in this directory supports a number of targets for
building components (or all) of the FreeBSD source tree. See build(7), config(8),
https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html, and
https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html
for more information, including setting make(1) variables.
Source Roadmap:
---------------
bin System/user commands.
cddl Various commands and libraries under the Common Development
and Distribution License.
contrib Packages contributed by 3rd parties.
crypto Cryptography stuff (see crypto/README).
etc Template files for /etc.
gnu Commands and libraries under the GNU General Public License
(GPL) or Lesser General Public License (LGPL). Please see
gnu/COPYING* for more information.
include System include files.
kerberos5 Kerberos5 (Heimdal) package.
lib System libraries.
libexec System daemons.
release Release building Makefile & associated tools.
rescue Build system for statically linked /rescue utilities.
sbin System commands.
secure Cryptographic libraries and commands.
share Shared resources.
stand Boot loader sources.
sys Kernel sources.
sys/<arch>/conf Kernel configuration files. GENERIC is the configuration
used in release builds. NOTES contains documentation of
all possible entries.
tests Regression tests which can be run by Kyua. See tests/README
for additional information.
tools Utilities for regression testing and miscellaneous tasks.
usr.bin User commands.
usr.sbin System administration commands.
For information on synchronizing your source tree with one or more of
the FreeBSD Project's development branches, please see:
https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/current-stable.html
+74 -33
View File
@@ -1,42 +1,83 @@
FreeBSD Source:
---------------
This is the top level of the FreeBSD source directory.
This is the top level of the FreeBSD source directory. This file
was last revised on:
$FreeBSD$
FreeBSD is an operating system used to power modern servers, desktops, and embedded platforms.
A large community has continually developed it for more than thirty years.
Its advanced networking, security, and storage features have made FreeBSD the platform of choice for many of the busiest web sites and most pervasive embedded networking and storage devices.
FreeBSD is an operating system used to power modern servers,
desktops, and embedded platforms. A large community has
continually developed it for more than thirty years. Its
advanced networking, security, and storage features have
made FreeBSD the platform of choice for many of the
busiest web sites and most pervasive embedded networking
and storage devices.
For copyright information, please see [the file COPYRIGHT](COPYRIGHT) in this directory.
Additional copyright information also exists for some sources in this tree - please see the specific source directories for more information.
For copyright information, please see the file COPYRIGHT in this
directory. Additional copyright information also exists for some
sources in this tree - please see the specific source directories for
more information.
The Makefile in this directory supports a number of targets for building components (or all) of the FreeBSD source tree.
See build(7), config(8), [FreeBSD handbook on building userland](https://docs.freebsd.org/en/books/handbook/cutting-edge/#makeworld), and [Handbook for kernels](https://docs.freebsd.org/en/books/handbook/kernelconfig/) for more information, including setting make(1) variables.
The Makefile in this directory supports a number of targets for
building components (or all) of the FreeBSD source tree. See build(7), config(8),
https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html, and
https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html
for more information, including setting make(1) variables.
Source Roadmap:
---------------
| Directory | Description |
| --------- | ----------- |
| bin | System/user commands. |
| cddl | Various commands and libraries under the Common Development and Distribution License. |
| contrib | Packages contributed by 3rd parties. |
| crypto | Cryptography stuff (see [crypto/README](crypto/README)). |
| etc | Template files for /etc. |
| gnu | Commands and libraries under the GNU General Public License (GPL) or Lesser General Public License (LGPL). Please see [gnu/COPYING](gnu/COPYING) and [gnu/COPYING.LIB](gnu/COPYING.LIB) for more information. |
| include | System include files. |
| kerberos5 | Kerberos5 (Heimdal) package. |
| lib | System libraries. |
| libexec | System daemons. |
| release | Release building Makefile & associated tools. |
| rescue | Build system for statically linked /rescue utilities. |
| sbin | System commands. |
| secure | Cryptographic libraries and commands. |
| share | Shared resources. |
| stand | Boot loader sources. |
| sys | Kernel sources (see [sys/README.md](sys/README.md)). |
| targets | Support for experimental `DIRDEPS_BUILD` |
| tests | Regression tests which can be run by Kyua. See [tests/README](tests/README) for additional information. |
| tools | Utilities for regression testing and miscellaneous tasks. |
| usr.bin | User commands. |
| usr.sbin | System administration commands. |
```
bin System/user commands.
For information on synchronizing your source tree with one or more of the FreeBSD Project's development branches, please see [FreeBSD Handbook](https://docs.freebsd.org/en/books/handbook/cutting-edge/#current-stable).
cddl Various commands and libraries under the Common Development
and Distribution License.
contrib Packages contributed by 3rd parties.
crypto Cryptography stuff (see crypto/README).
etc Template files for /etc.
gnu Commands and libraries under the GNU General Public License
(GPL) or Lesser General Public License (LGPL). Please see
gnu/COPYING* for more information.
include System include files.
kerberos5 Kerberos5 (Heimdal) package.
lib System libraries.
libexec System daemons.
release Release building Makefile & associated tools.
rescue Build system for statically linked /rescue utilities.
sbin System commands.
secure Cryptographic libraries and commands.
share Shared resources.
stand Boot loader sources.
sys Kernel sources.
sys/<arch>/conf Kernel configuration files. GENERIC is the configuration
used in release builds. NOTES contains documentation of
all possible entries.
tests Regression tests which can be run by Kyua. See tests/README
for additional information.
tools Utilities for regression testing and miscellaneous tasks.
usr.bin User commands.
usr.sbin System administration commands.
```
For information on synchronizing your source tree with one or more of
the FreeBSD Project's development branches, please see:
https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/current-stable.html
+20 -1
View File
@@ -1,4 +1,4 @@
Updating Information for FreeBSD stable/12 users.
Updating Information for FreeBSD releng/12.4 users.
This file is maintained and copyrighted by M. Warner Losh <[email protected]>.
See end of file for further details. For commonly done items, please see the
@@ -17,6 +17,25 @@ 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.
20221205:
12.4-RELEASE.
20221129:
12.4-RC2-p2 FreeBSD-SA-22:15.ping
FreeBSD-EN-22:28.heimdal
Stack overflow in ping [SA-22:15.ping]
Regression in Heimdal KDC [EN-22:28.heimdal]
20221116:
12.4-RC2-p1 FreeBSD-SA-22:14.heimdal
Multiple vulnerabilities in Heimdal [SA-22:14.heimdal]
20221020:
releng/12.4 branched from stable/12.
20220222:
Kernel-loadable random(4) modules are supported again, but are no
longer unloadable.
-2
View File
@@ -141,7 +141,6 @@ main(int argc, char *argv[])
int iovlen = 0;
#endif
fstype = "ufs";
(void)setlocale(LC_ALL, "");
memset(&maxwidths, 0, sizeof(maxwidths));
memset(&totalbuf, 0, sizeof(totalbuf));
@@ -210,7 +209,6 @@ main(int argc, char *argv[])
case 't':
if (vfslist_t != NULL)
xo_errx(1, "only one -t option may be specified");
fstype = optarg;
vfslist_t = makevfslist(optarg, &skipvfs_t);
break;
case 'T':
@@ -1605,7 +1605,6 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
* invocation.
*/
if (rsym.st_shndx != SHN_ABS) {
rsym.st_info = GELF_ST_INFO(STB_WEAK, STT_FUNC);
rsym.st_shndx = SHN_ABS;
(void) gelf_update_sym(data_sym, ndx, &rsym);
}
@@ -38,6 +38,9 @@
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#ifdef illumos
#include <alloca.h>
#endif
#include <errno.h>
#include <fcntl.h>
@@ -159,40 +162,26 @@ dt_opt_cpp_path(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
static int
dt_opt_cpp_opts(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
{
char *buf = NULL;
char *buf;
size_t len;
const char *opt = (const char *)option;
int ret;
if (opt == NULL || arg == NULL) {
ret = dt_set_errno(dtp, EDT_BADOPTVAL);
goto out;
}
if (opt == NULL || arg == NULL)
return (dt_set_errno(dtp, EDT_BADOPTVAL));
if (dtp->dt_pcb != NULL) {
ret = dt_set_errno(dtp, EDT_BADOPTCTX);
goto out;
}
if (dtp->dt_pcb != NULL)
return (dt_set_errno(dtp, EDT_BADOPTCTX));
len = strlen(opt) + strlen(arg) + 1;
if ((buf = dt_alloc(dtp, len)) == NULL) {
ret = dt_set_errno(dtp, EDT_NOMEM);
goto out;
}
buf = alloca(len);
(void) strcpy(buf, opt);
(void) strcat(buf, arg);
if (dt_cpp_add_arg(dtp, buf) == NULL) {
ret = dt_set_errno(dtp, EDT_NOMEM);
goto out;
}
if (dt_cpp_add_arg(dtp, buf) == NULL)
return (dt_set_errno(dtp, EDT_NOMEM));
ret = 0;
out:
if (buf != NULL)
dt_free(dtp, buf);
return (ret);
return (0);
}
/*ARGSUSED*/
@@ -896,35 +885,27 @@ dt_options_load(dtrace_hdl_t *dtp)
dof_hdr_t hdr, *dof;
dof_sec_t *sec;
size_t offs;
int i, ret;
int i;
/*
* To load the option values, we need to ask the kernel to provide its
* DOF, which we'll sift through to look for OPTDESC sections.
*/
dof = &hdr;
bzero(&hdr, sizeof (dof_hdr_t));
hdr.dofh_loadsz = sizeof (dof_hdr_t);
#ifdef illumos
if (dt_ioctl(dtp, DTRACEIOC_DOFGET, dof) == -1)
if (dt_ioctl(dtp, DTRACEIOC_DOFGET, &hdr) == -1)
#else
dof = &hdr;
if (dt_ioctl(dtp, DTRACEIOC_DOFGET, &dof) == -1)
#endif
{
ret = dt_set_errno(dtp, errno);
goto out;
}
return (dt_set_errno(dtp, errno));
if (hdr.dofh_loadsz < sizeof (dof_hdr_t)) {
ret = dt_set_errno(dtp, EINVAL);
goto out;
}
if (hdr.dofh_loadsz < sizeof (dof_hdr_t))
return (dt_set_errno(dtp, EINVAL));
if ((dof = dt_alloc(dtp, hdr.dofh_loadsz)) == NULL) {
ret = dt_set_errno(dtp, EDT_NOMEM);
goto out;
}
dof = alloca(hdr.dofh_loadsz);
bzero(dof, sizeof (dof_hdr_t));
dof->dofh_loadsz = hdr.dofh_loadsz;
@@ -936,10 +917,7 @@ dt_options_load(dtrace_hdl_t *dtp)
#else
if (dt_ioctl(dtp, DTRACEIOC_DOFGET, &dof) == -1)
#endif
{
ret = dt_set_errno(dtp, errno);
goto out;
}
return (dt_set_errno(dtp, errno));
for (i = 0; i < dof->dofh_secnum; i++) {
sec = (dof_sec_t *)(uintptr_t)((uintptr_t)dof +
@@ -964,11 +942,7 @@ dt_options_load(dtrace_hdl_t *dtp)
dtp->dt_options[opt->dofo_option] = opt->dofo_value;
}
ret = 0;
out:
if (dof != NULL && dof != &hdr)
dt_free(dtp, dof);
return (ret);
return (0);
}
typedef struct dt_option {
@@ -24,7 +24,8 @@
* All rights reserved.
*/
#include <err.h>
#pragma ident "%Z%%M% %I% %E% SMI"
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
@@ -35,6 +36,55 @@
/*LINTLIBRARY*/
static const char *pname;
#pragma init(getpname)
const char *
getpname(void)
{
const char *p, *q;
if (pname != NULL)
return (pname);
if ((p = getexecname()) != NULL)
q = strrchr(p, '/');
else
q = NULL;
if (q == NULL)
pname = p;
else
pname = q + 1;
return (pname);
}
void
vwarn(const char *format, va_list alist)
{
int err = errno;
if (pname != NULL)
(void) fprintf(stderr, "%s: ", pname);
(void) vfprintf(stderr, format, alist);
if (strchr(format, '\n') == NULL)
(void) fprintf(stderr, ": %s\n", strerror(err));
}
/*PRINTFLIKE1*/
void
warn(const char *format, ...)
{
va_list alist;
va_start(alist, format);
vwarn(format, alist);
va_end(alist);
}
void
vdie(const char *format, va_list alist)
{
@@ -39,9 +39,13 @@ extern "C" {
#define E_ERROR 1 /* Exit status for error */
#define E_USAGE 2 /* Exit status for usage error */
extern void vwarn(const char *, va_list);
extern void warn(const char *, ...);
extern void vdie(const char *, va_list);
extern void die(const char *, ...);
extern const char *getpname(void);
#ifdef __cplusplus
}
#endif
@@ -24,12 +24,13 @@
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/types.h>
#include <sys/sysmacros.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <err.h>
#include <strings.h>
#include <unistd.h>
#include <stdlib.h>
@@ -766,7 +767,7 @@ print_stats(void)
static int
print_usage(FILE *fp, int verbose)
{
(void) fprintf(fp, "Usage: %s [-dfhlsSt] [-u file] file\n", getprogname());
(void) fprintf(fp, "Usage: %s [-dfhlsSt] [-u file] file\n", getpname());
if (verbose) {
(void) fprintf(fp,
-37
View File
@@ -768,40 +768,3 @@ TEST_F(ReEvaluateByGuidTest, ReEvaluateByGuid_five)
delete CaseFile4;
delete CaseFile5;
}
/*
* Test VdevIterator
*/
class VdevIteratorTest : public ::testing::Test
{
};
bool VdevIteratorTestCB(Vdev &vdev, void *cbArg) {
return (false);
}
/*
* VdevIterator::Next should not crash when run on a pool that has a previously
* removed vdev. Regression for
* https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=273663
*/
TEST_F(VdevIteratorTest, VdevRemoval)
{
nvlist_t* poolConfig, *rootVdev;
ASSERT_EQ(0, nvlist_alloc(&rootVdev, NV_UNIQUE_NAME, 0));
ASSERT_EQ(0, nvlist_add_uint64(rootVdev, ZPOOL_CONFIG_GUID, 0x5678));
/*
* Note: pools with previously-removed top-level VDEVs will contain a
* TLV in their labels that has 0 children.
*/
ASSERT_EQ(0, nvlist_add_nvlist_array(rootVdev, ZPOOL_CONFIG_CHILDREN,
NULL, 0));
ASSERT_EQ(0, nvlist_alloc(&poolConfig, NV_UNIQUE_NAME, 0));
ASSERT_EQ(0, nvlist_add_uint64(poolConfig,
ZPOOL_CONFIG_POOL_GUID, 0x1234));
ASSERT_EQ(0, nvlist_add_nvlist(poolConfig, ZPOOL_CONFIG_VDEV_TREE,
rootVdev));
VdevIterator(poolConfig).Each(VdevIteratorTestCB, NULL);
}
+4 -1
View File
@@ -101,7 +101,10 @@ VdevIterator::Next()
{
nvlist_t *vdevConfig;
for (vdevConfig = NULL; !m_vdevQueue.empty();) {
if (m_vdevQueue.empty())
return (NULL);
for (;;) {
nvlist_t **vdevChildren;
int result;
u_int numChildren;
+1 -1
View File
@@ -274,7 +274,7 @@ ZfsDaemon::RescanSystem()
result = geom_gettree(&mesh);
if (result != 0) {
syslog(LOG_ERR, "ZfsDaemon::RescanSystem: "
"geom_gettree failed with error %d\n", result);
"geom_gettree faild with error %d\n", result);
return;
}
+3 -3
View File
@@ -152,12 +152,12 @@ struct port_input {
int fd; /* socket */
void *id; /* evSelect handle */
u_int stream : 1; /* stream socket */
u_int cred : 1; /* want credentials */
int stream : 1; /* stream socket */
int cred : 1; /* want credentials */
struct sockaddr *peer; /* last received packet */
socklen_t peerlen;
u_int priv : 1; /* peer is privileged */
int priv : 1; /* peer is privileged */
u_char *buf; /* receive buffer */
size_t buflen; /* buffer length */
+7 -12
View File
@@ -35,7 +35,6 @@
#include <errno.h>
#include <inttypes.h>
#include <malloc_np.h>
#include <signal.h>
#include <strings.h>
#include <string.h>
@@ -406,8 +405,10 @@ readmail(struct queue *queue, int nodot, int recp_from_header)
if ((ssize_t)error < 0)
return (-1);
while ((linelen = getline(&line, &linecap, stdin)) > 0) {
while (!feof(stdin)) {
newline[0] = '\0';
if ((linelen = getline(&line, &linecap, stdin)) <= 0)
break;
if (had_last_line)
errlogx(EX_DATAERR, "bad mail input format:"
" from %s (uid %d) (envelope-from %s)",
@@ -419,14 +420,8 @@ readmail(struct queue *queue, int nodot, int recp_from_header)
* If we fix it, it better be the last line of
* the file.
*/
if ((size_t)linelen + 1 > linecap) {
line = realloc(line, linelen + 2);
if (line == NULL)
errlogx(EX_SOFTWARE, "realloc");
linecap = malloc_usable_size(line);
}
line[linelen++] = '\n';
line[linelen] = 0;
line[linelen] = '\n';
line[linelen + 1] = 0;
had_last_line = 1;
}
if (!had_first_line) {
@@ -515,8 +510,8 @@ readmail(struct queue *queue, int nodot, int recp_from_header)
}
}
}
if (ferror(stdin) == 0)
ret = 0;
ret = 0;
fail:
free(line);
return (ret);
+8 -23
View File
@@ -69,11 +69,9 @@ process_ar_obj(struct elfcopy *ecp, struct ar_obj *obj)
/* Output to a temporary file. */
create_tempfile(NULL, &tempfile, &fd);
if ((ecp->eout = elf_begin(fd, ELF_C_WRITE, NULL)) == NULL) {
cleanup_tempfile(tempfile);
if ((ecp->eout = elf_begin(fd, ELF_C_WRITE, NULL)) == NULL)
errx(EXIT_FAILURE, "elf_begin() failed: %s",
elf_errmsg(-1));
}
elf_flagelf(ecp->eout, ELF_C_SET, ELF_F_LAYOUT);
create_elf(ecp);
elf_end(ecp->ein);
@@ -82,40 +80,27 @@ process_ar_obj(struct elfcopy *ecp, struct ar_obj *obj)
obj->buf = NULL;
/* Extract archive symbols. */
if (lseek(fd, 0, SEEK_SET) < 0) {
cleanup_tempfile(tempfile);
if (lseek(fd, 0, SEEK_SET) < 0)
err(EXIT_FAILURE, "lseek failed for '%s'", tempfile);
}
if ((ecp->eout = elf_begin(fd, ELF_C_READ, NULL)) == NULL) {
cleanup_tempfile(tempfile);
if ((ecp->eout = elf_begin(fd, ELF_C_READ, NULL)) == NULL)
errx(EXIT_FAILURE, "elf_begin() failed: %s",
elf_errmsg(-1));
}
extract_arsym(ecp);
elf_end(ecp->eout);
if (fstat(fd, &sb) == -1) {
cleanup_tempfile(tempfile);
if (fstat(fd, &sb) == -1)
err(EXIT_FAILURE, "fstat %s failed", tempfile);
}
if (lseek(fd, 0, SEEK_SET) < 0) {
cleanup_tempfile(tempfile);
if (lseek(fd, 0, SEEK_SET) < 0)
err(EXIT_FAILURE, "lseek %s failed", tempfile);
}
obj->size = sb.st_size;
if ((obj->maddr = malloc(obj->size)) == NULL) {
cleanup_tempfile(tempfile);
if ((obj->maddr = malloc(obj->size)) == NULL)
err(EXIT_FAILURE, "memory allocation failed for '%s'",
tempfile);
}
if ((size_t) read(fd, obj->maddr, obj->size) != obj->size) {
cleanup_tempfile(tempfile);
if ((size_t) read(fd, obj->maddr, obj->size) != obj->size)
err(EXIT_FAILURE, "read failed for '%s'", tempfile);
}
if (cleanup_tempfile(tempfile) < 0)
if (unlink(tempfile))
err(EXIT_FAILURE, "unlink %s failed", tempfile);
free(tempfile);
tempfile = NULL;
close(fd);
if (strlen(obj->name) > _MAXNAMELEN_SVR4)
add_to_ar_str_table(ecp, obj->name);
-1
View File
@@ -277,7 +277,6 @@ void add_to_symtab(struct elfcopy *_ecp, const char *_name,
unsigned char _st_info, unsigned char _st_other, int _ndx_known);
int add_to_inseg_list(struct elfcopy *_ecp, struct section *_sec);
void adjust_addr(struct elfcopy *_ecp);
int cleanup_tempfile(char *_fn);
void copy_content(struct elfcopy *_ecp);
void copy_data(struct section *_s);
void copy_phdr(struct elfcopy *_ecp);
+14 -60
View File
@@ -510,27 +510,6 @@ free_elf(struct elfcopy *ecp)
}
}
/*
* Remove a temporary file, without freeing its filename.
*
* Safe to pass NULL, will just ignore it.
*/
int
cleanup_tempfile(char *fn)
{
int errno_save, retval;
if (fn == NULL)
return 0;
errno_save = errno;
if ((retval = unlink(fn)) < 0) {
warn("unlink tempfile %s failed", fn);
errno = errno_save;
return retval;
}
return 0;
}
/* Create a temporary file. */
void
create_tempfile(const char *src, char **fn, int *fd)
@@ -677,10 +656,8 @@ create_file(struct elfcopy *ecp, const char *src, const char *dst)
}
#endif
if (lseek(ifd, 0, SEEK_SET) < 0) {
cleanup_tempfile(tempfile);
if (lseek(ifd, 0, SEEK_SET) < 0)
err(EXIT_FAILURE, "lseek failed");
}
/*
* If input object is not ELF file, convert it to an intermediate
@@ -700,12 +677,9 @@ create_file(struct elfcopy *ecp, const char *src, const char *dst)
ecp->oed = ELFDATA2LSB;
}
create_tempfile(src, &elftemp, &efd);
if ((ecp->eout = elf_begin(efd, ELF_C_WRITE, NULL)) == NULL) {
cleanup_tempfile(elftemp);
cleanup_tempfile(tempfile);
if ((ecp->eout = elf_begin(efd, ELF_C_WRITE, NULL)) == NULL)
errx(EXIT_FAILURE, "elf_begin() failed: %s",
elf_errmsg(-1));
}
elf_flagelf(ecp->eout, ELF_C_SET, ELF_F_LAYOUT);
if (ecp->itf == ETF_BINARY)
create_elf_from_binary(ecp, ifd, src);
@@ -713,31 +687,21 @@ create_file(struct elfcopy *ecp, const char *src, const char *dst)
create_elf_from_ihex(ecp, ifd);
else if (ecp->itf == ETF_SREC)
create_elf_from_srec(ecp, ifd);
else {
cleanup_tempfile(elftemp);
cleanup_tempfile(tempfile);
else
errx(EXIT_FAILURE, "Internal: invalid target flavour");
}
elf_end(ecp->eout);
/* Open intermediate ELF object as new input object. */
close(ifd);
if ((ifd = open(elftemp, O_RDONLY)) == -1) {
cleanup_tempfile(elftemp);
cleanup_tempfile(tempfile);
if ((ifd = open(elftemp, O_RDONLY)) == -1)
err(EXIT_FAILURE, "open %s failed", src);
}
close(efd);
if (cleanup_tempfile(elftemp) < 0) {
cleanup_tempfile(tempfile);
if (unlink(elftemp) < 0)
err(EXIT_FAILURE, "unlink %s failed", elftemp);
}
free(elftemp);
elftemp = NULL;
}
if ((ecp->ein = elf_begin(ifd, ELF_C_READ, NULL)) == NULL) {
cleanup_tempfile(tempfile);
if (fstat(ifd, &sb) == 0 && sb.st_size == 0)
errx(EXIT_FAILURE, "file format not recognized");
errx(EXIT_FAILURE, "elf_begin() failed: %s",
@@ -746,14 +710,11 @@ create_file(struct elfcopy *ecp, const char *src, const char *dst)
switch (elf_kind(ecp->ein)) {
case ELF_K_NONE:
cleanup_tempfile(tempfile);
errx(EXIT_FAILURE, "file format not recognized");
case ELF_K_ELF:
if ((ecp->eout = elf_begin(ofd, ELF_C_WRITE, NULL)) == NULL) {
cleanup_tempfile(tempfile);
if ((ecp->eout = elf_begin(ofd, ELF_C_WRITE, NULL)) == NULL)
errx(EXIT_FAILURE, "elf_begin() failed: %s",
elf_errmsg(-1));
}
/* elfcopy(1) manage ELF layout by itself. */
elf_flagelf(ecp->eout, ELF_C_SET, ELF_F_LAYOUT);
@@ -772,21 +733,21 @@ create_file(struct elfcopy *ecp, const char *src, const char *dst)
* Create (another) tempfile for binary/srec/ihex
* output object.
*/
if (cleanup_tempfile(tempfile) < 0)
errx(EXIT_FAILURE, "unlink %s failed",
tempfile);
free(tempfile);
if (tempfile != NULL) {
if (unlink(tempfile) < 0)
err(EXIT_FAILURE, "unlink %s failed",
tempfile);
free(tempfile);
}
create_tempfile(src, &tempfile, &ofd0);
/*
* Rewind the file descriptor being processed.
*/
if (lseek(ofd, 0, SEEK_SET) < 0) {
cleanup_tempfile(tempfile);
if (lseek(ofd, 0, SEEK_SET) < 0)
err(EXIT_FAILURE,
"lseek failed for the output object");
}
/*
* Call flavour-specific conversion routine.
@@ -807,13 +768,11 @@ create_file(struct elfcopy *ecp, const char *src, const char *dst)
#if WITH_PE
create_pe(ecp, ofd, ofd0);
#else
cleanup_tempfile(tempfile);
errx(EXIT_FAILURE, "PE/EFI support not enabled"
" at compile time");
#endif
break;
default:
cleanup_tempfile(tempfile);
errx(EXIT_FAILURE, "Internal: unsupported"
" output flavour %d", ecp->oec);
}
@@ -828,7 +787,6 @@ create_file(struct elfcopy *ecp, const char *src, const char *dst)
/* XXX: Not yet supported. */
break;
default:
cleanup_tempfile(tempfile);
errx(EXIT_FAILURE, "file format not supported");
}
@@ -847,13 +805,9 @@ copy_done:
in_place = 1;
}
if (copy_from_tempfile(tempfile, dst, ofd,
&tfd, in_place) < 0) {
cleanup_tempfile(tempfile);
if (copy_from_tempfile(tempfile, dst, ofd, &tfd, in_place) < 0)
err(EXIT_FAILURE, "creation of %s failed", dst);
}
/* 'tempfile' has been removed by copy_from_tempfile(). */
free(tempfile);
tempfile = NULL;
+2 -1
View File
@@ -3235,7 +3235,8 @@ dump_symtab(struct readelf *re, int i)
return;
if (!get_ent_count(s, &len))
return;
printf("\nSymbol table '%s' contains %d entries:\n", s->name, len);
printf("Symbol table (%s)", s->name);
printf(" contains %d entries:\n", len);
printf("%7s%9s%14s%5s%8s%6s%9s%5s\n", "Num:", "Value", "Size", "Type",
"Bind", "Vis", "Ndx", "Name");
-34
View File
@@ -2,40 +2,6 @@ NOTE: We are looking for help with a few things:
https://github.com/libexpat/libexpat/labels/help%20wanted
If you can help, please get in touch. Thanks!
Release 2.5.0 Tue October 25 2022
Security fixes:
#616 #649 #650 CVE-2022-43680 -- Fix heap use-after-free after overeager
destruction of a shared DTD in function
XML_ExternalEntityParserCreate in out-of-memory situations.
Expected impact is denial of service or potentially
arbitrary code execution.
Bug fixes:
#612 #645 Fix curruption from undefined entities
#613 #654 Fix case when parsing was suspended while processing nested
entities
#616 #652 #653 Stop leaking opening tag bindings after a closing tag
mismatch error where a parser is reset through
XML_ParserReset and then reused to parse
#656 CMake: Fix generation of pkg-config file
#658 MinGW|CMake: Fix static library name
Other changes:
#663 Protect header expat_config.h from multiple inclusion
#666 examples: Make use of XML_GetBuffer and be more
consistent across examples
#648 Address compiler warnings
#667 #668 Version info bumped from 9:9:8 to 9:10:8;
see https://verbump.de/ for what these numbers do
Special thanks to:
Jann Horn
Mark Brand
Osyotr
Rhodri James
and
Google Project Zero
Release 2.4.9 Tue September 20 2022
Security fixes:
#629 #640 CVE-2022-40674 -- Heap use-after-free vulnerability in
+1 -1
View File
@@ -5,7 +5,7 @@
[![Downloads GitHub](https://img.shields.io/github/downloads/libexpat/libexpat/total?label=Downloads%20GitHub)](https://github.com/libexpat/libexpat/releases)
# Expat, Release 2.5.0
# Expat, Release 2.4.9
This is Expat, a C library for parsing XML, started by
[James Clark](https://en.wikipedia.org/wiki/James_Clark_%28programmer%29) in 1997.
+3 -6
View File
@@ -81,14 +81,11 @@ dnl
dnl If the API changes incompatibly set LIBAGE back to 0
dnl
LIBCURRENT=9 # sync
LIBREVISION=10 # with
LIBAGE=8 # CMakeLists.txt!
LIBCURRENT=9 # sync
LIBREVISION=9 # with
LIBAGE=8 # CMakeLists.txt!
AC_CONFIG_HEADERS([expat_config.h])
AH_TOP([#ifndef EXPAT_CONFIG_H
#define EXPAT_CONFIG_H 1])
AH_BOTTOM([#endif // ndef EXPAT_CONFIG_H])
AM_PROG_AR
AC_PROG_INSTALL
+1 -1
View File
@@ -50,7 +50,7 @@
<div>
<h1>
The Expat XML Parser
<small>Release 2.5.0</small>
<small>Release 2.4.9</small>
</h1>
</div>
<div class="content">
+1 -1
View File
@@ -5,7 +5,7 @@
\\$2 \(la\\$1\(ra\\$3
..
.if \n(.g .mso www.tmac
.TH XMLWF 1 "October 25, 2022" "" ""
.TH XMLWF 1 "September 20, 2022" "" ""
.SH NAME
xmlwf \- Determines if an XML document is well-formed
.SH SYNOPSIS
+1 -1
View File
@@ -21,7 +21,7 @@
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
<!ENTITY dhfirstname "<firstname>Scott</firstname>">
<!ENTITY dhsurname "<surname>Bronson</surname>">
<!ENTITY dhdate "<date>October 25, 2022</date>">
<!ENTITY dhdate "<date>September 20, 2022</date>">
<!-- Please adjust this^^ date whenever cutting a new release. -->
<!ENTITY dhsection "<manvolnum>1</manvolnum>">
<!ENTITY dhemail "<email>[email protected]</email>">
+14 -33
View File
@@ -14,7 +14,7 @@
Copyright (c) 2001-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2004-2006 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2005-2007 Steven Solie <steven@solie.ca>
Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2016-2019 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2019 Zhongyuan Zhou <zhouzhongyuan@huawei.com>
Licensed under the MIT license:
@@ -49,6 +49,7 @@
#endif
#ifdef XML_UNICODE_WCHAR_T
# include <wchar.h>
# define XML_FMT_STR "ls"
#else
# define XML_FMT_STR "s"
@@ -57,7 +58,7 @@
static void XMLCALL
startElement(void *userData, const XML_Char *name, const XML_Char **atts) {
int i;
int *const depthPtr = (int *)userData;
int *depthPtr = (int *)userData;
(void)atts;
for (i = 0; i < *depthPtr; i++)
@@ -68,54 +69,34 @@ startElement(void *userData, const XML_Char *name, const XML_Char **atts) {
static void XMLCALL
endElement(void *userData, const XML_Char *name) {
int *const depthPtr = (int *)userData;
int *depthPtr = (int *)userData;
(void)name;
*depthPtr -= 1;
}
int
main(void) {
main(int argc, char *argv[]) {
char buf[BUFSIZ];
XML_Parser parser = XML_ParserCreate(NULL);
int done;
int depth = 0;
if (! parser) {
fprintf(stderr, "Couldn't allocate memory for parser\n");
return 1;
}
(void)argc;
(void)argv;
XML_SetUserData(parser, &depth);
XML_SetElementHandler(parser, startElement, endElement);
do {
void *const buf = XML_GetBuffer(parser, BUFSIZ);
if (! buf) {
fprintf(stderr, "Couldn't allocate memory for buffer\n");
XML_ParserFree(parser);
return 1;
}
const size_t len = fread(buf, 1, BUFSIZ, stdin);
if (ferror(stdin)) {
fprintf(stderr, "Read error\n");
XML_ParserFree(parser);
return 1;
}
done = feof(stdin);
if (XML_ParseBuffer(parser, (int)len, done) == XML_STATUS_ERROR) {
fprintf(stderr,
"Parse error at line %" XML_FMT_INT_MOD "u:\n%" XML_FMT_STR "\n",
XML_GetCurrentLineNumber(parser),
XML_ErrorString(XML_GetErrorCode(parser)));
size_t len = fread(buf, 1, sizeof(buf), stdin);
done = len < sizeof(buf);
if (XML_Parse(parser, buf, (int)len, done) == XML_STATUS_ERROR) {
fprintf(stderr, "%" XML_FMT_STR " at line %" XML_FMT_INT_MOD "u\n",
XML_ErrorString(XML_GetErrorCode(parser)),
XML_GetCurrentLineNumber(parser));
XML_ParserFree(parser);
return 1;
}
} while (! done);
XML_ParserFree(parser);
return 0;
}
+40 -41
View File
@@ -12,7 +12,7 @@
Copyright (c) 2001-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2005-2007 Steven Solie <steven@solie.ca>
Copyright (c) 2005-2006 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2016-2019 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Licensed under the MIT license:
@@ -51,74 +51,73 @@
# define XML_FMT_STR "s"
#endif
static void XMLCALL
startElement(void *userData, const XML_Char *name, const XML_Char **atts) {
int i;
int *const depthPtr = (int *)userData;
#define BUFFSIZE 8192
for (i = 0; i < *depthPtr; i++)
char Buff[BUFFSIZE];
int Depth;
static void XMLCALL
start(void *data, const XML_Char *el, const XML_Char **attr) {
int i;
(void)data;
for (i = 0; i < Depth; i++)
printf(" ");
printf("%" XML_FMT_STR, name);
printf("%" XML_FMT_STR, el);
for (i = 0; atts[i]; i += 2) {
printf(" %" XML_FMT_STR "='%" XML_FMT_STR "'", atts[i], atts[i + 1]);
for (i = 0; attr[i]; i += 2) {
printf(" %" XML_FMT_STR "='%" XML_FMT_STR "'", attr[i], attr[i + 1]);
}
printf("\n");
*depthPtr += 1;
Depth++;
}
static void XMLCALL
endElement(void *userData, const XML_Char *name) {
int *const depthPtr = (int *)userData;
(void)name;
end(void *data, const XML_Char *el) {
(void)data;
(void)el;
*depthPtr -= 1;
Depth--;
}
int
main(void) {
XML_Parser parser = XML_ParserCreate(NULL);
int done;
int depth = 0;
main(int argc, char *argv[]) {
XML_Parser p = XML_ParserCreate(NULL);
(void)argc;
(void)argv;
if (! parser) {
if (! p) {
fprintf(stderr, "Couldn't allocate memory for parser\n");
return 1;
exit(-1);
}
XML_SetUserData(parser, &depth);
XML_SetElementHandler(parser, startElement, endElement);
XML_SetElementHandler(p, start, end);
do {
void *const buf = XML_GetBuffer(parser, BUFSIZ);
if (! buf) {
fprintf(stderr, "Couldn't allocate memory for buffer\n");
XML_ParserFree(parser);
return 1;
}
const size_t len = fread(buf, 1, BUFSIZ, stdin);
for (;;) {
int done;
int len;
len = (int)fread(Buff, 1, BUFFSIZE, stdin);
if (ferror(stdin)) {
fprintf(stderr, "Read error\n");
XML_ParserFree(parser);
return 1;
exit(-1);
}
done = feof(stdin);
if (XML_ParseBuffer(parser, (int)len, done) == XML_STATUS_ERROR) {
if (XML_Parse(p, Buff, len, done) == XML_STATUS_ERROR) {
fprintf(stderr,
"Parse error at line %" XML_FMT_INT_MOD "u:\n%" XML_FMT_STR "\n",
XML_GetCurrentLineNumber(parser),
XML_ErrorString(XML_GetErrorCode(parser)));
XML_ParserFree(parser);
return 1;
XML_GetCurrentLineNumber(p),
XML_ErrorString(XML_GetErrorCode(p)));
exit(-1);
}
} while (! done);
XML_ParserFree(parser);
if (done)
break;
}
XML_ParserFree(p);
return 0;
}
-5
View File
@@ -1,8 +1,5 @@
/* expat_config.h.in. Generated from configure.ac by autoheader. */
#ifndef EXPAT_CONFIG_H
#define EXPAT_CONFIG_H 1
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
@@ -135,5 +132,3 @@
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
#endif // ndef EXPAT_CONFIG_H
+2 -2
View File
@@ -1054,8 +1054,8 @@ XML_SetBillionLaughsAttackProtectionActivationThreshold(
See http://semver.org.
*/
#define XML_MAJOR_VERSION 2
#define XML_MINOR_VERSION 5
#define XML_MICRO_VERSION 0
#define XML_MINOR_VERSION 4
#define XML_MICRO_VERSION 9
#ifdef __cplusplus
}
+15 -32
View File
@@ -1,4 +1,4 @@
/* 5ab094ffadd6edfc94c3eee53af44a86951f9f1f0933ada3114bbce2bfb02c99 (2.5.0+)
/* 90815a2b2c80c03b2b889fe1d427bb2b9e3282aa065e42784e001db4f23de324 (2.4.9+)
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
@@ -35,7 +35,6 @@
Copyright (c) 2021 Dong-hee Na <donghee.na@python.org>
Copyright (c) 2022 Samanta Navarro <ferivoz@riseup.net>
Copyright (c) 2022 Jeffrey Walton <noloader@gmail.com>
Copyright (c) 2022 Jann Horn <jannh@google.com>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@@ -1069,14 +1068,6 @@ parserCreate(const XML_Char *encodingName,
parserInit(parser, encodingName);
if (encodingName && ! parser->m_protocolEncodingName) {
if (dtd) {
// We need to stop the upcoming call to XML_ParserFree from happily
// destroying parser->m_dtd because the DTD is shared with the parent
// parser and the only guard that keeps XML_ParserFree from destroying
// parser->m_dtd is parser->m_isParamEntity but it will be set to
// XML_TRUE only later in XML_ExternalEntityParserCreate (or not at all).
parser->m_dtd = NULL;
}
XML_ParserFree(parser);
return NULL;
}
@@ -3020,6 +3011,9 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
int len;
const char *rawName;
TAG *tag = parser->m_tagStack;
parser->m_tagStack = tag->parent;
tag->parent = parser->m_freeTagList;
parser->m_freeTagList = tag;
rawName = s + enc->minBytesPerChar * 2;
len = XmlNameLength(enc, rawName);
if (len != tag->rawNameLength
@@ -3027,9 +3021,6 @@ doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
*eventPP = rawName;
return XML_ERROR_TAG_MISMATCH;
}
parser->m_tagStack = tag->parent;
tag->parent = parser->m_freeTagList;
parser->m_freeTagList = tag;
--parser->m_tagLevel;
if (parser->m_endElementHandler) {
const XML_Char *localPart;
@@ -4984,10 +4975,10 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
parser->m_handlerArg, parser->m_declElementType->name,
parser->m_declAttributeId->name, parser->m_declAttributeType, 0,
role == XML_ROLE_REQUIRED_ATTRIBUTE_VALUE);
poolClear(&parser->m_tempPool);
handleDefault = XML_FALSE;
}
}
poolClear(&parser->m_tempPool);
break;
case XML_ROLE_DEFAULT_ATTRIBUTE_VALUE:
case XML_ROLE_FIXED_ATTRIBUTE_VALUE:
@@ -5395,7 +5386,7 @@ doProlog(XML_Parser parser, const ENCODING *enc, const char *s, const char *end,
*
* If 'standalone' is false, the DTD must have no
* parameter entities or we wouldn't have passed the outer
* 'if' statement. That means the only entity in the hash
* 'if' statement. That measn the only entity in the hash
* table is the external subset name "#" which cannot be
* given as a parameter entity name in XML syntax, so the
* lookup must have returned NULL and we don't even reach
@@ -5807,27 +5798,19 @@ internalEntityProcessor(XML_Parser parser, const char *s, const char *end,
if (result != XML_ERROR_NONE)
return result;
if (textEnd != next && parser->m_parsingStatus.parsing == XML_SUSPENDED) {
else if (textEnd != next
&& parser->m_parsingStatus.parsing == XML_SUSPENDED) {
entity->processed = (int)(next - (const char *)entity->textPtr);
return result;
}
} else {
#ifdef XML_DTD
entityTrackingOnClose(parser, entity, __LINE__);
entityTrackingOnClose(parser, entity, __LINE__);
#endif
entity->open = XML_FALSE;
parser->m_openInternalEntities = openEntity->next;
/* put openEntity back in list of free instances */
openEntity->next = parser->m_freeInternalEntities;
parser->m_freeInternalEntities = openEntity;
// If there are more open entities we want to stop right here and have the
// upcoming call to XML_ResumeParser continue with entity content, or it would
// be ignored altogether.
if (parser->m_openInternalEntities != NULL
&& parser->m_parsingStatus.parsing == XML_SUSPENDED) {
return XML_ERROR_NONE;
entity->open = XML_FALSE;
parser->m_openInternalEntities = openEntity->next;
/* put openEntity back in list of free instances */
openEntity->next = parser->m_freeInternalEntities;
parser->m_freeInternalEntities = openEntity;
}
#ifdef XML_DTD
+1 -1
View File
@@ -45,7 +45,7 @@ enum {
BT_LF, /* line feed = "\n" */
BT_GT, /* greater than = ">" */
BT_QUOT, /* quotation character = "\"" */
BT_APOS, /* apostrophe = "'" */
BT_APOS, /* aposthrophe = "'" */
BT_EQUALS, /* equal sign = "=" */
BT_QUEST, /* question mark = "?" */
BT_EXCL, /* exclamation mark = "!" */
+3 -174
View File
@@ -11,7 +11,7 @@
Copyright (c) 2005-2007 Steven Solie <steven@solie.ca>
Copyright (c) 2005-2012 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017-2022 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2017-2018 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2017 Joe Orton <jorton@redhat.com>
Copyright (c) 2017 José Gutiérrez de la Concha <jose@zeroc.com>
Copyright (c) 2018 Marco Maggi <marco.maggi-ipsu@poste.it>
@@ -4990,7 +4990,7 @@ START_TEST(test_suspend_resume_internal_entity) {
}
END_TEST
static void XMLCALL
void
suspending_comment_handler(void *userData, const XML_Char *data) {
UNUSED_P(data);
XML_Parser parser = (XML_Parser)userData;
@@ -6734,102 +6734,6 @@ START_TEST(test_empty_element_abort) {
}
END_TEST
/* Regression test for GH issue #612: unfinished m_declAttributeType
* allocation in ->m_tempPool can corrupt following allocation.
*/
static int XMLCALL
external_entity_unfinished_attlist(XML_Parser parser, const XML_Char *context,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId) {
const char *text = "<!ELEMENT barf ANY>\n"
"<!ATTLIST barf my_attr (blah|%blah;a|foo) #REQUIRED>\n"
"<!--COMMENT-->\n";
XML_Parser ext_parser;
UNUSED_P(base);
UNUSED_P(publicId);
if (systemId == NULL)
return XML_STATUS_OK;
ext_parser = XML_ExternalEntityParserCreate(parser, context, NULL);
if (ext_parser == NULL)
fail("Could not create external entity parser");
if (_XML_Parse_SINGLE_BYTES(ext_parser, text, (int)strlen(text), XML_TRUE)
== XML_STATUS_ERROR)
xml_failure(ext_parser);
XML_ParserFree(ext_parser);
return XML_STATUS_OK;
}
START_TEST(test_pool_integrity_with_unfinished_attr) {
const char *text = "<?xml version='1.0' encoding='UTF-8'?>\n"
"<!DOCTYPE foo [\n"
"<!ELEMENT foo ANY>\n"
"<!ENTITY % entp SYSTEM \"external.dtd\">\n"
"%entp;\n"
"]>\n"
"<a></a>\n";
const XML_Char *expected = XCS("COMMENT");
CharData storage;
CharData_Init(&storage);
XML_SetParamEntityParsing(g_parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
XML_SetExternalEntityRefHandler(g_parser, external_entity_unfinished_attlist);
XML_SetAttlistDeclHandler(g_parser, dummy_attlist_decl_handler);
XML_SetCommentHandler(g_parser, accumulate_comment);
XML_SetUserData(g_parser, &storage);
if (_XML_Parse_SINGLE_BYTES(g_parser, text, (int)strlen(text), XML_TRUE)
== XML_STATUS_ERROR)
xml_failure(g_parser);
CharData_CheckXMLChars(&storage, expected);
}
END_TEST
typedef struct {
XML_Parser parser;
CharData *storage;
} ParserPlusStorage;
static void XMLCALL
accumulate_and_suspend_comment_handler(void *userData, const XML_Char *data) {
ParserPlusStorage *const parserPlusStorage = (ParserPlusStorage *)userData;
accumulate_comment(parserPlusStorage->storage, data);
XML_StopParser(parserPlusStorage->parser, XML_TRUE);
}
START_TEST(test_nested_entity_suspend) {
const char *const text = "<!DOCTYPE a [\n"
" <!ENTITY e1 '<!--e1-->'>\n"
" <!ENTITY e2 '<!--e2 head-->&e1;<!--e2 tail-->'>\n"
" <!ENTITY e3 '<!--e3 head-->&e2;<!--e3 tail-->'>\n"
"]>\n"
"<a><!--start-->&e3;<!--end--></a>";
const XML_Char *const expected = XCS("start") XCS("e3 head") XCS("e2 head")
XCS("e1") XCS("e2 tail") XCS("e3 tail") XCS("end");
CharData storage;
XML_Parser parser = XML_ParserCreate(NULL);
ParserPlusStorage parserPlusStorage = {parser, &storage};
CharData_Init(&storage);
XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
XML_SetCommentHandler(parser, accumulate_and_suspend_comment_handler);
XML_SetUserData(parser, &parserPlusStorage);
enum XML_Status status = XML_Parse(parser, text, (int)strlen(text), XML_TRUE);
while (status == XML_STATUS_SUSPENDED) {
status = XML_ResumeParser(parser);
}
if (status != XML_STATUS_OK)
xml_failure(parser);
CharData_CheckXMLChars(&storage, expected);
XML_ParserFree(parser);
}
END_TEST
/*
* Namespaces tests.
*/
@@ -7757,7 +7661,7 @@ START_TEST(test_misc_version) {
fail("Version mismatch");
#if ! defined(XML_UNICODE) || defined(XML_UNICODE_WCHAR_T)
if (xcstrcmp(version_text, XCS("expat_2.5.0"))) /* needs bump on releases */
if (xcstrcmp(version_text, XCS("expat_2.4.9"))) /* needs bump on releases */
fail("XML_*_VERSION in expat.h out of sync?\n");
#else
/* If we have XML_UNICODE defined but not XML_UNICODE_WCHAR_T
@@ -7969,28 +7873,6 @@ START_TEST(test_misc_deny_internal_entity_closing_doctype_issue_317) {
}
END_TEST
START_TEST(test_misc_tag_mismatch_reset_leak) {
#ifdef XML_NS
const char *const text = "<open xmlns='https://namespace1.test'></close>";
XML_Parser parser = XML_ParserCreateNS(NULL, XCS('\n'));
if (XML_Parse(parser, text, (int)strlen(text), XML_TRUE) != XML_STATUS_ERROR)
fail("Call to parse was expected to fail");
if (XML_GetErrorCode(parser) != XML_ERROR_TAG_MISMATCH)
fail("Call to parse was expected to fail from a closing tag mismatch");
XML_ParserReset(parser, NULL);
if (XML_Parse(parser, text, (int)strlen(text), XML_TRUE) != XML_STATUS_ERROR)
fail("Call to parse was expected to fail");
if (XML_GetErrorCode(parser) != XML_ERROR_TAG_MISMATCH)
fail("Call to parse was expected to fail from a closing tag mismatch");
XML_ParserFree(parser);
#endif
}
END_TEST
static void
alloc_setup(void) {
XML_Memory_Handling_Suite memsuite = {duff_allocator, duff_reallocator, free};
@@ -10208,53 +10090,6 @@ START_TEST(test_alloc_long_notation) {
}
END_TEST
static int XMLCALL
external_entity_parser_create_alloc_fail_handler(XML_Parser parser,
const XML_Char *context,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId) {
UNUSED_P(base);
UNUSED_P(systemId);
UNUSED_P(publicId);
if (context != NULL)
fail("Unexpected non-NULL context");
// The following number intends to fail the upcoming allocation in line
// "parser->m_protocolEncodingName = copyString(encodingName,
// &(parser->m_mem));" in function parserInit.
allocation_count = 3;
const XML_Char *const encodingName = XCS("UTF-8"); // needs something non-NULL
const XML_Parser ext_parser
= XML_ExternalEntityParserCreate(parser, context, encodingName);
if (ext_parser != NULL)
fail(
"Call to XML_ExternalEntityParserCreate was expected to fail out-of-memory");
allocation_count = ALLOC_ALWAYS_SUCCEED;
return XML_STATUS_ERROR;
}
START_TEST(test_alloc_reset_after_external_entity_parser_create_fail) {
const char *const text = "<!DOCTYPE doc SYSTEM 'foo'><doc/>";
XML_SetExternalEntityRefHandler(
g_parser, external_entity_parser_create_alloc_fail_handler);
XML_SetParamEntityParsing(g_parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
if (XML_Parse(g_parser, text, (int)strlen(text), XML_TRUE)
!= XML_STATUS_ERROR)
fail("Call to parse was expected to fail");
if (XML_GetErrorCode(g_parser) != XML_ERROR_EXTERNAL_ENTITY_HANDLING)
fail("Call to parse was expected to fail from the external entity handler");
XML_ParserReset(g_parser, NULL);
}
END_TEST
static void
nsalloc_setup(void) {
XML_Memory_Handling_Suite memsuite = {duff_allocator, duff_reallocator, free};
@@ -12334,9 +12169,6 @@ make_suite(void) {
tcase_add_test(tc_basic, test_bad_notation);
tcase_add_test(tc_basic, test_default_doctype_handler);
tcase_add_test(tc_basic, test_empty_element_abort);
tcase_add_test__ifdef_xml_dtd(tc_basic,
test_pool_integrity_with_unfinished_attr);
tcase_add_test(tc_basic, test_nested_entity_suspend);
suite_add_tcase(s, tc_namespace);
tcase_add_checked_fixture(tc_namespace, namespace_setup, namespace_teardown);
@@ -12389,7 +12221,6 @@ make_suite(void) {
tcase_add_test(tc_misc, test_misc_stop_during_end_handler_issue_240_2);
tcase_add_test__ifdef_xml_dtd(
tc_misc, test_misc_deny_internal_entity_closing_doctype_issue_317);
tcase_add_test(tc_misc, test_misc_tag_mismatch_reset_leak);
suite_add_tcase(s, tc_alloc);
tcase_add_checked_fixture(tc_alloc, alloc_setup, alloc_teardown);
@@ -12448,8 +12279,6 @@ make_suite(void) {
tcase_add_test(tc_alloc, test_alloc_long_public_id);
tcase_add_test(tc_alloc, test_alloc_long_entity_value);
tcase_add_test(tc_alloc, test_alloc_long_notation);
tcase_add_test__ifdef_xml_dtd(
tc_alloc, test_alloc_reset_after_external_entity_parser_create_fail);
suite_add_tcase(s, tc_nsalloc);
tcase_add_checked_fixture(tc_nsalloc, nsalloc_setup, nsalloc_teardown);
+1 -1
View File
@@ -1 +1 @@
Gentoo GLEP 78 (GPKG) binary package for "inkscape-1.2.1-r2-1" using zstd compression
Gentoo GLEP 78 (GPKG) binary package for "inkscape-1.2.1-r2-1" using zstd compression
+1 -1
View File
@@ -376,7 +376,7 @@ malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
} \
} while (0)
#define GET_ARG_NUMERIC(val, len) do { \
switch ((unsigned char)len) { \
switch (len) { \
case '?': \
val = va_arg(ap, int); \
break; \
-4
View File
@@ -1,7 +1,3 @@
Wed 07, 2022: libarchive 3.6.2 released
Apr 08, 2022: libarchive 3.6.1 released
Feb 09, 2022: libarchive 3.6.0 released
Feb 08, 2022: libarchive 3.5.3 released
-5
View File
@@ -37,7 +37,6 @@ The top-level directory contains the following information files:
* **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
@@ -72,7 +71,6 @@ know about any errors or omissions you find.
## Supported Formats
Currently, the library automatically detects and reads the following formats:
* Old V7 tar archives
* POSIX ustar
* GNU tar format (including GNU long filenames, long link names, and sparse files)
@@ -94,7 +92,6 @@ Currently, the library automatically detects and reads the following formats:
* XAR archives
The library also detects and handles any of the following before evaluating the archive:
* uuencoded files
* files with RPM wrapper
* gzip compression
@@ -106,7 +103,6 @@ The library also detects and handles any of the following before evaluating the
* zstandard 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
@@ -126,7 +122,6 @@ The library can create archives in any of the following formats:
* XAR archives
When creating archives, the result can be filtered with any of the following:
* uuencode
* gzip compression
* bzip2 compression
+2 -22
View File
@@ -36,14 +36,6 @@ DEFINE_TEST(test_option_t)
time_t mtime;
char date[32];
char date2[32];
struct tm *tmptr;
#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
struct tm tmbuf;
#endif
#if defined(HAVE__LOCALTIME64_S)
errno_t terr;
__time64_t tmptime;
#endif
/* List reference archive, make sure the TOC is correct. */
extract_reference_file("test_option_t.cpio");
@@ -95,23 +87,11 @@ DEFINE_TEST(test_option_t)
#ifdef HAVE_LOCALE_H
setlocale(LC_ALL, "");
#endif
#if defined(HAVE_LOCALTIME_R)
tmptr = localtime_r(&mtime, &tmbuf);
#elif defined(HAVE__LOCALTIME64_S)
tmptime = mtime;
terr = _localtime64_s(&tmbuf, &tmptime);
if (terr)
tmptr = NULL;
else
tmptr = &tmbuf;
#else
tmptr = localtime(&mtime);
#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
strftime(date2, sizeof(date2)-1, "%b %d %Y", tmptr);
strftime(date2, sizeof(date2)-1, "%b %d %Y", localtime(&mtime));
_snprintf(date, sizeof(date)-1, "%12.12s file", date2);
#else
strftime(date2, sizeof(date2)-1, "%b %e %Y", tmptr);
strftime(date2, sizeof(date2)-1, "%b %e %Y", localtime(&mtime));
snprintf(date, sizeof(date)-1, "%12.12s file", date2);
#endif
assertEqualMem(p + 42, date, strlen(date));
+2 -4
View File
@@ -36,7 +36,7 @@
* assert that ARCHIVE_VERSION_NUMBER >= 2012108.
*/
/* Note: Compiler will complain if this does not match archive_entry.h! */
#define ARCHIVE_VERSION_NUMBER 3006002
#define ARCHIVE_VERSION_NUMBER 3006000
#include <sys/stat.h>
#include <stddef.h> /* for wchar_t */
@@ -120,8 +120,6 @@ typedef ssize_t la_ssize_t;
# define __LA_DECL __declspec(dllimport)
# endif
# endif
#elif defined __LIBARCHIVE_ENABLE_VISIBILITY
# define __LA_DECL __attribute__((visibility("default")))
#else
/* Static libraries or non-Windows needs no special declaration. */
# define __LA_DECL
@@ -157,7 +155,7 @@ __LA_DECL int archive_version_number(void);
/*
* Textual name/version of the library, useful for version displays.
*/
#define ARCHIVE_VERSION_ONLY_STRING "3.6.2"
#define ARCHIVE_VERSION_ONLY_STRING "3.6.0"
#define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
__LA_DECL const char * archive_version_string(void);
+14 -20
View File
@@ -49,16 +49,16 @@
* Initialize a Message digest.
*/
static int
win_crypto_init(Digest_CTX *ctx, DWORD prov, ALG_ID algId)
win_crypto_init(Digest_CTX *ctx, ALG_ID algId)
{
ctx->valid = 0;
if (!CryptAcquireContext(&ctx->cryptProv, NULL, NULL,
prov, CRYPT_VERIFYCONTEXT)) {
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
if (GetLastError() != (DWORD)NTE_BAD_KEYSET)
return (ARCHIVE_FAILED);
if (!CryptAcquireContext(&ctx->cryptProv, NULL, NULL,
prov, CRYPT_NEWKEYSET))
PROV_RSA_FULL, CRYPT_NEWKEYSET))
return (ARCHIVE_FAILED);
}
@@ -243,8 +243,7 @@ __archive_md5init(archive_md5_ctx *ctx)
{
if ((*ctx = EVP_MD_CTX_new()) == NULL)
return (ARCHIVE_FAILED);
if (!EVP_DigestInit(*ctx, EVP_md5()))
return (ARCHIVE_FAILED);
EVP_DigestInit(*ctx, EVP_md5());
return (ARCHIVE_OK);
}
@@ -276,7 +275,7 @@ __archive_md5final(archive_md5_ctx *ctx, void *md)
static int
__archive_md5init(archive_md5_ctx *ctx)
{
return (win_crypto_init(ctx, PROV_RSA_FULL, CALG_MD5));
return (win_crypto_init(ctx, CALG_MD5));
}
static int
@@ -435,8 +434,7 @@ __archive_ripemd160init(archive_rmd160_ctx *ctx)
{
if ((*ctx = EVP_MD_CTX_new()) == NULL)
return (ARCHIVE_FAILED);
if (!EVP_DigestInit(*ctx, EVP_ripemd160()))
return (ARCHIVE_FAILED);
EVP_DigestInit(*ctx, EVP_ripemd160());
return (ARCHIVE_OK);
}
@@ -626,8 +624,7 @@ __archive_sha1init(archive_sha1_ctx *ctx)
{
if ((*ctx = EVP_MD_CTX_new()) == NULL)
return (ARCHIVE_FAILED);
if (!EVP_DigestInit(*ctx, EVP_sha1()))
return (ARCHIVE_FAILED);
EVP_DigestInit(*ctx, EVP_sha1());
return (ARCHIVE_OK);
}
@@ -659,7 +656,7 @@ __archive_sha1final(archive_sha1_ctx *ctx, void *md)
static int
__archive_sha1init(archive_sha1_ctx *ctx)
{
return (win_crypto_init(ctx, PROV_RSA_FULL, CALG_SHA1));
return (win_crypto_init(ctx, CALG_SHA1));
}
static int
@@ -890,8 +887,7 @@ __archive_sha256init(archive_sha256_ctx *ctx)
{
if ((*ctx = EVP_MD_CTX_new()) == NULL)
return (ARCHIVE_FAILED);
if (!EVP_DigestInit(*ctx, EVP_sha256()))
return (ARCHIVE_FAILED);
EVP_DigestInit(*ctx, EVP_sha256());
return (ARCHIVE_OK);
}
@@ -919,7 +915,7 @@ __archive_sha256final(archive_sha256_ctx *ctx, void *md)
static int
__archive_sha256init(archive_sha256_ctx *ctx)
{
return (win_crypto_init(ctx, PROV_RSA_AES, CALG_SHA_256));
return (win_crypto_init(ctx, CALG_SHA_256));
}
static int
@@ -1126,8 +1122,7 @@ __archive_sha384init(archive_sha384_ctx *ctx)
{
if ((*ctx = EVP_MD_CTX_new()) == NULL)
return (ARCHIVE_FAILED);
if (!EVP_DigestInit(*ctx, EVP_sha384()))
return (ARCHIVE_FAILED);
EVP_DigestInit(*ctx, EVP_sha384());
return (ARCHIVE_OK);
}
@@ -1155,7 +1150,7 @@ __archive_sha384final(archive_sha384_ctx *ctx, void *md)
static int
__archive_sha384init(archive_sha384_ctx *ctx)
{
return (win_crypto_init(ctx, PROV_RSA_AES, CALG_SHA_384));
return (win_crypto_init(ctx, CALG_SHA_384));
}
static int
@@ -1386,8 +1381,7 @@ __archive_sha512init(archive_sha512_ctx *ctx)
{
if ((*ctx = EVP_MD_CTX_new()) == NULL)
return (ARCHIVE_FAILED);
if (!EVP_DigestInit(*ctx, EVP_sha512()))
return (ARCHIVE_FAILED);
EVP_DigestInit(*ctx, EVP_sha512());
return (ARCHIVE_OK);
}
@@ -1415,7 +1409,7 @@ __archive_sha512final(archive_sha512_ctx *ctx, void *md)
static int
__archive_sha512init(archive_sha512_ctx *ctx)
{
return (win_crypto_init(ctx, PROV_RSA_AES, CALG_SHA_512));
return (win_crypto_init(ctx, CALG_SHA_512));
}
static int
@@ -568,13 +568,6 @@ archive_entry_nlink(struct archive_entry *entry)
return (entry->ae_stat.aest_nlink);
}
/* Instead, our caller could have chosen a specific encoding
* (archive_mstring_get_mbs, archive_mstring_get_utf8,
* archive_mstring_get_wcs). So we should try multiple
* encodings. Try mbs first because of history, even though
* utf8 might be better for pathname portability.
* Also omit wcs because of type mismatch (char * versus wchar *)
*/
const char *
archive_entry_pathname(struct archive_entry *entry)
{
@@ -582,13 +575,6 @@ archive_entry_pathname(struct archive_entry *entry)
if (archive_mstring_get_mbs(
entry->archive, &entry->ae_pathname, &p) == 0)
return (p);
#if HAVE_EILSEQ /*{*/
if (errno == EILSEQ) {
if (archive_mstring_get_utf8(
entry->archive, &entry->ae_pathname, &p) == 0)
return (p);
}
#endif /*}*/
if (errno == ENOMEM)
__archive_errx(1, "No memory");
return (NULL);
@@ -30,7 +30,7 @@
#define ARCHIVE_ENTRY_H_INCLUDED
/* Note: Compiler will complain if this does not match archive.h! */
#define ARCHIVE_VERSION_NUMBER 3006002
#define ARCHIVE_VERSION_NUMBER 3006000
/*
* Note: archive_entry.h is for use outside of libarchive; the
@@ -122,8 +122,6 @@ typedef ssize_t la_ssize_t;
# define __LA_DECL __declspec(dllimport)
# endif
# endif
#elif defined __LIBARCHIVE_ENABLE_VISIBILITY
# define __LA_DECL __attribute__((visibility("default")))
#else
/* Static libraries on all platforms and shared libraries on non-Windows. */
# define __LA_DECL
@@ -230,23 +230,10 @@ __hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx)
static int
__hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len)
{
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
OSSL_PARAM params[2];
EVP_MAC *mac = EVP_MAC_fetch(NULL, "HMAC", NULL);
*ctx = EVP_MAC_CTX_new(mac);
if (*ctx == NULL)
return -1;
EVP_MAC_free(mac);
params[0] = OSSL_PARAM_construct_utf8_string("digest", "SHA1", 0);
params[1] = OSSL_PARAM_construct_end();
EVP_MAC_init(*ctx, key, key_len, params);
#else
*ctx = HMAC_CTX_new();
if (*ctx == NULL)
return -1;
HMAC_Init_ex(*ctx, key, key_len, EVP_sha1(), NULL);
#endif
return 0;
}
@@ -254,38 +241,22 @@ static void
__hmac_sha1_update(archive_hmac_sha1_ctx *ctx, const uint8_t *data,
size_t data_len)
{
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
EVP_MAC_update(*ctx, data, data_len);
#else
HMAC_Update(*ctx, data, data_len);
#endif
}
static void
__hmac_sha1_final(archive_hmac_sha1_ctx *ctx, uint8_t *out, size_t *out_len)
{
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
size_t len = *out_len;
#else
unsigned int len = (unsigned int)*out_len;
#endif
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
EVP_MAC_final(*ctx, out, &len, *out_len);
#else
HMAC_Final(*ctx, out, &len);
#endif
*out_len = len;
}
static void
__hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx)
{
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
EVP_MAC_CTX_free(*ctx);
#else
HMAC_CTX_free(*ctx);
#endif
*ctx = NULL;
}
@@ -74,16 +74,9 @@ typedef mbedtls_md_context_t archive_hmac_sha1_ctx;
typedef struct hmac_sha1_ctx archive_hmac_sha1_ctx;
#elif defined(HAVE_LIBCRYPTO)
#include <openssl/opensslv.h>
#include <openssl/hmac.h>
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
typedef EVP_MAC_CTX *archive_hmac_sha1_ctx;
#else
#include "archive_openssl_hmac_private.h"
typedef HMAC_CTX* archive_hmac_sha1_ctx;
#endif
#else
@@ -195,9 +195,8 @@
/*
* glibc 2.24 deprecates readdir_r
* bionic c deprecates readdir_r too
*/
#if defined(HAVE_READDIR_R) && (!defined(__GLIBC__) || !defined(__GLIBC_MINOR__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 24)) && (!defined(__ANDROID__))
#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
@@ -34,6 +34,9 @@ __FBSDID("$FreeBSD$");
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_MOUNT_H
#include <sys/mount.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
@@ -51,8 +54,6 @@ __FBSDID("$FreeBSD$");
#endif
#ifdef HAVE_LINUX_FS_H
#include <linux/fs.h>
#elif HAVE_SYS_MOUNT_H
#include <sys/mount.h>
#endif
/*
* Some Linux distributions have both linux/ext2_fs.h and ext2fs/ext2_fs.h.
@@ -2097,8 +2098,6 @@ tree_push(struct tree *t, const char *path, int filesystem_id,
struct tree_entry *te;
te = calloc(1, sizeof(*te));
if (te == NULL)
__archive_errx(1, "Out of memory");
te->next = t->stack;
te->parent = t->current;
if (te->parent)
@@ -450,9 +450,7 @@ lz4_filter_read_descriptor(struct archive_read_filter *self)
chsum = (chsum >> 8) & 0xff;
chsum_verifier = read_buf[descriptor_bytes-1] & 0xff;
if (chsum != chsum_verifier)
#ifndef DONT_FAIL_ON_CRC_ERROR
goto malformed_error;
#endif
__archive_read_filter_consume(self->upstream, descriptor_bytes);
@@ -523,9 +521,7 @@ lz4_filter_read_data_block(struct archive_read_filter *self, const void **p)
unsigned int chsum_block =
archive_le32dec(read_buf + 4 + compressed_size);
if (chsum != chsum_block)
#ifndef DONT_FAIL_ON_CRC_ERROR
goto malformed_error;
#endif
}
@@ -656,12 +652,10 @@ lz4_filter_read_default_stream(struct archive_read_filter *self, const void **p)
state->xxh32_state);
state->xxh32_state = NULL;
if (checksum != checksum_stream) {
#ifndef DONT_FAIL_ON_CRC_ERROR
archive_set_error(&self->archive->archive,
ARCHIVE_ERRNO_MISC,
"lz4 stream checksum error");
return (ARCHIVE_FATAL);
#endif
}
} else if (ret > 0)
__archive_xxhash.XXH32_update(state->xxh32_state,
@@ -283,9 +283,7 @@ consume_header(struct archive_read_filter *self)
else
checksum = adler32(adler32(0, NULL, 0), p, len);
if (archive_be32dec(p + len) != checksum)
#ifndef DONT_FAIL_ON_CRC_ERROR
goto corrupted;
#endif
__archive_read_filter_consume(self->upstream, len + 4);
if (flags & EXTRA_FIELD) {
/* Skip extra field */
@@ -612,11 +612,9 @@ lzip_tail(struct archive_read_filter *self)
/* Check the crc32 value of the uncompressed data of the current
* member */
if (state->crc32 != archive_le32dec(f)) {
#ifndef DONT_FAIL_ON_CRC_ERROR
archive_set_error(&self->archive->archive, ARCHIVE_ERRNO_MISC,
"Lzip: CRC32 error");
return (ARCHIVE_FAILED);
#endif
}
/* Check the uncompressed size of the current member */
@@ -776,7 +776,7 @@ archive_read_format_7zip_read_header(struct archive_read *a,
}
/* Set up a more descriptive format name. */
snprintf(zip->format_name, sizeof(zip->format_name), "7-Zip");
sprintf(zip->format_name, "7-Zip");
a->archive.archive_format_name = zip->format_name;
return (ret);
@@ -2857,10 +2857,8 @@ slurp_central_directory(struct archive_read *a, struct _7zip *zip,
/* CRC check. */
if (crc32(0, (const unsigned char *)p + 12, 20)
!= archive_le32dec(p + 8)) {
#ifdef DONT_FAIL_ON_CRC_ERROR
archive_set_error(&a->archive, -1, "Header CRC error");
return (ARCHIVE_FATAL);
#endif
}
next_header_offset = archive_le64dec(p + 12);
@@ -2910,10 +2908,8 @@ slurp_central_directory(struct archive_read *a, struct _7zip *zip,
/* Check the EncodedHeader CRC.*/
if (r == 0 && zip->header_crc32 != next_header_crc) {
archive_set_error(&a->archive, -1,
#ifndef DONT_FAIL_ON_CRC_ERROR
"Damaged 7-Zip archive");
r = -1;
#endif
}
if (r == 0) {
if (zip->si.ci.folders[0].digest_defined)
@@ -2964,11 +2960,9 @@ slurp_central_directory(struct archive_read *a, struct _7zip *zip,
/* Check the Header CRC.*/
if (check_header_crc && zip->header_crc32 != next_header_crc) {
#ifndef DONT_FAIL_ON_CRC_ERROR
archive_set_error(&a->archive, -1,
"Malformed 7-Zip archive");
return (ARCHIVE_FATAL);
#endif
}
break;
default:
@@ -996,7 +996,7 @@ archive_read_format_cab_read_header(struct archive_read *a,
cab->end_of_entry_cleanup = cab->end_of_entry = 1;
/* Set up a more descriptive format name. */
snprintf(cab->format_name, sizeof(cab->format_name), "CAB %d.%d (%s)",
sprintf(cab->format_name, "CAB %d.%d (%s)",
hd->major, hd->minor, cab->entry_cffolder->compname);
a->archive.archive_format_name = cab->format_name;
@@ -1134,7 +1134,7 @@ cab_checksum_update(struct archive_read *a, size_t bytes)
}
if (sumbytes) {
int odd = sumbytes & 3;
if ((int)(sumbytes - odd) > 0)
if (sumbytes - odd > 0)
cfdata->sum_calculated = cab_checksum_cfdata_4(
p, sumbytes - odd, cfdata->sum_calculated);
if (odd)
@@ -1171,14 +1171,12 @@ cab_checksum_finish(struct archive_read *a)
cfdata->sum_calculated = cab_checksum_cfdata(
cfdata->memimage + CFDATA_cbData, l, cfdata->sum_calculated);
if (cfdata->sum_calculated != cfdata->sum) {
#ifndef DONT_FAIL_ON_CRC_ERROR
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Checksum error CFDATA[%d] %" PRIx32 ":%" PRIx32 " in %d bytes",
cab->entry_cffolder->cfdata_index -1,
cfdata->sum, cfdata->sum_calculated,
cfdata->compressed_size);
return (ARCHIVE_FAILED);
#endif
}
return (ARCHIVE_OK);
}
@@ -1756,7 +1756,7 @@ parse_file_info(struct archive_read *a, struct file_info *parent,
size_t name_len;
const unsigned char *rr_start, *rr_end;
const unsigned char *p;
size_t dr_len = 0;
size_t dr_len;
uint64_t fsize, offset;
int32_t location;
int flags;
@@ -739,7 +739,7 @@ archive_read_format_lha_read_header(struct archive_read *a,
if (lha->directory || lha->compsize == 0)
lha->end_of_entry = 1;
snprintf(lha->format_name, sizeof(lha->format_name), "lha -%c%c%c-",
sprintf(lha->format_name, "lha -%c%c%c-",
lha->method[0], lha->method[1], lha->method[2]);
a->archive.archive_format_name = lha->format_name;
@@ -1039,11 +1039,9 @@ lha_read_file_header_2(struct archive_read *a, struct lha *lha)
}
if (header_crc != lha->header_crc) {
#ifndef DONT_FAIL_ON_CRC_ERROR
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"LHa header CRC error");
return (ARCHIVE_FATAL);
#endif
}
return (err);
}
@@ -1109,11 +1107,9 @@ lha_read_file_header_3(struct archive_read *a, struct lha *lha)
return (err);
if (header_crc != lha->header_crc) {
#ifndef DONT_FAIL_ON_CRC_ERROR
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"LHa header CRC error");
return (ARCHIVE_FATAL);
#endif
}
return (err);
invalid:
@@ -997,11 +997,9 @@ process_add_entry(struct archive_read *a, struct mtree *mtree,
struct mtree_entry *alt;
alt = (struct mtree_entry *)__archive_rb_tree_find_node(
&mtree->rbtree, entry->name);
if (alt != NULL) {
while (alt->next_dup)
alt = alt->next_dup;
alt->next_dup = entry;
}
while (alt->next_dup)
alt = alt->next_dup;
alt->next_dup = entry;
}
}
@@ -1076,7 +1074,7 @@ read_mtree(struct archive_read *a, struct mtree *mtree)
continue;
/* Non-printable characters are not allowed */
for (s = p;s < p + len - 1; s++) {
if (!isprint((unsigned char)*s) && *s != '\t') {
if (!isprint((unsigned char)*s)) {
r = ARCHIVE_FATAL;
break;
}
@@ -1255,17 +1253,9 @@ parse_file(struct archive_read *a, struct archive_entry *entry,
archive_entry_filetype(entry) == AE_IFDIR) {
mtree->fd = open(path, O_RDONLY | O_BINARY | O_CLOEXEC);
__archive_ensure_cloexec_flag(mtree->fd);
if (mtree->fd == -1 && (
#if defined(_WIN32) && !defined(__CYGWIN__)
/*
* On Windows, attempting to open a file with an
* invalid name result in EINVAL (Error 22)
*/
(errno != ENOENT && errno != EINVAL)
#else
errno != ENOENT
#endif
|| archive_strlen(&mtree->contents_name) > 0)) {
if (mtree->fd == -1 &&
(errno != ENOENT ||
archive_strlen(&mtree->contents_name) > 0)) {
archive_set_error(&a->archive, errno,
"Can't open %s", path);
r = ARCHIVE_WARN;
@@ -1007,11 +1007,9 @@ archive_read_format_rar_read_header(struct archive_read *a,
crc32_val = crc32(0, (const unsigned char *)p + 2, (unsigned)skip - 2);
if ((crc32_val & 0xffff) != archive_le16dec(p)) {
#ifndef DONT_FAIL_ON_CRC_ERROR
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Header CRC error");
return (ARCHIVE_FATAL);
#endif
}
__archive_read_consume(a, skip);
break;
@@ -1067,11 +1065,9 @@ archive_read_format_rar_read_header(struct archive_read *a,
skip -= to_read;
}
if ((crc32_val & 0xffff) != crc32_expected) {
#ifndef DONT_FAIL_ON_CRC_ERROR
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Header CRC error");
return (ARCHIVE_FATAL);
#endif
}
if (head_type == ENDARC_HEAD)
return (ARCHIVE_EOF);
@@ -1436,11 +1432,9 @@ read_header(struct archive_read *a, struct archive_entry *entry,
/* File Header CRC check. */
crc32_val = crc32(crc32_val, h, (unsigned)(header_size - 7));
if ((crc32_val & 0xffff) != archive_le16dec(rar_header.crc)) {
#ifndef DONT_FAIL_ON_CRC_ERROR
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Header CRC error");
return (ARCHIVE_FATAL);
#endif
}
/* If no CRC error, Go on parsing File Header. */
p = h;
@@ -1958,11 +1952,9 @@ read_data_stored(struct archive_read *a, const void **buff, size_t *size,
*size = 0;
*offset = rar->offset;
if (rar->file_crc != rar->crc_calculated) {
#ifndef DONT_FAIL_ON_CRC_ERROR
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"File CRC error");
return (ARCHIVE_FATAL);
#endif
}
rar->entry_eof = 1;
return (ARCHIVE_EOF);
@@ -2053,11 +2045,9 @@ read_data_compressed(struct archive_read *a, const void **buff, size_t *size,
*size = 0;
*offset = rar->offset;
if (rar->file_crc != rar->crc_calculated) {
#ifndef DONT_FAIL_ON_CRC_ERROR
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"File CRC error");
return (ARCHIVE_FATAL);
#endif
}
rar->entry_eof = 1;
return (ARCHIVE_EOF);
@@ -2821,13 +2821,11 @@ static int parse_block_header(struct archive_read* a, const uint8_t* p,
^ (uint8_t) (*block_size >> 16);
if(calculated_cksum != hdr->block_cksum) {
#ifndef DONT_FAIL_ON_CRC_ERROR
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Block checksum error: got 0x%x, expected 0x%x",
hdr->block_cksum, calculated_cksum);
return ARCHIVE_FATAL;
#endif
}
return ARCHIVE_OK;
@@ -3913,13 +3911,6 @@ static int do_unpack(struct archive_read* a, struct rar5* rar,
case GOOD:
/* fallthrough */
case BEST:
/* No data is returned here. But because a sparse-file aware
* caller (like archive_read_data_into_fd) may treat zero-size
* as a sparse file block, we need to update the offset
* accordingly. At this point the decoder doesn't have any
* pending uncompressed data blocks, so the current position in
* the output file should be last_write_ptr. */
if (offset) *offset = rar->cstate.last_write_ptr;
return uncompress_file(a);
default:
archive_set_error(&a->archive,
@@ -407,13 +407,14 @@ archive_read_format_tar_bid(struct archive_read *a, int best_bid)
/*
* Check format of mode/uid/gid/mtime/size/rdevmajor/rdevminor fields.
*/
if (validate_number_field(header->mode, sizeof(header->mode)) == 0
if (bid > 0 && (
validate_number_field(header->mode, sizeof(header->mode)) == 0
|| validate_number_field(header->uid, sizeof(header->uid)) == 0
|| validate_number_field(header->gid, sizeof(header->gid)) == 0
|| validate_number_field(header->mtime, sizeof(header->mtime)) == 0
|| validate_number_field(header->size, sizeof(header->size)) == 0
|| validate_number_field(header->rdevmajor, sizeof(header->rdevmajor)) == 0
|| validate_number_field(header->rdevminor, sizeof(header->rdevminor)) == 0) {
|| validate_number_field(header->rdevminor, sizeof(header->rdevminor)) == 0)) {
bid = 0;
}
@@ -2109,21 +2110,6 @@ pax_attribute(struct archive_read *a, struct tar *tar,
/* "size" is the size of the data in the entry. */
tar->entry_bytes_remaining
= tar_atol10(value, strlen(value));
if (tar->entry_bytes_remaining < 0) {
tar->entry_bytes_remaining = 0;
archive_set_error(&a->archive,
ARCHIVE_ERRNO_MISC,
"Tar size attribute is negative");
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 size attribute overflow");
return (ARCHIVE_FATAL);
}
/*
* The "size" pax header keyword always overrides the
* "size" field in the tar header.
@@ -624,9 +624,7 @@ read_toc(struct archive_read *a)
__archive_read_consume(a, xar->toc_chksum_size);
xar->offset += xar->toc_chksum_size;
if (r != ARCHIVE_OK)
#ifndef DONT_FAIL_ON_CRC_ERROR
return (ARCHIVE_FATAL);
#endif
}
/*
@@ -829,12 +827,10 @@ xar_read_header(struct archive_read *a, struct archive_entry *entry)
xattr->a_sum.val, xattr->a_sum.len,
xattr->e_sum.val, xattr->e_sum.len);
if (r != ARCHIVE_OK) {
#ifndef DONT_FAIL_ON_CRC_ERROR
archive_set_error(&(a->archive), ARCHIVE_ERRNO_MISC,
"Xattr checksum error");
r = ARCHIVE_WARN;
break;
#endif
}
if (xattr->name.s == NULL) {
archive_set_error(&(a->archive), ARCHIVE_ERRNO_MISC,
@@ -3988,10 +3988,10 @@ int
archive_mstring_get_mbs_l(struct archive *a, struct archive_mstring *aes,
const char **p, size_t *length, struct archive_string_conv *sc)
{
int ret = 0;
#if defined(_WIN32) && !defined(__CYGWIN__)
int r;
int r, ret = 0;
(void)r; /* UNUSED */
#if defined(_WIN32) && !defined(__CYGWIN__)
/*
* Internationalization programming on Windows must use Wide
* characters because Windows platform cannot make locale UTF-8.
@@ -201,10 +201,6 @@ __archive_write_allocate_filter(struct archive *_a)
struct archive_write_filter *f;
f = calloc(1, sizeof(*f));
if (f == NULL)
return (NULL);
f->archive = _a;
f->state = ARCHIVE_WRITE_FILTER_STATE_NEW;
if (a->filter_first == NULL)
@@ -552,10 +548,6 @@ archive_write_open2(struct archive *_a, void *client_data,
a->client_data = client_data;
client_filter = __archive_write_allocate_filter(_a);
if (client_filter == NULL)
return (ARCHIVE_FATAL);
client_filter->open = archive_write_client_open;
client_filter->write = archive_write_client_write;
client_filter->close = archive_write_client_close;
@@ -1996,8 +1996,6 @@ archive_write_disk_new(void)
free(a);
return (NULL);
}
a->path_safe.s[0] = 0;
#ifdef HAVE_ZLIB_H
a->decmpfs_compression_level = 5;
#endif
@@ -2795,7 +2793,7 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
char *tail;
char *head;
int last;
char c = '\0';
char c;
int r;
struct stat st;
int chdir_fd;
@@ -218,7 +218,6 @@ On failure, the callback should invoke
.Fn archive_set_error
to register an error code and message and
return
.Cm ARCHIVE_FATAL .
.Bl -item -offset indent
.It
.Ft typedef int
@@ -165,7 +165,7 @@ struct file {
mode_t mode;
uint32_t crc32;
unsigned int dir:1;
signed int dir:1;
};
struct _7zip {
@@ -289,12 +289,12 @@ struct isoent {
struct extr_rec *current;
} extr_rec_list;
unsigned int virtual:1;
signed int virtual:1;
/* If set to one, this file type is a directory.
* A convenience flag to be used as
* "archive_entry_filetype(isoent->file->entry) == AE_IFDIR".
*/
unsigned int dir:1;
signed int dir:1;
};
struct hardlink {
@@ -755,9 +755,9 @@ struct iso9660 {
/* Used for making zisofs. */
struct {
unsigned int detect_magic:1;
unsigned int making:1;
unsigned int allzero:1;
signed int detect_magic:1;
signed int making:1;
signed int allzero:1;
unsigned char magic_buffer[64];
int magic_cnt;
@@ -7802,8 +7802,8 @@ struct zisofs_extract {
uint64_t pz_uncompressed_size;
size_t uncompressed_buffer_size;
unsigned int initialized:1;
unsigned int header_passed:1;
signed int initialized:1;
signed int header_passed:1;
uint32_t pz_offset;
unsigned char *block_pointers;
@@ -367,12 +367,10 @@ archive_write_pax_header_xattr(struct pax *pax, const char *encoded_name,
struct archive_string s;
char *encoded_value;
if (encoded_name == NULL)
return;
if (pax->flags & WRITE_LIBARCHIVE_XATTR) {
encoded_value = base64_encode((const char *)value, value_len);
if (encoded_value != NULL) {
if (encoded_name != NULL && encoded_value != NULL) {
archive_string_init(&s);
archive_strcpy(&s, "LIBARCHIVE.xattr.");
archive_strcat(&s, encoded_name);
@@ -405,22 +403,17 @@ archive_write_pax_header_xattrs(struct archive_write *a,
archive_entry_xattr_next(entry, &name, &value, &size);
url_encoded_name = url_encode(name);
if (url_encoded_name == NULL)
goto malloc_error;
else {
if (url_encoded_name != NULL) {
/* Convert narrow-character to UTF-8. */
r = archive_strcpy_l(&(pax->l_url_encoded_name),
url_encoded_name, pax->sconv_utf8);
free(url_encoded_name); /* Done with this. */
if (r == 0)
encoded_name = pax->l_url_encoded_name.s;
else if (r == -1)
goto malloc_error;
else {
archive_set_error(&a->archive,
ARCHIVE_ERRNO_MISC,
"Error encoding pax extended attribute");
return (ARCHIVE_FAILED);
else if (errno == ENOMEM) {
archive_set_error(&a->archive, ENOMEM,
"Can't allocate memory for Linkname");
return (ARCHIVE_FATAL);
}
}
@@ -429,9 +422,6 @@ archive_write_pax_header_xattrs(struct archive_write *a,
}
return (ARCHIVE_OK);
malloc_error:
archive_set_error(&a->archive, ENOMEM, "Can't allocate memory");
return (ARCHIVE_FATAL);
}
static int
@@ -1727,7 +1717,7 @@ build_pax_attribute_name(char *dest, const char *src)
* to having clients override it.
*/
#if HAVE_GETPID && 0 /* Disable this for now; see above comment. */
snprintf(buff, sizeof(buff), "PaxHeader.%d", getpid());
sprintf(buff, "PaxHeader.%d", getpid());
#else
/* If the platform can't fetch the pid, don't include it. */
strcpy(buff, "PaxHeader");
@@ -1914,19 +1904,14 @@ url_encode(const char *in)
{
const char *s;
char *d;
size_t out_len = 0;
int out_len = 0;
char *out;
for (s = in; *s != '\0'; s++) {
if (*s < 33 || *s > 126 || *s == '%' || *s == '=') {
if (SIZE_MAX - out_len < 4)
return (NULL);
if (*s < 33 || *s > 126 || *s == '%' || *s == '=')
out_len += 3;
} else {
if (SIZE_MAX - out_len < 2)
return (NULL);
else
out_len++;
}
}
out = (char *)malloc(out_len + 1);
@@ -212,8 +212,8 @@ struct file {
struct heap_data data;
struct archive_string script;
unsigned int virtual:1;
unsigned int dir:1;
signed int virtual:1;
signed int dir:1;
};
struct hardlink {
@@ -76,7 +76,7 @@ int
__archive_create_child(const char *cmd, int *child_stdin, int *child_stdout,
pid_t *out_child)
{
pid_t child = -1;
pid_t child;
int stdin_pipe[2], stdout_pipe[2], tmp;
#if HAVE_POSIX_SPAWNP
posix_spawn_file_actions_t actions;
@@ -907,7 +907,7 @@ DEFINE_TEST(test_acl_platform_nfs4)
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
for (i = 0; i < acls_dir_cnt; ++i) {
snprintf(buff, sizeof(buff), "dir%d", i);
sprintf(buff, "dir%d", i);
archive_entry_set_pathname(ae, buff);
archive_entry_set_filetype(ae, AE_IFDIR);
archive_entry_set_perm(ae, 0654);
@@ -960,7 +960,7 @@ DEFINE_TEST(test_acl_platform_nfs4)
/* Verify single-permission dirs on disk. */
for (i = 0; i < dircnt; ++i) {
snprintf(buff, sizeof(buff), "dir%d", i);
sprintf(buff, "dir%d", i);
assertEqualInt(0, stat(buff, &st));
assertEqualInt(st.st_mtime, 123456 + i);
#if ARCHIVE_ACL_SUNOS_NFS4
@@ -32,7 +32,7 @@ DEFINE_TEST(test_archive_api_feature)
/* This is the (hopefully) final versioning API. */
assertEqualInt(ARCHIVE_VERSION_NUMBER, archive_version_number());
snprintf(buff, sizeof(buff), "libarchive %d.%d.%d",
sprintf(buff, "libarchive %d.%d.%d",
archive_version_number() / 1000000,
(archive_version_number() / 1000) % 1000,
archive_version_number() % 1000);
@@ -321,11 +321,6 @@ test_newer_ctime_than_file_mbs(void)
struct archive_entry *ae;
struct archive *m;
#if defined(_WIN32) && !defined(__CYGWIN__)
skipping("Can't set ctime on Windows");
return;
#endif
if (!assert((m = archive_match_new()) != NULL))
return;
if (!assert((ae = archive_entry_new()) != NULL)) {
@@ -440,11 +435,6 @@ test_newer_ctime_than_file_wcs(void)
struct archive_entry *ae;
struct archive *m;
#if defined(_WIN32) && !defined(__CYGWIN__)
skipping("Can't set ctime on Windows");
return;
#endif
if (!assert((m = archive_match_new()) != NULL))
return;
if (!assert((ae = archive_entry_new()) != NULL)) {
@@ -792,11 +782,6 @@ test_older_ctime_than_file_mbs(void)
struct archive_entry *ae;
struct archive *m;
#if defined(_WIN32) && !defined(__CYGWIN__)
skipping("Can't set ctime on Windows");
return;
#endif
if (!assert((m = archive_match_new()) != NULL))
return;
if (!assert((ae = archive_entry_new()) != NULL)) {
@@ -912,11 +897,6 @@ test_older_ctime_than_file_wcs(void)
struct archive_entry *ae;
struct archive *m;
#if defined(_WIN32) && !defined(__CYGWIN__)
skipping("Can't set ctime on Windows");
return;
#endif
if (!assert((m = archive_match_new()) != NULL))
return;
if (!assert((ae = archive_entry_new()) != NULL)) {
@@ -1093,11 +1073,6 @@ test_ctime_between_files_mbs(void)
struct archive_entry *ae;
struct archive *m;
#if defined(_WIN32) && !defined(__CYGWIN__)
skipping("Can't set ctime on Windows");
return;
#endif
if (!assert((m = archive_match_new()) != NULL))
return;
if (!assert((ae = archive_entry_new()) != NULL)) {
@@ -1157,11 +1132,6 @@ test_ctime_between_files_wcs(void)
struct archive_entry *ae;
struct archive *m;
#if defined(_WIN32) && !defined(__CYGWIN__)
skipping("Can't set ctime on Windows");
return;
#endif
if (!assert((m = archive_match_new()) != NULL))
return;
if (!assert((ae = archive_entry_new()) != NULL)) {
@@ -847,7 +847,6 @@ test_archive_string_set_get(void)
assertEqualInt(0, archive_mstring_update_utf8(a, &mstr, "EEEEE---H"));
check_string(a, &mstr, sc, "EEEEE---H", L"EEEEE---H");
archive_mstring_clean(&mstr);
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
}
@@ -789,7 +789,6 @@ DEFINE_TEST(test_read_format_mtree_nonexistent_contents_file)
assertEqualInt(ARCHIVE_OK, archive_read_close(a));
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
}
/*
* Check mtree file with non-printable ascii characters
*/
@@ -815,32 +814,3 @@ DEFINE_TEST(test_read_format_mtree_noprint)
assertEqualInt(ARCHIVE_OK, archive_read_close(a));
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
}
/*
* Check mtree file with tab characters, which are supported but not printable
*/
DEFINE_TEST(test_read_format_mtree_tab)
{
static char archive[] =
"#mtree\n"
"\ta\ttype=file\n";
struct archive_entry *ae;
struct archive *a;
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK,
archive_read_support_filter_all(a));
assertEqualIntA(a, ARCHIVE_OK,
archive_read_support_format_all(a));
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, archive, sizeof(archive)));
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString(archive_entry_pathname(ae), "a");
assertEqualInt(archive_entry_filetype(ae), AE_IFREG);
assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
assertEqualInt(1, archive_file_count(a));
assertEqualInt(ARCHIVE_OK, archive_read_close(a));
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
}
@@ -168,7 +168,7 @@ DEFINE_TEST(test_read_format_rar5_compressed)
assertEqualInt(DATA_SIZE, archive_entry_size(ae));
assertA(DATA_SIZE == archive_read_data(a, buff, DATA_SIZE));
assertA(ARCHIVE_EOF == archive_read_next_header(a, &ae));
assertA(1 == verify_data(buff, 0, DATA_SIZE));
verify_data(buff, 0, DATA_SIZE);
EPILOGUE();
}
@@ -187,25 +187,25 @@ DEFINE_TEST(test_read_format_rar5_multiple_files)
assertEqualString("test1.bin", archive_entry_pathname(ae));
assertEqualInt(DATA_SIZE, archive_entry_size(ae));
assertA(DATA_SIZE == archive_read_data(a, buff, DATA_SIZE));
assertA(1 == verify_data(buff, 1, DATA_SIZE));
assertA(verify_data(buff, 1, DATA_SIZE));
assertA(0 == archive_read_next_header(a, &ae));
assertEqualString("test2.bin", archive_entry_pathname(ae));
assertEqualInt(DATA_SIZE, archive_entry_size(ae));
assertA(DATA_SIZE == archive_read_data(a, buff, DATA_SIZE));
assertA(1 == verify_data(buff, 2, DATA_SIZE));
assertA(verify_data(buff, 2, DATA_SIZE));
assertA(0 == archive_read_next_header(a, &ae));
assertEqualString("test3.bin", archive_entry_pathname(ae));
assertEqualInt(DATA_SIZE, archive_entry_size(ae));
assertA(DATA_SIZE == archive_read_data(a, buff, DATA_SIZE));
assertA(1 == verify_data(buff, 3, DATA_SIZE));
assertA(verify_data(buff, 3, DATA_SIZE));
assertA(0 == archive_read_next_header(a, &ae));
assertEqualString("test4.bin", archive_entry_pathname(ae));
assertEqualInt(DATA_SIZE, archive_entry_size(ae));
assertA(DATA_SIZE == archive_read_data(a, buff, DATA_SIZE));
assertA(1 == verify_data(buff, 4, DATA_SIZE));
assertA(verify_data(buff, 4, DATA_SIZE));
/* There should be no more files in this archive. */
@@ -230,25 +230,25 @@ DEFINE_TEST(test_read_format_rar5_multiple_files_solid)
assertEqualString("test1.bin", archive_entry_pathname(ae));
assertEqualInt(DATA_SIZE, archive_entry_size(ae));
assertA(DATA_SIZE == archive_read_data(a, buff, DATA_SIZE));
assertA(1 == verify_data(buff, 1, DATA_SIZE));
assertA(verify_data(buff, 1, DATA_SIZE));
assertA(0 == archive_read_next_header(a, &ae));
assertEqualString("test2.bin", archive_entry_pathname(ae));
assertEqualInt(DATA_SIZE, archive_entry_size(ae));
assertA(DATA_SIZE == archive_read_data(a, buff, DATA_SIZE));
assertA(1 == verify_data(buff, 2, DATA_SIZE));
assertA(verify_data(buff, 2, DATA_SIZE));
assertA(0 == archive_read_next_header(a, &ae));
assertEqualString("test3.bin", archive_entry_pathname(ae));
assertEqualInt(DATA_SIZE, archive_entry_size(ae));
assertA(DATA_SIZE == archive_read_data(a, buff, DATA_SIZE));
assertA(1 == verify_data(buff, 3, DATA_SIZE));
assertA(verify_data(buff, 3, DATA_SIZE));
assertA(0 == archive_read_next_header(a, &ae));
assertEqualString("test4.bin", archive_entry_pathname(ae));
assertEqualInt(DATA_SIZE, archive_entry_size(ae));
assertA(DATA_SIZE == archive_read_data(a, buff, DATA_SIZE));
assertA(1 == verify_data(buff, 4, DATA_SIZE));
assertA(verify_data(buff, 4, DATA_SIZE));
assertA(ARCHIVE_EOF == archive_read_next_header(a, &ae));
EPILOGUE();
@@ -1346,27 +1346,4 @@ DEFINE_TEST(test_read_format_rar5_bad_window_size_in_multiarchive_file)
while(0 < archive_read_data(a, buf, sizeof(buf))) {}
EPILOGUE();
}
DEFINE_TEST(test_read_format_rar5_read_data_block_uninitialized_offset)
{
const void *buf;
size_t size;
la_int64_t offset;
PROLOGUE("test_read_format_rar5_compressed.rar");
assertA(0 == archive_read_next_header(a, &ae));
/* A real code may pass a pointer to an uninitialized variable as an offset
* output argument. Here we want to check this situation. But because
* relying on a value of an uninitialized variable in a test is not a good
* idea, let's pretend that 0xdeadbeef is a random value of the
* uninitialized variable. */
offset = 0xdeadbeef;
assertEqualInt(ARCHIVE_OK, archive_read_data_block(a, &buf, &size, &offset));
/* The test archive doesn't contain a sparse file. And because of that, here
* we assume that the first returned offset should be 0. */
assertEqualInt(0, offset);
EPILOGUE();
}
}
@@ -1,53 +0,0 @@
/*-
* Copyright (c) 2020 Ben Wagner
* 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$");
/*
* The pax size attribute can be used to override the size.
* It should be validated the same way the normal size is validated.
* The test data is fuzzer output from
* https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=48467 .
*/
DEFINE_TEST(test_read_format_tar_invalid_pax_size)
{
/*
* An archive that contains a PAX 'size' record with a large negative value.
*/
struct archive_entry *ae;
struct archive *a;
const char *refname = "test_read_format_tar_invalid_pax_size.tar";
extract_reference_file(refname);
assert((a = archive_read_new()) != NULL);
assertEqualInt(ARCHIVE_OK, archive_read_support_filter_all(a));
assertEqualInt(ARCHIVE_OK, archive_read_support_format_all(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_open_filename(a, refname, 10240));
/* This assert will pass a normal debug build without the pax size check. */
/* Run this test with `-fsanitize=undefined` to verify. */
assertEqualIntA(a, ARCHIVE_FATAL, archive_read_next_header(a, &ae));
assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
}
@@ -1,38 +0,0 @@
begin 644 test_read_format_tar_invalid_pax_size.tar.uu
M+B]087A(96%D97)S+C$T-#8S+V%A80``````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````#`P,#`V-#0`,#`P,#`P,``P,#`P,#`P`#`P,#`P,#`P,S$R
M`#$R-3,Q,30U,S<Q`"`Q,30R,"`@>```````````````````````````````
M````````````````````````````````````````````````````````````
M``````````````````````````````````````````!U='-A<@`P,```````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M```````````````````````S,"`@("`@(#T@("`@("`@("`@("`@("`@("`@
M(`HS,"`@("`@(#T@("`@("`@("`@("`@("`@("`@(`HS,"`@("`@("`]("`@
M("`@("`@("`@("`@("`@(`HS,"!S:7IE/2TQ.3<V.30Q,3$Q,S8U.3<R-S0S
M-@H@("`@("`@("`@_R`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@____("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@
M("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@("`@(&%A80``````````
M````````````````````````````````````````````````````````````
M```````````````````````````````````````````````````````````P
M,#,P.#$V`#`S-S0U,S0`,#`Q,38Q,``P,#`P,#`P,#`P-P`Q,C4S,3$T-3,W
M,``@,3(P-S$@(#$`````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````=7-T87(`,#!D=GEU:V]V````````````````````````````````96YG
M`````````````````````````/\!````````````````,#`Q`#`P,#`P,#`P
M,#`P````````````````````````````````````````````````````]P``
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
&````````
`
end
@@ -81,7 +81,7 @@ test_truncation(const char *compression,
archive_entry_set_filetype(ae, AE_IFREG);
archive_entry_set_size(ae, datasize);
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "%s%d", compression, i);
sprintf(path, "%s%d", compression, i);
archive_entry_copy_pathname(ae, path);
failure("%s", path);
if (!assertEqualIntA(a, ARCHIVE_OK,
@@ -123,7 +123,7 @@ test_truncation(const char *compression,
assert(NULL != archive_error_string(a));
break;
}
snprintf(path, sizeof(path), "%s%d", compression, i);
sprintf(path, "%s%d", compression, i);
assertEqualString(path, archive_entry_pathname(ae));
if (datasize != (size_t)archive_read_data(a, data, datasize)) {
failure("Should have non-NULL error message for %s",
@@ -253,10 +253,8 @@ is_sparse_supported(const char *path)
#if defined(HAVE_LINUX_FIEMAP_H)
if (r < 0)
return (is_sparse_supported_fiemap(path));
return (1);
#else
return (r >= 0);
#endif
return (r >= 0);
}
#elif !defined(HAVE_LINUX_FIEMAP_H)
@@ -224,7 +224,7 @@ DEFINE_TEST(test_tar_large)
*/
for (i = 0; tests[i] != 0; i++) {
assert((ae = archive_entry_new()) != NULL);
snprintf(namebuff, sizeof(namebuff), "file_%d", i);
sprintf(namebuff, "file_%d", i);
archive_entry_copy_pathname(ae, namebuff);
archive_entry_set_mode(ae, S_IFREG | 0755);
filesize = tests[i];
@@ -271,7 +271,7 @@ DEFINE_TEST(test_tar_large)
*/
for (i = 0; tests[i] > 0; i++) {
assertEqualIntA(a, 0, archive_read_next_header(a, &ae));
snprintf(namebuff, sizeof(namebuff), "file_%d", i);
sprintf(namebuff, "file_%d", i);
assertEqualString(namebuff, archive_entry_pathname(ae));
assert(tests[i] == archive_entry_size(ae));
}
@@ -75,7 +75,7 @@ DEFINE_TEST(test_write_disk_secure744)
archive_entry_free(ae);
*p++ = '/';
snprintf(p, buff_size - (p - buff), "target%d", n);
sprintf(p, "target%d", n);
/* Try to create a file through the symlink, should fail. */
assert((ae = archive_entry_new()) != NULL);
@@ -64,7 +64,7 @@ DEFINE_TEST(test_write_filter_b64encode)
assert((ae = archive_entry_new()) != NULL);
archive_entry_set_filetype(ae, AE_IFREG);
archive_entry_set_size(ae, datasize);
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
archive_entry_copy_pathname(ae, path);
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
assertA(datasize
@@ -79,7 +79,7 @@ DEFINE_TEST(test_write_filter_b64encode)
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used1));
for (i = 0; i < 99; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualIntA(a, 0, archive_read_next_header(a, &ae)))
break;
assertEqualString(path, archive_entry_pathname(ae));
@@ -111,7 +111,7 @@ DEFINE_TEST(test_write_filter_b64encode)
assertEqualIntA(a, ARCHIVE_OK,
archive_write_open_memory(a, buff, buffsize, &used2));
for (i = 0; i < 99; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, path);
archive_entry_set_size(ae, datasize);
@@ -128,7 +128,7 @@ DEFINE_TEST(test_write_filter_b64encode)
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used2));
for (i = 0; i < 99; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(0, archive_read_next_header(a, &ae)))
break;
assertEqualString(path, archive_entry_pathname(ae));
@@ -83,7 +83,7 @@ DEFINE_TEST(test_write_filter_bzip2)
archive_entry_set_filetype(ae, AE_IFREG);
archive_entry_set_size(ae, datasize);
for (i = 0; i < 999; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
archive_entry_copy_pathname(ae, path);
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
assertA(datasize
@@ -99,7 +99,7 @@ DEFINE_TEST(test_write_filter_bzip2)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used1));
for (i = 0; i < 999; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(0, archive_read_next_header(a, &ae)))
break;
assertEqualString(path, archive_entry_pathname(ae));
@@ -133,7 +133,7 @@ DEFINE_TEST(test_write_filter_bzip2)
assertEqualIntA(a, ARCHIVE_OK,
archive_write_open_memory(a, buff, buffsize, &used2));
for (i = 0; i < 999; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, path);
archive_entry_set_size(ae, datasize);
@@ -160,7 +160,7 @@ DEFINE_TEST(test_write_filter_bzip2)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used2));
for (i = 0; i < 999; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(0, archive_read_next_header(a, &ae)))
break;
assertEqualString(path, archive_entry_pathname(ae));
@@ -187,7 +187,7 @@ DEFINE_TEST(test_write_filter_bzip2)
assertEqualIntA(a, ARCHIVE_OK,
archive_write_open_memory(a, buff, buffsize, &used2));
for (i = 0; i < 999; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, path);
archive_entry_set_size(ae, datasize);
@@ -212,7 +212,7 @@ DEFINE_TEST(test_write_filter_bzip2)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used2));
for (i = 0; i < 999; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(0, archive_read_next_header(a, &ae)))
break;
assertEqualString(path, archive_entry_pathname(ae));
@@ -59,7 +59,7 @@ DEFINE_TEST(test_write_filter_compress)
archive_write_open_memory(a, buff, buffsize, &used));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, path);
archive_entry_set_size(ae, datasize);
@@ -83,7 +83,7 @@ DEFINE_TEST(test_write_filter_compress)
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(0, archive_read_next_header(a, &ae)))
break;
assertEqualString(path, archive_entry_pathname(ae));
@@ -85,7 +85,7 @@ DEFINE_TEST(test_write_filter_gzip)
archive_entry_set_filetype(ae, AE_IFREG);
archive_entry_set_size(ae, datasize);
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
archive_entry_copy_pathname(ae, path);
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
assertA(datasize
@@ -113,7 +113,7 @@ DEFINE_TEST(test_write_filter_gzip)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used1));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(ARCHIVE_OK,
archive_read_next_header(a, &ae)))
break;
@@ -148,7 +148,7 @@ DEFINE_TEST(test_write_filter_gzip)
archive_write_set_options(a, "gzip:compression-level=9"));
assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, path);
archive_entry_set_size(ae, datasize);
@@ -187,7 +187,7 @@ DEFINE_TEST(test_write_filter_gzip)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used2));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(ARCHIVE_OK,
archive_read_next_header(a, &ae)))
break;
@@ -212,7 +212,7 @@ DEFINE_TEST(test_write_filter_gzip)
assertEqualIntA(a, ARCHIVE_OK,
archive_write_open_memory(a, buff, buffsize, &used2));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, path);
archive_entry_set_size(ae, datasize);
@@ -249,7 +249,7 @@ DEFINE_TEST(test_write_filter_gzip)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used2));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(ARCHIVE_OK,
archive_read_next_header(a, &ae)))
break;
@@ -68,7 +68,7 @@ DEFINE_TEST(test_write_filter_lrzip)
archive_entry_set_filetype(ae, AE_IFREG);
archive_entry_set_size(ae, datasize);
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
archive_entry_copy_pathname(ae, path);
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
assertA(datasize
@@ -84,7 +84,7 @@ DEFINE_TEST(test_write_filter_lrzip)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used1));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(ARCHIVE_OK,
archive_read_next_header(a, &ae)))
break;
@@ -84,7 +84,7 @@ DEFINE_TEST(test_write_filter_lz4)
archive_entry_set_filetype(ae, AE_IFREG);
archive_entry_set_size(ae, datasize);
for (i = 0; i < filecount; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
archive_entry_copy_pathname(ae, path);
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
assertA(datasize
@@ -107,7 +107,7 @@ DEFINE_TEST(test_write_filter_lz4)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used1));
for (i = 0; i < filecount; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(ARCHIVE_OK,
archive_read_next_header(a, &ae)))
break;
@@ -142,7 +142,7 @@ DEFINE_TEST(test_write_filter_lz4)
assertEqualIntA(a, ARCHIVE_OK,
archive_write_open_memory(a, buff, buffsize, &used2));
for (i = 0; i < filecount; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, path);
archive_entry_set_size(ae, datasize);
@@ -170,7 +170,7 @@ DEFINE_TEST(test_write_filter_lz4)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used2));
for (i = 0; i < filecount; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(ARCHIVE_OK,
archive_read_next_header(a, &ae)))
break;
@@ -195,7 +195,7 @@ DEFINE_TEST(test_write_filter_lz4)
assertEqualIntA(a, ARCHIVE_OK,
archive_write_open_memory(a, buff, buffsize, &used2));
for (i = 0; i < filecount; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, path);
archive_entry_set_size(ae, datasize);
@@ -225,7 +225,7 @@ DEFINE_TEST(test_write_filter_lz4)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used2));
for (i = 0; i < filecount; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(ARCHIVE_OK,
archive_read_next_header(a, &ae)))
break;
@@ -330,7 +330,7 @@ test_options(const char *options)
archive_entry_set_filetype(ae, AE_IFREG);
archive_entry_set_size(ae, datasize);
for (i = 0; i < filecount; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
archive_entry_copy_pathname(ae, path);
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
assertA(datasize
@@ -350,7 +350,7 @@ test_options(const char *options)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used1));
for (i = 0; i < filecount; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(ARCHIVE_OK,
archive_read_next_header(a, &ae)))
break;
@@ -81,7 +81,7 @@ DEFINE_TEST(test_write_filter_lzip)
archive_entry_set_filetype(ae, AE_IFREG);
archive_entry_set_size(ae, datasize);
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
archive_entry_copy_pathname(ae, path);
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
assertA(datasize
@@ -103,7 +103,7 @@ DEFINE_TEST(test_write_filter_lzip)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used1));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(ARCHIVE_OK,
archive_read_next_header(a, &ae)))
break;
@@ -133,7 +133,7 @@ DEFINE_TEST(test_write_filter_lzip)
archive_write_set_filter_option(a, NULL, "compression-level", "9"));
assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, path);
archive_entry_set_size(ae, datasize);
@@ -157,7 +157,7 @@ DEFINE_TEST(test_write_filter_lzip)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used2));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
failure("Trying to read %s", path);
if (!assertEqualIntA(a, ARCHIVE_OK,
archive_read_next_header(a, &ae)))
@@ -181,7 +181,7 @@ DEFINE_TEST(test_write_filter_lzip)
archive_write_set_filter_option(a, NULL, "compression-level", "0"));
assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, path);
archive_entry_set_size(ae, datasize);
@@ -210,7 +210,7 @@ DEFINE_TEST(test_write_filter_lzip)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used2));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(ARCHIVE_OK,
archive_read_next_header(a, &ae)))
break;
@@ -80,7 +80,7 @@ DEFINE_TEST(test_write_filter_lzma)
archive_entry_set_filetype(ae, AE_IFREG);
archive_entry_set_size(ae, datasize);
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
archive_entry_copy_pathname(ae, path);
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
assertA(datasize
@@ -102,7 +102,7 @@ DEFINE_TEST(test_write_filter_lzma)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used1));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(ARCHIVE_OK,
archive_read_next_header(a, &ae)))
break;
@@ -132,7 +132,7 @@ DEFINE_TEST(test_write_filter_lzma)
archive_write_set_filter_option(a, NULL, "compression-level", "9"));
assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, path);
archive_entry_set_size(ae, datasize);
@@ -156,7 +156,7 @@ DEFINE_TEST(test_write_filter_lzma)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used2));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
failure("Trying to read %s", path);
if (!assertEqualIntA(a, ARCHIVE_OK,
archive_read_next_header(a, &ae)))
@@ -180,7 +180,7 @@ DEFINE_TEST(test_write_filter_lzma)
archive_write_set_filter_option(a, NULL, "compression-level", "0"));
assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, path);
archive_entry_set_size(ae, datasize);
@@ -214,7 +214,7 @@ DEFINE_TEST(test_write_filter_lzma)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used2));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(ARCHIVE_OK,
archive_read_next_header(a, &ae)))
break;
@@ -79,7 +79,7 @@ DEFINE_TEST(test_write_filter_lzop)
archive_entry_set_filetype(ae, AE_IFREG);
archive_entry_set_size(ae, datasize);
for (i = 0; i < filecount; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
archive_entry_copy_pathname(ae, path);
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
assertA(datasize
@@ -99,7 +99,7 @@ DEFINE_TEST(test_write_filter_lzop)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used1));
for (i = 0; i < filecount; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(ARCHIVE_OK,
archive_read_next_header(a, &ae)))
break;
@@ -135,7 +135,7 @@ DEFINE_TEST(test_write_filter_lzop)
assertEqualIntA(a, ARCHIVE_OK,
archive_write_open_memory(a, buff, buffsize, &used2));
for (i = 0; i < filecount; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, path);
archive_entry_set_size(ae, datasize);
@@ -163,7 +163,7 @@ DEFINE_TEST(test_write_filter_lzop)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used2));
for (i = 0; i < filecount; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(ARCHIVE_OK,
archive_read_next_header(a, &ae)))
break;
@@ -188,7 +188,7 @@ DEFINE_TEST(test_write_filter_lzop)
assertEqualIntA(a, ARCHIVE_OK,
archive_write_open_memory(a, buff, buffsize, &used2));
for (i = 0; i < filecount; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, path);
archive_entry_set_size(ae, datasize);
@@ -218,7 +218,7 @@ DEFINE_TEST(test_write_filter_lzop)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used2));
for (i = 0; i < filecount; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(ARCHIVE_OK,
archive_read_next_header(a, &ae)))
break;
@@ -64,7 +64,7 @@ DEFINE_TEST(test_write_filter_uuencode)
assert((ae = archive_entry_new()) != NULL);
archive_entry_set_filetype(ae, AE_IFREG);
archive_entry_set_size(ae, datasize);
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
archive_entry_copy_pathname(ae, path);
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
assertA(datasize
@@ -79,7 +79,7 @@ DEFINE_TEST(test_write_filter_uuencode)
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used1));
for (i = 0; i < 99; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualIntA(a, 0, archive_read_next_header(a, &ae)))
break;
assertEqualString(path, archive_entry_pathname(ae));
@@ -111,7 +111,7 @@ DEFINE_TEST(test_write_filter_uuencode)
assertEqualIntA(a, ARCHIVE_OK,
archive_write_open_memory(a, buff, buffsize, &used2));
for (i = 0; i < 99; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, path);
archive_entry_set_size(ae, datasize);
@@ -128,7 +128,7 @@ DEFINE_TEST(test_write_filter_uuencode)
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_open_memory(a, buff, used2));
for (i = 0; i < 99; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(0, archive_read_next_header(a, &ae)))
break;
assertEqualString(path, archive_entry_pathname(ae));
@@ -80,7 +80,7 @@ DEFINE_TEST(test_write_filter_xz)
archive_entry_set_filetype(ae, AE_IFREG);
archive_entry_set_size(ae, datasize);
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
archive_entry_copy_pathname(ae, path);
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
assertA(datasize
@@ -102,7 +102,7 @@ DEFINE_TEST(test_write_filter_xz)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used1));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(ARCHIVE_OK,
archive_read_next_header(a, &ae)))
break;
@@ -132,7 +132,7 @@ DEFINE_TEST(test_write_filter_xz)
archive_write_set_filter_option(a, NULL, "compression-level", "9"));
assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, path);
archive_entry_set_size(ae, datasize);
@@ -163,7 +163,7 @@ DEFINE_TEST(test_write_filter_xz)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used2));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
failure("Trying to read %s", path);
if (!assertEqualIntA(a, ARCHIVE_OK,
archive_read_next_header(a, &ae)))
@@ -187,7 +187,7 @@ DEFINE_TEST(test_write_filter_xz)
archive_write_set_filter_option(a, NULL, "compression-level", "0"));
assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, path);
archive_entry_set_size(ae, datasize);
@@ -220,7 +220,7 @@ DEFINE_TEST(test_write_filter_xz)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used2));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(ARCHIVE_OK,
archive_read_next_header(a, &ae)))
break;
@@ -74,7 +74,7 @@ DEFINE_TEST(test_write_filter_zstd)
archive_entry_set_filetype(ae, AE_IFREG);
archive_entry_set_size(ae, datasize);
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
archive_entry_copy_pathname(ae, path);
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
assertA(datasize
@@ -96,7 +96,7 @@ DEFINE_TEST(test_write_filter_zstd)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used1));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
if (!assertEqualInt(ARCHIVE_OK,
archive_read_next_header(a, &ae)))
break;
@@ -135,7 +135,7 @@ DEFINE_TEST(test_write_filter_zstd)
archive_write_set_filter_option(a, NULL, "threads", "4"));
assertEqualIntA(a, ARCHIVE_OK, archive_write_open_memory(a, buff, buffsize, &used2));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
assert((ae = archive_entry_new()) != NULL);
archive_entry_copy_pathname(ae, path);
archive_entry_set_size(ae, datasize);
@@ -158,7 +158,7 @@ DEFINE_TEST(test_write_filter_zstd)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used2));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
failure("Trying to read %s", path);
if (!assertEqualIntA(a, ARCHIVE_OK,
archive_read_next_header(a, &ae)))
@@ -185,7 +185,7 @@ DEFINE_TEST(test_write_filter_zstd)
archive_entry_set_filetype(ae, AE_IFREG);
archive_entry_set_size(ae, datasize);
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
archive_entry_copy_pathname(ae, path);
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
assertA(datasize == (size_t)archive_write_data(a, data, datasize));
@@ -205,7 +205,7 @@ DEFINE_TEST(test_write_filter_zstd)
assertEqualIntA(a, ARCHIVE_OK,
archive_read_open_memory(a, buff, used3));
for (i = 0; i < 100; i++) {
snprintf(path, sizeof(path), "file%03d", i);
sprintf(path, "file%03d", i);
failure("Trying to read %s", path);
if (!assertEqualIntA(a, ARCHIVE_OK,
archive_read_next_header(a, &ae)))
@@ -128,31 +128,12 @@ static void verify_uncompressed_contents(const char *buff, size_t used)
/* Misc variables */
unsigned long crc;
struct tm *tm;
#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
struct tm tmbuf;
#endif
#if defined(HAVE__LOCALTIME64_S)
errno_t terr;
__time64_t tmptime;
#endif
struct tm *tm = localtime(&now);
/* p is the pointer to walk over the central directory,
* q walks over the local headers, the data and the data descriptors. */
const char *p, *q, *local_header, *extra_start;
#if defined(HAVE_LOCALTIME_R)
tm = localtime_r(&now, &tmbuf);
#elif defined(HAVE__LOCALTIME64_S)
tmptime = now;
terr = _localtime64_s(&tmbuf, &tmptime);
if (terr)
tm = NULL;
else
tm = &tmbuf;
#else
tm = localtime(&now);
#endif
/* Remember the end of the archive in memory. */
buffend = buff + used;
@@ -73,14 +73,7 @@ DEFINE_TEST(test_write_format_zip_file)
struct archive *a;
struct archive_entry *ae;
time_t t = 1234567890;
struct tm *tm;
#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
struct tm tmbuf;
#endif
#if defined(HAVE__LOCALTIME64_S)
errno_t terr;
__time64_t tmptime;
#endif
struct tm *tm = localtime(&t);
size_t used, buffsize = 1000000;
unsigned long crc;
int file_perm = 00644;
@@ -98,18 +91,6 @@ DEFINE_TEST(test_write_format_zip_file)
zip_compression = 0;
#endif
#if defined(HAVE_LOCALTIME_R)
tm = localtime_r(&t, &tmbuf);
#elif defined(HAVE__LOCALTIME64_S)
tmptime = t;
terr = _localtime64_s(&tmbuf, &tmptime);
if (terr)
tm = NULL;
else
tm = &tmbuf;
#else
tm = localtime(&t);
#endif
buff = malloc(buffsize);
/* Create a new archive in memory. */
@@ -75,14 +75,7 @@ DEFINE_TEST(test_write_format_zip_file_zip64)
struct archive *a;
struct archive_entry *ae;
time_t t = 1234567890;
struct tm *tm;
#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
struct tm tmbuf;
#endif
#if defined(HAVE__LOCALTIME64_S)
errno_t terr;
__time64_t tmptime;
#endif
struct tm *tm = localtime(&t);
size_t used, buffsize = 1000000;
unsigned long crc;
int file_perm = 00644;
@@ -99,18 +92,6 @@ DEFINE_TEST(test_write_format_zip_file_zip64)
zip_compression = 0;
#endif
#if defined(HAVE_LOCALTIME_R)
tm = localtime_r(&t, &tmbuf);
#elif defined(HAVE__LOCALTIME64_S)
tmptime = t;
terr = _localtime64_s(&tmbuf, &tmptime);
if (terr)
tm = NULL;
else
tm = &tmbuf;
#else
tm = localtime(&t);
#endif
buff = malloc(buffsize);
/* Create a new archive in memory. */
@@ -309,7 +309,7 @@ verify_large_zip(struct archive *a, struct fileblocks *fileblocks)
for (i = 0; test_sizes[i] > 0; i++) {
assertEqualIntA(a, ARCHIVE_OK,
archive_read_next_header(a, &ae));
snprintf(namebuff, sizeof(namebuff), "file_%d", i);
sprintf(namebuff, "file_%d", i);
assertEqualString(namebuff, archive_entry_pathname(ae));
assertEqualInt(test_sizes[i], archive_entry_size(ae));
}
@@ -359,7 +359,7 @@ DEFINE_TEST(test_write_format_zip_large)
*/
for (i = 0; test_sizes[i] != 0; i++) {
assert((ae = archive_entry_new()) != NULL);
snprintf(namebuff, sizeof(namebuff), "file_%d", i);
sprintf(namebuff, "file_%d", i);
archive_entry_copy_pathname(ae, namebuff);
archive_entry_set_mode(ae, S_IFREG | 0755);
filesize = test_sizes[i];
+1 -1
View File
@@ -953,7 +953,7 @@ archives.
.Sh ENVIRONMENT
The following environment variables affect the execution of
.Nm :
.Bl -tag -width indent
.Bl -tag -width ".Ev BLOCKSIZE"
.It Ev TAR_READER_OPTIONS
The default options for format readers and compression readers.
The
-1
View File
@@ -320,7 +320,6 @@ cleanup_substitution(struct bsdtar *bsdtar)
while ((rule = subst->first_rule) != NULL) {
subst->first_rule = rule->next;
free(rule->result);
regfree(&rule->re);
free(rule);
}
free(subst);
+10 -10
View File
@@ -160,21 +160,21 @@ create_tree(void)
failure("Internal sanity check failed: i = %d", i);
assert(filenames[i] != NULL);
snprintf(buff, sizeof(buff), "f/%s", filenames[i]);
sprintf(buff, "f/%s", filenames[i]);
assertMakeFile(buff, 0777, buff);
/* Create a link named "l/abcdef..." to the above. */
snprintf(buff2, sizeof(buff2), "l/%s", filenames[i]);
sprintf(buff2, "l/%s", filenames[i]);
assertMakeHardlink(buff2, buff);
/* Create a link named "m/abcdef..." to the above. */
snprintf(buff2, sizeof(buff2), "m/%s", filenames[i]);
sprintf(buff2, "m/%s", filenames[i]);
assertMakeHardlink(buff2, buff);
if (canSymlink()) {
/* Create a symlink named "s/abcdef..." to the above. */
snprintf(buff, sizeof(buff), "s/%s", filenames[i]);
snprintf(buff2, sizeof(buff2), "../f/%s", filenames[i]);
sprintf(buff, "s/%s", filenames[i]);
sprintf(buff2, "../f/%s", filenames[i]);
failure("buff=\"%s\" buff2=\"%s\"", buff, buff2);
assertMakeSymlink(buff, buff2, 0);
}
@@ -202,13 +202,13 @@ verify_tree(size_t limit)
/* Generate the names we know should be there and verify them. */
for (i = 1; i < LOOP_MAX; i++) {
/* Verify a file named "f/abcdef..." */
snprintf(name1, sizeof(name1), "f/%s", filenames[i]);
sprintf(name1, "f/%s", filenames[i]);
if (i <= limit) {
assertFileExists(name1);
assertFileContents(name1, (int)strlen(name1), name1);
}
snprintf(name2, sizeof(name2), "l/%s", filenames[i]);
sprintf(name2, "l/%s", filenames[i]);
if (i + 2 <= limit) {
/* Verify hardlink "l/abcdef..." */
assertIsHardlink(name1, name2);
@@ -219,14 +219,14 @@ verify_tree(size_t limit)
if (canSymlink()) {
/* Verify symlink "s/abcdef..." */
snprintf(name1, sizeof(name1), "s/%s", filenames[i]);
snprintf(name2, sizeof(name2), "../f/%s", filenames[i]);
sprintf(name1, "s/%s", filenames[i]);
sprintf(name2, "../f/%s", filenames[i]);
if (strlen(name2) <= limit)
assertIsSymlink(name1, name2, 0);
}
/* Verify dir "d/abcdef...". */
snprintf(name1, sizeof(name1), "d/%s", filenames[i]);
sprintf(name1, "d/%s", filenames[i]);
if (i + 1 <= limit) { /* +1 for trailing slash */
if (assertIsDir(name1, -1)) {
/* TODO: opendir/readdir this
+3 -5
View File
@@ -30,17 +30,15 @@ __FBSDID("$FreeBSD$");
DEFINE_TEST(test_option_b)
{
char *testprog_ustar;
size_t testprog_ustar_len;
assertMakeFile("file1", 0644, "file1");
if (systemf("cat file1 > test_cat.out 2> test_cat.err") != 0) {
skipping("This test requires a `cat` program");
return;
}
testprog_ustar_len = strlen(testprog) + sizeof(USTAR_OPT) + 1;
testprog_ustar = malloc(testprog_ustar_len);
strncpy(testprog_ustar, testprog, testprog_ustar_len);
strncat(testprog_ustar, USTAR_OPT, testprog_ustar_len);
testprog_ustar = malloc(strlen(testprog) + sizeof(USTAR_OPT) + 1);
strcpy(testprog_ustar, testprog);
strcat(testprog_ustar, USTAR_OPT);
/*
* Bsdtar does not pad if the output is going directly to a disk file.
+10 -11
View File
@@ -63,7 +63,7 @@ __FBSDID("$FreeBSD$");
#include "err.h"
#include "passphrase.h"
static size_t bsdtar_expand_char(char *, size_t, size_t, char);
static size_t bsdtar_expand_char(char *, size_t, char);
static const char *strip_components(const char *path, int elements);
#if defined(_WIN32) && !defined(__CYGWIN__)
@@ -173,12 +173,12 @@ safe_fprintf(FILE *f, const char *fmt, ...)
/* Not printable, format the bytes. */
while (n-- > 0)
i += (unsigned)bsdtar_expand_char(
outbuff, sizeof(outbuff), i, *p++);
outbuff, i, *p++);
}
} else {
/* After any conversion failure, don't bother
* trying to convert the rest. */
i += (unsigned)bsdtar_expand_char(outbuff, sizeof(outbuff), i, *p++);
i += (unsigned)bsdtar_expand_char(outbuff, i, *p++);
try_wc = 0;
}
@@ -200,7 +200,7 @@ safe_fprintf(FILE *f, const char *fmt, ...)
* Render an arbitrary sequence of bytes into printable ASCII characters.
*/
static size_t
bsdtar_expand_char(char *buff, size_t buffsize, size_t offset, char c)
bsdtar_expand_char(char *buff, size_t offset, char c)
{
size_t i = offset;
@@ -221,7 +221,7 @@ bsdtar_expand_char(char *buff, size_t buffsize, size_t offset, char c)
case '\v': buff[i++] = 'v'; break;
case '\\': buff[i++] = '\\'; break;
default:
snprintf(buff + i, buffsize - i, "%03o", 0xFF & (int)c);
sprintf(buff + i, "%03o", 0xFF & (int)c);
i += 3;
}
}
@@ -309,12 +309,11 @@ set_chdir(struct bsdtar *bsdtar, const char *newdir)
/* The -C /foo -C bar case; concatenate */
char *old_pending = bsdtar->pending_chdir;
size_t old_len = strlen(old_pending);
size_t new_len = old_len + strlen(newdir) + 2;
bsdtar->pending_chdir = malloc(new_len);
bsdtar->pending_chdir = malloc(old_len + strlen(newdir) + 2);
if (old_pending[old_len - 1] == '/')
old_pending[old_len - 1] = '\0';
if (bsdtar->pending_chdir != NULL)
snprintf(bsdtar->pending_chdir, new_len, "%s/%s",
sprintf(bsdtar->pending_chdir, "%s/%s",
old_pending, newdir);
free(old_pending);
}
@@ -696,7 +695,7 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry)
/* Use uname if it's present, else uid. */
p = archive_entry_uname(entry);
if ((p == NULL) || (*p == '\0')) {
snprintf(tmp, sizeof(tmp), "%lu ",
sprintf(tmp, "%lu ",
(unsigned long)archive_entry_uid(entry));
p = tmp;
}
@@ -711,7 +710,7 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry)
fprintf(out, "%s", p);
w = strlen(p);
} else {
snprintf(tmp, sizeof(tmp), "%lu",
sprintf(tmp, "%lu",
(unsigned long)archive_entry_gid(entry));
w = strlen(tmp);
fprintf(out, "%s", tmp);
@@ -724,7 +723,7 @@ list_item_verbose(struct bsdtar *bsdtar, FILE *out, struct archive_entry *entry)
*/
if (archive_entry_filetype(entry) == AE_IFCHR
|| archive_entry_filetype(entry) == AE_IFBLK) {
snprintf(tmp, sizeof(tmp), "%lu,%lu",
sprintf(tmp, "%lu,%lu",
(unsigned long)archive_entry_rdevmajor(entry),
(unsigned long)archive_entry_rdevminor(entry));
} else {
+29 -58
View File
@@ -426,7 +426,7 @@ failure(const char *fmt, ...)
nextmsg = NULL;
} else {
va_start(ap, fmt);
vsnprintf(msgbuff, sizeof(msgbuff), fmt, ap);
vsprintf(msgbuff, fmt, ap);
va_end(ap);
nextmsg = msgbuff;
}
@@ -551,7 +551,7 @@ test_skipping(const char *fmt, ...)
va_list ap;
va_start(ap, fmt);
vsnprintf(buff, sizeof(buff), fmt, ap);
vsprintf(buff, fmt, ap);
va_end(ap);
/* Use failure() message if set. */
msg = nextmsg;
@@ -1970,12 +1970,7 @@ assertion_make_file(const char *file, int line,
failure_finish(NULL);
return (0);
}
#ifdef HAVE_FCHMOD
if (0 != fchmod(fd, mode))
#else
if (0 != chmod(path, mode))
#endif
{
if (0 != chmod(path, mode)) {
failure_start(file, line, "Could not chmod %s", path);
failure_finish(NULL);
close(fd);
@@ -3070,7 +3065,7 @@ systemf(const char *fmt, ...)
int r;
va_start(ap, fmt);
vsnprintf(buff, sizeof(buff), fmt, ap);
vsprintf(buff, fmt, ap);
if (verbosity > VERBOSITY_FULL)
logprintf("Cmd: %s\n", buff);
r = system(buff);
@@ -3095,7 +3090,7 @@ slurpfile(size_t * sizep, const char *fmt, ...)
int r;
va_start(ap, fmt);
vsnprintf(filename, sizeof(filename), fmt, ap);
vsprintf(filename, fmt, ap);
va_end(ap);
f = fopen(filename, "rb");
@@ -3162,7 +3157,7 @@ extract_reference_file(const char *name)
char buff[1024];
FILE *in, *out;
snprintf(buff, sizeof(buff), "%s/%s.uu", refdir, name);
sprintf(buff, "%s/%s.uu", refdir, name);
in = fopen(buff, "r");
failure("Couldn't open reference file %s", buff);
assert(in != NULL);
@@ -3190,12 +3185,14 @@ extract_reference_file(const char *name)
while (bytes > 0) {
int n = 0;
/* Write out 1-3 bytes from that. */
assert(VALID_UUDECODE(p[0]));
assert(VALID_UUDECODE(p[1]));
n = UUDECODE(*p++) << 18;
n |= UUDECODE(*p++) << 12;
fputc(n >> 16, out);
--bytes;
if (bytes > 0) {
assert(VALID_UUDECODE(p[0]));
assert(VALID_UUDECODE(p[1]));
n = UUDECODE(*p++) << 18;
n |= UUDECODE(*p++) << 12;
fputc(n >> 16, out);
--bytes;
}
if (bytes > 0) {
assert(VALID_UUDECODE(p[0]));
n |= UUDECODE(*p++) << 6;
@@ -3221,7 +3218,7 @@ copy_reference_file(const char *name)
FILE *in, *out;
size_t rbytes;
snprintf(buff, sizeof(buff), "%s/%s", refdir, name);
sprintf(buff, "%s/%s", refdir, name);
in = fopen(buff, "rb");
failure("Couldn't open reference file %s", buff);
assert(in != NULL);
@@ -3548,7 +3545,7 @@ test_run(int i, const char *tmpdir)
exit(1);
}
/* Create a log file for this test. */
snprintf(logfilename, sizeof(logfilename), "%s.log", tests[i].name);
sprintf(logfilename, "%s.log", tests[i].name);
logfile = fopen(logfilename, "w");
fprintf(logfile, "%s\n\n", tests[i].name);
/* Chdir() to a work dir for this specific test. */
@@ -3862,19 +3859,7 @@ main(int argc, char **argv)
static const int limit = sizeof(tests) / sizeof(tests[0]);
int test_set[sizeof(tests) / sizeof(tests[0])];
int i = 0, j = 0, tests_run = 0, tests_failed = 0, option;
int testprogdir_len;
#ifdef PROGRAM
int tmp2_len;
#endif
time_t now;
struct tm *tmptr;
#if defined(HAVE_LOCALTIME_R) || defined(HAVE__LOCALTIME64_S)
struct tm tmbuf;
#endif
#if defined(HAVE__LOCALTIME64_S)
errno_t terr;
__time64_t tmptime;
#endif
char *refdir_alloc = NULL;
const char *progname;
char **saved_argv;
@@ -3910,13 +3895,12 @@ main(int argc, char **argv)
* tree.
*/
progname = p = argv[0];
testprogdir_len = strlen(progname) + 1;
if ((testprogdir = (char *)malloc(testprogdir_len)) == NULL)
if ((testprogdir = (char *)malloc(strlen(progname) + 1)) == NULL)
{
fprintf(stderr, "ERROR: Out of memory.");
exit(1);
}
strncpy(testprogdir, progname, testprogdir_len);
strcpy(testprogdir, progname);
while (*p != '\0') {
/* Support \ or / dir separators for Windows compat. */
if (*p == '/' || *p == '\\')
@@ -4058,21 +4042,20 @@ main(int argc, char **argv)
#ifdef PROGRAM
if (testprogfile == NULL)
{
tmp2_len = strlen(testprogdir) + 1 + strlen(PROGRAM) + 1;
if ((tmp2 = (char *)malloc(tmp2_len)) == NULL)
if ((tmp2 = (char *)malloc(strlen(testprogdir) + 1 +
strlen(PROGRAM) + 1)) == NULL)
{
fprintf(stderr, "ERROR: Out of memory.");
exit(1);
}
strncpy(tmp2, testprogdir, tmp2_len);
strncat(tmp2, "/", tmp2_len);
strncat(tmp2, PROGRAM, tmp2_len);
strcpy(tmp2, testprogdir);
strcat(tmp2, "/");
strcat(tmp2, PROGRAM);
testprogfile = tmp2;
}
{
char *testprg;
int testprg_len;
#if defined(_WIN32) && !defined(__CYGWIN__)
/* Command.com sometimes rejects '/' separators. */
testprg = strdup(testprogfile);
@@ -4083,11 +4066,10 @@ main(int argc, char **argv)
testprogfile = testprg;
#endif
/* Quote the name that gets put into shell command lines. */
testprg_len = strlen(testprogfile) + 3;
testprg = malloc(testprg_len);
strncpy(testprg, "\"", testprg_len);
strncat(testprg, testprogfile, testprg_len);
strncat(testprg, "\"", testprg_len);
testprg = malloc(strlen(testprogfile) + 3);
strcpy(testprg, "\"");
strcat(testprg, testprogfile);
strcat(testprg, "\"");
testprog = testprg;
}
#endif
@@ -4109,20 +4091,9 @@ main(int argc, char **argv)
*/
now = time(NULL);
for (i = 0; ; i++) {
#if defined(HAVE_LOCALTIME_R)
tmptr = localtime_r(&now, &tmbuf);
#elif defined(HAVE__LOCALTIME64_S)
tmptime = now;
terr = _localtime64_s(&tmbuf, &tmptime);
if (terr)
tmptr = NULL;
else
tmptr = &tmbuf;
#else
tmptr = localtime(&now);
#endif
strftime(tmpdir_timestamp, sizeof(tmpdir_timestamp),
"%Y-%m-%dT%H.%M.%S", tmptr);
"%Y-%m-%dT%H.%M.%S",
localtime(&now));
if ((strlen(tmp) + 1 + strlen(progname) + 1 +
strlen(tmpdir_timestamp) + 1 + 3) >
(sizeof(tmpdir) / sizeof(char))) {
Loaded 100 of 3397 files, more files were not shown because too many files have changed in this diff. Show more