Compare commits

...
175 Commits
Author SHA1 Message Date
Glen Barber fc952ac221 Update in preparation of 13.1-RELEASE
- Bump BRANCH to RELEASE
- Add the anticipated RELEASE announcement date
- Set a static __FreeBSD_version

Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-05-11 19:59:24 -04:00
Mark Johnston 9470a2f7da clockcalib: Fix an overflow bug
tc_counter_mask is an unsigned int and in the TSC timecounter is equal
to UINT_MAX, so the addition tc->tc_counter_mask + 1 can overflow to 0,
resulting in a hang during boot.

Approved by:	re (gjb)
Fixes:		c2705ceaeb ("x86: Speed up clock calibration")
Reviewed by:	cperciva
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c3196306f0)
(cherry picked from commit 58f49b7da7)
2022-05-05 14:37:48 -04:00
Glen Barber cd651fcc49 Update to RC6
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-05-04 20:06:39 -04:00
Hans Petter Selasky 465c5bd88e xhci(4): Always add and evaluate the slot context.
Because the maximum number of endpoint contexts is stored there.

Tested by:	ehaupt@
PR:		262882
Approved by:	re (gjb, early MFC)
Sponsored by:	NVIDIA Networking

(cherry picked from commit 09dd1adfa4)
(cherry picked from commit 6d8c6b24ee)
2022-05-04 09:20:54 +02:00
Hans Petter Selasky 340ed8ccb5 xhci(4): Only drop BULK and INTERRUPT endpoints to reset data toggle.
Only drop BULK and INTERRUPT endpoints, to reset the data toggle,
because for other endpoint types this is not critical.

While at it fix some whitespace.

Tested by:	ehaupt@
PR:		262882
Approved by:	re (gjb, early MFC)
Sponsored by:	NVIDIA Networking

(cherry picked from commit e276d28150)
(cherry picked from commit 610528736f)
2022-05-04 09:20:46 +02:00
Jung-uk Kim 2b3d81ba7d OpenSSL: Regen manual pages for OpenSSL 1.1.1o
Approved by:	re (gjb, implicit, security)

(cherry picked from commit 9a3583bfbd)
(cherry picked from commit 225a1494a5)
2022-05-03 16:36:33 -04:00
Jung-uk Kim 2e121bd7c7 OpenSSL: Merge OpenSSL 1.1.1o
Approved by:	re (gjb, implicit, security)

(cherry picked from commit 34252e89a9)
(cherry picked from commit 1b7b799f9e)
2022-05-03 16:34:47 -04:00
Glen Barber 2e9ad6042b 13.1: Update to RC5
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-04-27 20:06:34 -04:00
Hans Petter Selasky 245d5a65f5 xhci(4): Ensure the so-called data toggle gets properly reset.
Use the drop and enable endpoint context commands to force a reset of
the data toggle for USB 2.0 and USB 3.0 after:
 - clear endpoint halt command (when the driver wishes).
 - set config command (when the kernel or user-space wants).
 - set alternate setting command (only affected endpoints).

Some XHCI HW implementations may not allow the endpoint reset command when
the endpoint context is not in the halted state.

Reported by:		Juniper and Gary Jennejohn
Approved by:		re (gjb)
Sponsored by:		NVIDIA Networking

(cherry picked from commit cda31e7349)
2022-04-27 21:33:34 +02:00
Ed Maste 346f0084ba libcxxrt: Insert padding in __cxa_dependent_exception
Padding was added to __cxa_exception in 45ca8b19 and
__cxa_dependent_exception needs the same layout.
Add some static_asserts to detect this in the future.

Merge of libcxxrt commit b00c6c564357

(cherry picked from commit c40e434988)
(cherry picked from commit 69a40d9241)

Approved by:	re (gjb)
2022-04-27 12:05:34 -04:00
Andrew Turner d33bf8c50b Stop using the kmem for PCPU memory on arm64
When allocating memory with a kernel memory allocator we may get
memory that will later be promoted to a superpage. If this happens
while another CPU is using the pointer they can race and when the
promotion passes through the break-before-make sequence the pointer
will be invalid for a short length of time.

Revert the commit that added the use of the kernel allocator and
subsequent fixes to the original change.

Revert "Pass the ACPI ID when reading the ACPI domain"

This reverts commit aa3b5d79b2.

Revert "Stop reading the arm64 domain when it's known"

This reverts commit b7c23efd74.

Revert "Allocate arm64 per-CPU data in the correct domain"

This reverts commit f51997c6e4.

Approved by:	re (gjb)
Reported by:	dch
Sponsored by:	The FreeBSD Foundation
2022-04-27 15:16:35 +01:00
Misho 5acfa48bb2 if_bnxt: Allow bnxt interfaces to use vlans
When VLAN HW filter is disabled, the NIC does not pass any vlan tagged
traffic. Setting these flags on the device allows vlan tagged traffic to
pass.

Approved by:	re (gjb)
PR:		236983
Tested by:	pi
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D34824

(cherry picked from commit 0c6a2fa33e)
(cherry picked from commit e54505277c)
2022-04-27 14:55:24 +01:00
Glen Barber 27c537bf05 release: fix on-disc pkg binary symbolic links
Approved by:	re (kib)
PR:		263574
Reported by:	loader
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 68b0a79b7c)
(cherry picked from commit fab1a7b9b6)
2022-04-26 16:01:01 -04:00
Kyle Evans 59288c719d stand: zfs: handle holes at the tail end correctly
This mirrors dmu_read_impl(), zeroing out the tail end of the buffer and
clipping the read to what's contained by the block that exists.

This fixes an issue that arose during the 13.1 release process; in
13.1-RC1 and later, setting up GELI+ZFS will result in a failure to
boot.  The culprit is this, which causes us to fail to load geom_eli.ko
as there's a residual portion after the single datablk that should be
zeroed out.

PR:		263407
Reviewed by:	tsoome
Approved by:	re (gjb)

(cherry picked from commit 914dc91d12)
(cherry picked from commit 0c9c8a4c64)
2022-04-24 18:15:07 -05:00
Gordon Bergling 6b642cf5c8 time(3): Refine history in the manual page
The time() system call first appeared in Version 1 AT&T UNIX.  Through
the Version 3 AT&T UNIX, it returned 60 Hz ticks since an epoch that
changed occasionally, because it was a 32-bit value that overflowed in a
little over 2 years.

In Version 4 AT&T UNIX the granularity of the return value was reduced to
whole seconds, delaying the aforementioned overflow until 2038.

Version 7 AT&T UNIX introduced the ftime() system call, which returned
time at a millisecond level, though retained the gtime() system call
(exposed as time() in userland).  time() could have been implemented as a
wrapper around ftime(), but that wasn't done.

4.1cBSD implemented a higher-precision time function gettimeofday() to
replace ftime() and reimplemented time() in terms of that.

Since FreeBSD 9 the implementation of time() uses
clock_gettime(CLOCK_SECOND) instead of gettimeofday() for performance
reasons.

With most valuable input from Warner (imp@).

Reviewed by:	0mp, jilles, imp
Approved by:	re (gjb)
Differential Revision:	https://reviews.freebsd.org/D34751

(cherry picked from commit 3e0f3678ec)
2022-04-22 16:36:36 +02:00
Glen Barber 283d1b9825 13.1: update to RC4
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-04-20 20:10:33 -04:00
Konstantin Belousov 821467b5a0 Mostly revert a5970a529c: Make files opened with O_PATH to not block non-forced unmount
Approved by:	re (gjb)

(cherry picked from commit bf13db086b)
(cherry picked from commit 6daddc54de)
2022-04-20 00:03:16 +03:00
Dimitry Andric 07bbb50f59 Merge libcxxrt commit 45ca8b1942090226ba9368caeeeabc0d4ee41ad6
Insert padding in __cxa_exception struct for compatibility

  Similar to https://github.com/llvm/llvm-project/commit/f2a436058fcb, the
  addition of __attribute__((__aligned__)) to _Unwind_Exception (in commit
  b9616964) causes implicit padding to be inserted before the unwindHeader
  field in __cxa_exception.

  Applications attempt to get at the earlier fields in __cxa_exception, so
  preserve the same negative offsets in __cxa_exception, by moving the
  padding to the beginning of the struct.

  The assumption here is that if the ABI is not aware of the padding
  before unwindHeader and put the referenceCount/primaryException in
  there, no padding should exist before unwindHeader.

This should make libreoffice's custom exception handling mechanisms work
correctly, even if it was built against an older cxxabi.h/unwind.h pair.

PR:		263370
Approved by:	re (gjb)
MFC after:	immediately

(cherry picked from commit 434215c26d)
(cherry picked from commit 06394327dd)
2022-04-19 22:23:20 +02:00
Mark Johnston 5f649725da libctf: Fix recursive descent into anonymous SOU fields
Approved by:	re (gjb)
PR:		262412
Tested by:	dhw, gallatin
Fixes:		a6fb869173 ("libctf: Handle CTFv3 containers")
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 6e563a1b60)
(cherry picked from commit 8b01c3026b)
2022-04-18 12:39:00 -04:00
Mark Johnston 6955dbde7a ctf: Avoid passing a caddr_t to roundup2()
For some reason I can't reproduce this locally, but Jenkins complains.

Approved by:	re (gjb)
Reported by:	Jenkins
Fixes:		bdf290cd3e ("ctf: Add v3 support to CTF tools, ctf{convert,dump,merge}")

(cherry picked from commit 3fe1f21fb3)
(cherry picked from commit fb89cf93a5)
2022-04-18 12:38:54 -04:00
Mark Johnston e3d976742c ctf: Fix a -Wunused-but-set-variable warning
Approved by:	re (gjb)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit cb6f722562)
(cherry picked from commit d80faf878a)
2022-04-18 12:38:50 -04:00
Mark Johnston 105d1ae904 ctf: Add v3 support to CTF tools, ctf{convert,dump,merge}
ctfdump handles v2 and v3.  ctfconvert now emits only CTFv3, whereas
ctfmerge can merge v2 and v3 containers into v3 containers.

Approved by:	re (gjb)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit bdf290cd3e)
(cherry picked from commit e5b54808f7)
2022-04-18 12:38:45 -04:00
Mark Johnston dc543c8786 libctf: Handle CTFv3 containers
In general, the patch adds indirection to minimize the amount of code
that needs to know about differences between v2 and v3.  Specifically,
some new ctf_get_ctt_* functions are added, and new LCTF_* macros are
added to use the underlying container's version to do the right thing.

CTF containers can have parent/child relationships, wherein a type ID in
one container refers to a type in the parent.  It is permitted for the
parent and child to have different versions.

Approved by:	re (gjb)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit a6fb869173)
(cherry picked from commit a49aa9da78)
2022-04-18 12:38:39 -04:00
Mark Johnston 5444e90da1 linker: Permit CTFv3 containers
Approved by:	re (gjb)
Reviewed by:	Domagoj Stolfa
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 8dbae4ce32)
(cherry picked from commit 8409eb0251)
2022-04-18 12:38:34 -04:00
Mark Johnston 246787fcb8 fbt: Add support for CTFv3 containers
The general aim in this and subsequent patches is to minimize the
amount of code that directly references CTF types such as ctf_type_t,
ctf_array_t, etc.  To that end, introduce some routines similar to the
existing fbt_get_ctt_size() (which exists to deal with differences
between v1 and v2) and change ctf_lookup_by_id() to return a void
pointer.

Support for v2 containers is preserved.

Approved by:	re (gjb)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit d9175438c0)
(cherry picked from commit 2ecf3b58eb)
2022-04-18 12:38:28 -04:00
Mark Johnston 6e6983ee2b ctf: Add definitions for CTFv3
These are based on definitions added to binutils' libctf.  Specifically:
- Type IDs are now encoded in 32 bits rather than 16, changing the
  layout of ctf_type_t, ctf_array_t, ctf_member_t and ctf_lmember_t.
- Type info is encoded in 32 bits rather than 16.  The type "kind" is
  extended from 5 bits to 6, and the type "vlen" is extended from 10
  bits to 25.

The main upside is that we remove the current limit, imposed by CTFv2,
of 2^{15} distinct types in the main kernel executable.  Other limits,
such as that on the number of elements in an enum, imposed by the vlen
limit, are also raised.

This change adds v2 and v3 flavours of macros and type definitions which
differ between the two versions.  Compatibility is preserved for now by
having generic names refer to the v2 definitions, so, e.g., ctf_type_t
is still a v2 type.

No functional change intended.

Approved by:	re (gjb)
Reviewed by:	Domagoj Stolfa
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 994297b01b)
(cherry picked from commit 9818e5ebf3)
2022-04-18 12:38:22 -04:00
Mark Johnston 30700bc80e linker: Simplify CTF container handling
Use sys/ctf.h to provide various definitions required to parse the CTF
header.  No functional change intended.

Approved by:	re (gjb)
Reviewed by:	Domagoj Stolfa, emaste
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit cab9382a2c)
(cherry picked from commit 24597a09b9)
2022-04-18 12:38:14 -04:00
Mark Johnston 6edd55f882 ctf: Import ctf.h from OpenBSD
Use it instead of the existing ctf.h from OpenSolaris.  This makes it
easier to use CTF in the core kernel, and to extend the CTF format to
support wider type IDs.

The imported ctf.h is modified to depend only on _types.h, and also to
provide macros which use the "parent" bit of a type ID to refer to types
in a parent CTF container.

No functional change intended.

Approved by:	re (gjb)
Reviewed by:	Domagoj Stolfa, emaste
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 2d5d2a986c)
(cherry picked from commit 3681c4f065)
2022-04-18 12:37:53 -04:00
Gordon Bergling e74c79e48e isci(4): Remove a double word in an error message
- s/is is/is/

Approved by:	re@ (gjb)

(cherry picked from commit 756220b515)
2022-04-15 15:30:13 +02:00
Gordon Bergling 02b444d749 tty(4): Add a HISTORY section to the manual page
Note that a console typewriter device /dev/tty
and asynchronous communication interfaces /dev/tty[0-5]
first appeared in Version 1 AT&T UNIX.

Obtained from:	OpenBSD
Approved by:	re@ (gjb)

(cherry picked from commit b988af5b43)
2022-04-15 15:29:36 +02:00
Gordon Bergling f02b1c36b2 pass(4): Fix a typo in the manual page
- s/modfied/modified/

Approved by:	re@ (gjb)

(cherry picked from commit 3dcfd6c266)
2022-04-15 15:29:06 +02:00
Gordon Bergling 2ece57c3ac mt(3): Fix a typo in the manual page
- s/mulitple/multiple/

Approved by:	re@ (gjb)

(cherry picked from commit 656d68a711)
2022-04-15 15:28:34 +02:00
Gordon Bergling 839c10c589 own(9): Fix a typo in a function name in the manual page
- s/own_commmand_wait/own_command_wait/

Approved by:	re@ (gjb)

(cherry picked from commit a95850f10a)
2022-04-15 15:28:10 +02:00
Gordon Bergling 2b667915c8 htu21(4): Correct a typo in the manual page
- s/measurment/measurement/

Approved by:	re@ (gjb)

(cherry picked from commit 0d40cd1524)
2022-04-15 15:27:15 +02:00
Gordon Bergling 9afada88e0 ipf(5): Fix a typo in the manual page
- s/accomodate/accommodate/

Approved by:	re@ (gjb)

(cherry picked from commit 8a3568b584)
2022-04-15 15:26:50 +02:00
Gordon Bergling ac384c6bfd crypto(9): Fix a typo in the manual page
- s/faciliate/facilitate/

Approved by:	re@ (gjb)

(cherry picked from commit 8e8d2a722e)
2022-04-15 15:26:13 +02:00
Gordon Bergling 165d97049a loader.4th(8): Fix a typo in the manual page
- s/commmand/command/

Approved by:	re@ (gjb)

(cherry picked from commit ad49d7c54c)
2022-04-15 15:25:48 +02:00
Gordon Bergling 5ae18075fe pnfsserver(4): Fix a typo in the manual page
- s/commmand/command/

Approved by:	re@ (gjb)

(cherry picked from commit a16977209b)
2022-04-15 15:25:21 +02:00
Glen Barber ec2fbe4b1e 13.1: update to RC3
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-04-13 21:15:25 -04:00
Mike Karels 96d89102f0 Switch RELNOTES to 13.1
Truncate entries from 13.0; change 13.0 to 13.1.

This is a direct commit.

Approved by:	re (gjb)
2022-04-11 19:06:01 -05:00
Mark Johnston 53460a2c7e net: Fix LLE lock leaks
Historically, lltable_try_set_entry_addr() would release the LLE lock
upon failure.  After some refactoring, it no longer does so, but
consumers were not adjusted accordingly.

Also fix a leak that can occur if lltable_calc_llheader() fails in the
ARP code, but I suspect that such a failure can only occur due to a code
bug.

Approved by:	re (gjb)
Reviewed by:	bz, melifaro
Reported by:	pho
Fixes:		0b79b007eb ("[lltable] Restructure nd6 code.")
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit dd91d84486)
(cherry picked from commit 078d50f9dd14ac77145b2cf8f143d49329b2c4f7)
2022-04-11 09:59:21 -04:00
Mark Johnston 21a2bfcafb i386: Fix the nodevice apic build
Approved by:	re (gjb)
PR:		263124
Fixes:		62d09b46ad ("x86: Defer LAPIC calibration until after timecounters are available")
Reviewed by:	kib, jhb, emaste
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit aa597d4049)
(cherry picked from commit 4f659ce4daf82ac3335abf3aab7181f2ac90a4cd)
2022-04-11 09:59:15 -04:00
Ed Maste 7150099b3c installworld: handle ldd including preloaded objects
The installworld target makes a temporary copy of binaries to be used
during the install.  Libraries that they depend on are also included,
found by using `ldd`.

After commit 0913953c9e ldd started listing preloaded objects,
including [vdso], under a [preloaded] header.  Skip ldd output that is
enclosed in square brackets.

Reviewed by:	cy, kib [earlier version]
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34734

(cherry picked from commit b3b462229f)
(cherry picked from commit e10026a406)

Approved by:	re (gjb)
2022-04-11 09:12:53 -04:00
Martin Matuska b572edb09c libarchive: fix zstd compression support
The commit 833a452e9 introduced a change that detached
the zstd compression (not decompression) support from base build.

Reported by:	kevans
Approved by:	re (delphij)

(cherry picked from commit 7f815d4f12)
(cherry picked from commit 3caf7dd45d)
2022-04-11 01:52:50 +02:00
Glen Barber c2e15a08fd 13.1: update to RC2
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-04-06 20:07:08 -04:00
Mateusz Guzik 1929c80c53 vfs: fixup WANTIOCTLCAPS on open
In some cases vn_open_cred overwrites cn_flags, effectively nullifying
initialisation done in NDINIT. This will have to be fixed.

In the meantime make sure the flag is passed.

Reported by:	jenkins
Noted by:	Mathieu <[email protected]>
Approved by:	re (gjb)

(cherry picked from commit b7262756e2)
(cherry picked from commit 792ebbb155)
2022-04-06 23:26:14 +00:00
Mateusz Guzik fffe016c81 vfs: fix memory leak on lookup with fds with ioctl caps
Reviewed by:	markj
PR:		262515
Noted by:	[email protected]
Differential Revision:	https://reviews.freebsd.org/D34667
Approved by:	re (gjb)

(cherry picked from commit 0c805718cb)
(cherry picked from commit 838d8e6fb6)
2022-04-06 23:25:50 +00:00
Warner Losh 11931e7aa8 fix integer overflow bugs in *stosbt
68f57679d6 Fixed another class of integer overflows, but introduced a
boundary condition for 2-4s in ns conversion, 2-~4000s in us conversions
and 2-~4,000,000s in ms conversions. This was because we bogusly used
SBT_1S for the notion of 1 second, instead of the appropriate power of
10. To fix, just use the appropriate power of 10, which avoids these
overflows.

This caused some sleeps in ZFS to be on the order of an hour.

Approved by:		re@ (gjb)
MFC:			1 day
PR:			263073
Sponsored by:		Netflix
Reviewed by:		asomers
Differential Revision:	https://reviews.freebsd.org/D34790

(cherry picked from commit 4c30b9ecd4)
(cherry picked from commit c43786cc37)
2022-04-06 11:46:08 -06:00
Chandrakanth Patil c872d65b55 mrsas: if controller reset is in progress, refrain from firing DCMDs to
firmware in shutdown

If controller reset is in progress, at same time if system shutdown is
issued then corresponding shutdown function in driver will be invoked
where driver is waiting 15 seconds to complete the controller reset.

If the reset is not complteted within that time frame driver will go
ahead and fire cache flush and shutdown DCMDs which will end up
accessing the the queues which are not initialized due to undergoing
reset leads to FMU error in firmware.

Fix:
In shutdown function, if controller reset is not finished within 15
seconds than driver will return to the OS without firing any DCMDs.

Approved by: re@ (gjb)
Reviewed by: imp
PR: 261375

(cherry picked from commit 79c4c4be96)
(cherry picked from commit 09e161a29e)
2022-04-06 11:46:00 -06:00
Chandrakanth Patil cf523b815c mrsas: remove additional MPT command allocation for R1 FP command
There is an additional MPT command allocation for R1 fp command which
will lead to MPT command unavailablity in case of rigorous R1 FP IOs.

Remove additional MPT command allocation for R1 FP.

Approved by: re@ (gjb)
Reviewed by: imp
PR: 261377

(cherry picked from commit 241bb95552)
(cherry picked from commit 2ebe518597)
2022-04-06 11:45:50 -06:00
Warner Losh bf1dea8f1b linuxkpi: move io_mapping_create_wc to .c
Move io_mapping_create_wc to .c because it encodes the size of struct
io_mapping so we move this from the client module to the linuxkpi
module.

Approved by:		re@ (gjb)
Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34776

(cherry picked from commit 132b00f906)
(cherry picked from commit 4e94b3542d)
2022-04-06 11:45:46 -06:00
Warner Losh a84ef318c6 linuxkpi: Move lkpi_pcim_iomap_devres_find to .c file
lkpi_pcim_iomap_devres_find encodes the size of struct pcim_iomap_devres
in the code, so move from .h to .c to move from client driver to
linuxkpi module.

Approved by:		re@ (gjb)
Sponsored by:		Netflix
Reviewed by:		hselasky
Differential Revision:	https://reviews.freebsd.org/D34775

(cherry picked from commit 2bf3361d56)
(cherry picked from commit 211621030e)
2022-04-06 11:45:42 -06:00
Warner Losh ebd35d1ceb linuxkpi: Move pci_alloc_irq_vectors to .c file
pci_alloc_irq_vectors encodes the size of struct msix_entry
into its code. Move from .h to .c to move this knowledge from
client modules to linuxkpi module.

Approved by:		re@ (gjb)
Sponsored by:		Netflix
Reviewed by:		hselasky
Differential Revision:	https://reviews.freebsd.org/D34774

(cherry picked from commit 36b5c44002)
(cherry picked from commit bc01b38394)
2022-04-06 11:45:38 -06:00
Warner Losh 20f0a3ac5b linuxkpi: Move pci_request_region and _lkpi_pci_iomap into .c
Both pci_request_region and _lkpi_pci_iomap encode the size of struct
pci_mmio_region into their code. Move from .h to .c files to move that
knowledge from the client drivers into the linuxkpi module.

Approved by:		re@ (gjb)
Sponsored by:		Netflix
Reviewed by:		hselasky
Differential Revision:	https://reviews.freebsd.org/D34773

(cherry picked from commit 1cdb25340f)
(cherry picked from commit 4859994c42)
2022-04-06 11:45:34 -06:00
Warner Losh 43b329596f linuxkpi: Move lkpi_pci_devres_get_alloc into .c file
lkpi_pci_devres_get_alloc encodes the struct pci_devres into its
code. Move from .h file to .c file to move this knowledge into linuxkpi
module.

Approved by:		re@ (gjb)
Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34772

(cherry picked from commit 3ea682e21e)
(cherry picked from commit 2cd55de380)
2022-04-06 11:45:31 -06:00
Warner Losh 88543510cc linuxkpi: Move cdev_alloc into .c file
Move cdev_alloc into linux_compat.c since it encodes the size of struct
linux_cdev into the client modules otherwise.

Approved by:		re@ (gjb)
Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34771

(cherry picked from commit aca0bcbca3)
(cherry picked from commit d1f93d6721)
2022-04-06 11:45:27 -06:00
Warner Losh 169aa34959 linuxkpi: Move class_create to .c file
class_create encodes the size of struct class into the generated
code. Move from .h file to .c file to move this knowledge from the
client modules that call this into the linuxkpi module.

Approved by:		re@ (gjb)
Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34769

(cherry picked from commit 1341ac9f9c)
(cherry picked from commit 98d2b4a158)
2022-04-06 11:45:23 -06:00
Warner Losh f6f168a17e linuxkpi: Move device_create_groups_vargs to linux_compat.c
device_create_groups_vargs encodes the size of struct device. Move
definition from .h to .c to move this size into the linuxkpi module
rather than encoding it in all client driver modules.

Approved by:		re@ (gjb)
Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34768

(cherry picked from commit 702b687503)
(cherry picked from commit 417f1c8149)
2022-04-06 11:45:18 -06:00
Warner Losh d3113190dd linuxkpi: move kobject_create to .c file
kobject_create knows the size of struct kobject. Move it to
linux_compat.c so this knowledge is confined to the loadable module and
not the clients.

Approved by:		re@ (gjb)
Sponsored by:		Netflix
Reviewed by:		hselasky, emaste
Differential Revision:	https://reviews.freebsd.org/D34767

(cherry picked from commit 36929b5584)
(cherry picked from commit 2f3d11894b)
2022-04-06 11:45:15 -06:00
Warner Losh 0e2ae559a1 linuxkpi: add padding to struct pci_driver
Add 32 or 64 bytes of padding to struct pci_driver at the end in the
_spare field like we should have done when we branched stable/13, but
neglected to do so since we didn't properly anticipate the need.

We cannot safely use these spare fields until after 13.0 EOL since
drivers compiled on 13.0 won't have that space reserved and we'll step
on something else using them. This isn't 100% KBI compatible through the
13.x release branch, but is compatible enough so that drm packages built
on the oldest supported release will work on the latest stable/13 and
any newer releases. It's not ideal, but makes the best of a bad
situation and is a pragmatic approach that belatedly builds in some
future proofing.

Direct commit to stable/13 because this is not relevant to main in this
exact form.

Approved by:		re@ (gjb)
Sponsored by:		Netflix
Reviewed by:		bz
Differential Revision:	https://reviews.freebsd.org/D34754

(cherry picked from commit 86d5c66106)
2022-04-06 11:45:10 -06:00
Warner Losh 6615aa8e1b linuxkpi: Restore the KBI for struct pci_driver
The size of the 13.0 version of struct pci_driver was 92 or 184 bytes on
32- or 64-bit systems respectively. We recently added bsd_probe_return
at the end of this struct, breaking the KBI on the stable/13 branch.

Fix this by removing the isdrm member. We don't need it because we can
do a strcmp in the few places that need it as they aren't performance
critical. Move the newly added bsd_probe_return to that slot. It's the
same size in all our supported KBIs as bool and fits into that slot due
to padding rules.

Direct commit to stable/13 because this is not relevant to main.

Approved by:		re@ (gjb)
Sponsored by:		Netflix
Reviewed by:		bz
Differential Revision:	https://reviews.freebsd.org/D34754

(cherry picked from commit aa61c28b42)
2022-04-06 11:44:54 -06:00
Kyle Evans 568f805c83 bectl: push space-in-name check down into libbe
This check was previously in `create` only, not applying to renames.  It
should really be applied at the libbe level, so that we can avoid
writing about this restriction over and over again.

While we're here: `bectl rename` always succeeds, even when it doesn't.
Start returning the error.

Approved by:	re (gjb)
Reported By:	Christian McDonald <cmcdonald netgate com>

(cherry picked from commit dadb9c7093)
(cherry picked from commit 227e52a9c0)
2022-04-06 09:32:51 -05:00
Kyle Evans 41e0b07a5e bectl: add some discussion about boot environment layouts
Discuss the standard type of layout, as well as the "deep" BE layout,
and some of the properties of both.  Point the various -r flags at this
new section, to help users understand which they're working with and
what the -r flag is actually doing. Note that we may just deprecate the
-r flag in future versions, but the flag will be recognized as a NOP at
that point.

Approved by:	re (gjb)

(cherry picked from commit c0f846ff23)
(cherry picked from commit 0e90da6549)
2022-04-06 09:32:48 -05:00
Kyle Evans 99931db675 libbe: fix be_mounted_at() with props after bootonce
propinfo.bootonce was filled with garbage, leading to a segfault later
during prop building.  Initialize it to NULL.

Approved by:	re (gjb)

(cherry picked from commit d155d8e138)
(cherry picked from commit 6ce8e35cea)
2022-04-06 09:32:44 -05:00
Kyle Evans b8f5e2765d libbe: pull props for the correct dataset in be_mounted_at()
The props feature to this API was added as a "just in case", with no
planned consumer.  It turns out that it was implemented incorrectly,
tapping out props for the BE root (BE's parent) rather than the BE
itself in all cases.

Fetch properties for the dataset that's actually mounted at the queried
path.

Approved by:	re (gjb)
Reported by:	Christian McDonald <cmcdonald netgate com>

(cherry picked from commit 31190aa02e)
(cherry picked from commit bed9c972ae)
2022-04-06 09:32:31 -05:00
Martin Matuska 9c1ad063e5 libarchive: merge vendor bugfixes
Bugfixes:
  IS #1685 and OSS-Fuzz #38764 (security):
    (ISO reader) fix possible heap buffer overflow in read_children()
  IS #1715 and OSS-Fuzz #46279 (security):
    (RARv4 reader) fix heap-use-after-free in run_filters()

Approved by:	re (gjb)

(cherry picked from commit 9f690fcfdc)
(cherry picked from commit 43a449f2f1)
2022-04-06 13:32:07 +02:00
Ed Maste 7e87e677f4 Bump newvers.sh for 13.1-RC1 advisories
Approved by:	so, re (implicit)
2022-04-05 23:28:41 -04:00
Vincenzo Maffione 7c55c52696 netmap: Fix TOCTOU vulnerability in nmreq_copyin
The total size of the user-provided nmreq was first computed and then
trusted during the copyin. This might lead to kernel memory corruption
and escape from jails/containers.

Reported by: Lucas Leong (@_wmliang_) of Trend Micro Zero Day Initiative
Security: CVE-2022-23084
MFC after:	3 days

(cherry picked from commit 3937299165)
(cherry picked from commit 9f600a260a)

Approved by:	so, re (implicit)
2022-04-05 23:24:05 -04:00
Vincenzo Maffione 9d354cf6e1 netmap: Fix integer overflow in nmreq_copyin
An unsanitized field in an option could be abused, causing an integer
overflow followed by kernel memory corruption. This might be used
to escape jails/containers.

Reported by: Reno Robert and Lucas Leong (@_wmliang_) of Trend Micro
Zero Day Initiative
Security: CVE-2022-23085

(cherry picked from commit 694ea59c70)
(cherry picked from commit 9df8dd3ea3)

Approved by:	so, re (implicit)
2022-04-05 23:23:51 -04:00
Bjoern A. Zeeb 00cc1ce78d net80211: validate Mesh ID length in ieee80211_parse_beacon
Reported by:	m00nbsd working with Trend Micro Zero Day Initiative

(cherry picked from commit fb8c87b4f3)
(cherry picked from commit 72617f9246)

Approved by:	so, re (implicit)
2022-04-05 21:56:33 -04:00
Mark Johnston 5a28d8befd bhyve: validate e82545 checksum offset field
Reported by:	Mehdi Talbi, Synacktiv

(cherry picked from commit b0aa20bec5)
(cherry picked from commit 53f7220947)

Approved by:	so, re (implicit)
2022-04-05 21:56:21 -04:00
Bjoern A. Zeeb 871bfac8b2 LinuxKPI: 802.11: fix RSSI (and NF)
As in 4a22cd6c4e nf and rss should be
signed and not unsigned.  Change the types in the header and while
here change a magic number to a define as done elsewhere (value does
not change).

When calculating c_rssi we need to make it relative so subtract nf.
And while here improve the debug output.

This will hopefully fix ifconfig wlanN list scan S:N output which
tools use to chose a BSSID and help net80211 internal calculations.

Sponsored by:	The FreeBSD Foundation
Approved by:	re (gjb)

(cherry picked from commit 60970a328e)
(cherry picked from commit 7b9d8e33bc)
2022-04-05 19:11:00 +00:00
Bjoern A. Zeeb a7352cbd4d net80211: correct types for nf and rssi
NF and RSSI should be signed and not unsigned to avoid problems.
Change the type accordingly.

Sponsored by:	The FreeBSD Foundation
Approved by:	re (gjb)

(cherry picked from commit 4a22cd6c4e)
(cherry picked from commit 7311128e69)
2022-04-05 19:11:00 +00:00
Bjoern A. Zeeb 681b6a95f7 LinuxKPI: 802.11: fix compat code for i386
Compiling another driver on i386 revealed two problems:
- ieee80211_tx_info.status.status_driver_data space needs to be
  calculated.  While a pointer is 32bit vm_paddr_t is 64 bit on i386
  so we didn't fit more than one of these in but needed more space.
- the arguments to ieee80211_txq_get_depth() are expected to
  unsigned long and not uint64_t.

No user noticable changes.

Sponsored by:	The FreeBSD Foundation
Approved by:	re (gjb)

(cherry picked from commit 86220d3cbd)
(cherry picked from commit 2a8e509ba3)
2022-04-05 19:11:00 +00:00
Ed Maste 7b03cfcb24 fstyp: detect Raspberry Pi Pico boot filesystem as FAT
fstyp looks for a 0x55 0xAA signature at offset 510, but this is not
required by specifications and is not provided by the Raspberry Pi Pico
bootloader.

We should really remove the signature check and implement a more
comprehensive BPB validation instead, but it will require more
investigation and testing.  For now just add a special case for the
Raspberry Pi Pico bootloader, to avoid introducing regressions or new
false positives.

PR:		262896
Reviewed by:	delphij
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34699

(cherry picked from commit 868c1b8431)
(cherry picked from commit 27c2f016b8)
(cherry picked from commit e06ce938dd)

Approved by:	re (gjb)
2022-04-05 14:54:04 -04:00
Piotr Kubaj f17fa892de powerpc: implement __clear_cache
Merge LLVM commit 81f5c6270cdfcdf80e6296df216b696a7a37c8b5.

This fixes runtime of most notably pcre libraries (currently patched in ports),
and probably also other ports since currently __clear_cache() just calls
SIGABRT on powerpc.

Reviewed by:	dim
Differential Revision: https://reviews.freebsd.org/D34736
Approved by:	re (gjb)

(cherry picked from commit 57b6ac48a9)
(cherry picked from commit 16c3f5d03e)
2022-04-05 16:51:27 +02:00
Colin Percival ce528519ec uart(4): Add a concept of "unique" serial devices
FreeBSD detects serial ports twice: First, very early in the boot
process, in order to obtain a usable console; and second, during
the device probe/attach process.  When a UART is discovered during
device probing, FreeBSD attempts to determine whether it is a
device which was already being used as a console; without this,
the console doesn't work in userland.

Unfortunately it's possible for a UART to be mapped to a different
location in memory when it is discovered on a bus than it has when
it is announced via the ACPI SPCR table; this breaks the matching
process, which relies on comparing bus addresses.

To address this, we introduce a concept of "unique" serial devices,
i.e. devices which are guaranteed to be present *only once* on any
system.  If we discover one of these during device probing, we can
match it to a same-PCI-vendor-and-device-numbers console which was
announced via the ACPI SPCR table, regardless of the differing bus
addresses.

At present, the only unique serial device is the "Amazon PCI serial
device" (vendor 0x1d0f, device 0x8250) found in some EC2 instances.
This unbreaks the serial console on those systems.

Reviewed by:	imp
Approved by:	re (gjb)
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D34703

(cherry picked from commit ad93649d23)
(cherry picked from commit 5cc5cd739e)
2022-04-05 06:32:24 -07:00
Andrew Gallatin 3aad5b1fe2 cxgbe: fix enabling lro & rxtimestamps
A recent change caused iq flags, like LRO, to be set before
init_iq(). However, init_iq() clears those flags, so they
became effectively impossible to set.   This change moves
the initializion of these flags to after the call to init_iq().
This fixes LRO.

Differential Revision: https://reviews.freebsd.org/D30460
Reviewed by: np, rrs
Sponsored by: Netflix
Fixes: 43bbae1948

(cherry picked from commit df8437a93d)
(cherry picked from commit 392d7f0269)

Approved by:	re@ (gjb@)
2022-04-04 13:05:03 -07:00
Xin LI f5196112e8 lib/libz: remove ZLIBprivate_1.0 namespace.
These symbols were hidden and no longer exposed, and were never exposed in headers.

MFC after:	3 days

(cherry picked from commit a7f127b653)
(cherry picked from commit c4727a47f1)

Approved by:	re (gjb)
2022-04-04 16:02:13 -04:00
Xin LI c022121396 sys/contrib/zlib: Always define Z_U8 and Z_U4
This is a temporary hack for zlib to make sure that the library
still builds when building with Z_SOLO (used in kernel and loader),
as zlib is depending on limits.h which is only available in STDC
case.

PR:		kern/262977
MFC after:	3 days

(cherry picked from commit 0a21252adf)

Approved by:	re (gjb, early MFC)

(cherry picked from commit 9587a10b42)

Approved by:	re (gjb)
2022-04-04 12:54:20 -04:00
Xin LI 8b3a5cdcf0 MFV 7b495a2a7a (zlib): Correct incorrect inputs provided to the CRC
functions.

MFC after:	3 days

(cherry picked from commit c61bc1110c)
(cherry picked from commit 6b0e0c9e95)

Approved by:	re (gjb)
2022-04-04 12:54:11 -04:00
Xin LI 91f57c80de MFV c144cc5479: zlib 1.2.12.
MFC after:	3 days
Relnotes:	yes

(cherry picked from commit cd8822075a)
(cherry picked from commit 6349675dec)

Approved by:	re (gjb)
2022-04-04 12:54:01 -04:00
Ed Maste aef190f298 mpr/mps/mpt: verify cfg page ioctl lengths
*_CFG_PAGE ioctl handlers in the mpr, mps, and mpt drivers allocated a
buffer of a caller-specified size, but copied to it a fixed size header.
Add checks that the size is at least the required minimum.

Note that the device nodes are owned by root:operator with 0640
permissions so the ioctls are not available to unprivileged users.

This change includes suggestions from scottl, markj and mav.

Two of the mpt cases were reported by Lucas Leong (@_wmliang_) of
Trend Micro Zero Day Initiative; scottl reported the third case in mpt.
Same issue found in mpr and mps after discussion with imp.

Reported by:	Lucas Leong (@_wmliang_), Trend Micro Zero Day Initiative
Reviewed by:	imp, mav
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34692

(cherry picked from commit 8276c4149b)
(cherry picked from commit 0b29e1b9f9)

Approved by:	re (gjb)
2022-04-04 12:24:05 -04:00
Mark Johnston 367d0c7d66 pf: Initialize the table entry zone limit at initialization time
The limit may later be updated by the "set limit" directive in pf.conf.
UMA does not permit a limit to be set on a zone after any items have
been allocated from a zone.

Other UMA zones used by pf do not appear to be susceptible to this
problem: they either set a limit at zone creation time or never set one
at all.

Approved by:	re (gjb)
PR:		260406
Reviewed by:	kp
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 7d1ab86691)
(cherry picked from commit 1487f84223)
2022-04-04 10:04:14 -04:00
Andrew Turner b57e321175 Treat cache write as a read in arm64 data faults
On arm64 we can ask the hardware to perform cache operations from
userspace. These require read permission however when the memory is
unmapped the kernel will receive a write exception. Add a check to
see if the cause of the exception is from the cache and pass a memory
read fault type to the vm subsystem.

PR:		262836
Reported by:	dch
Approved by:	re (gjb)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 029c1c4828)
(cherry picked from commit 004da2d51f)
2022-04-01 12:15:08 +01:00
Xin LI c093f9a6fc MFS 26e8bb3: MFC cc68614, ac69e5d, 7ed8e14: Update contrib/expat to 2.4.7.
(cherry picked from commit cc68614da8)
(cherry picked from commit ac69e5d471)
(cherry picked from commit 7ed8e142a0)
(cherry picked from commit 26e8bb3a4e)
Approved by:	re (gjb)
2022-03-31 23:28:18 -07:00
Warner Losh de78b2b272 bsd-family-tree: macOS 11 and macOS 12
Sponsored by:		Netflix
Approved by: re@ (delphij@)

(cherry picked from commit 4fc5a607fd)
(cherry picked from commit 6292dace82)
2022-03-31 22:56:13 -06:00
Warner Losh ef1582bebf bsd-family-tree: Dragonfly 6.2.1 release
Sponsored by:		Netflix
Approved by: re@ (delphij@)

(cherry picked from commit d2cc7bff4d)
(cherry picked from commit 137ef89271)
2022-03-31 22:56:10 -06:00
Warner Losh 41bb6c24bd bsd-family-tree: Add OpenBSD 7.0
Sponsored by:		Netflix
Approved by: re@ (delphij@)

(cherry picked from commit 754cf44d99)
(cherry picked from commit b54988faf9)
2022-03-31 22:56:05 -06:00
Warner Losh 1728f5bb4e bsd-family-tree: Add FreeBSD 12.3
FreeBSD 12.3 wasn't added when it was released. Add it now.

Sponsored by:		Netflix
Approved by: re@ (delphij@)

(cherry picked from commit 58e6bbc5ac)
(cherry picked from commit af0b54d42a)
2022-03-31 22:56:01 -06:00
Warner Losh 1986a665bf bsd-family-tree: Add 2.8BSD relationship to Research 7th edition
In the 2BSD line, the 2.8BSD tapes were the first ones to include a
kernel, both source and a bootable tape. This was an AT&T V7 kernel,
with a number of bug fixes; new features in use at Berkeley; performance
enhancements that were circulating to V7 in the licensee community; and
build system changes. Based on the TUHS archives, it contains none of
the V32 changes, however.

In addition to the source code analysis, Mike Karels relates the story
of how his group lost a customizes to V6 on a PDP-11/40 due to a disk
crash. Since V7 just came out and Bill Jolitz had just brought that up
elsewhere, they replaced their customized V6 with a V7 system, and that
base would eventually become 2.8BSD. (Quarter Century of Unix)

Given both lines of evidence, add a direct line from V7 Unix to 2.8BSD.

Also confirmed that the V6 line to 1BSD and 2BSD was appropriate. 1BSD
and 2BSD included ashell(1) and ex(1). ashell(1) was derived from v6
hell. ex(1) was an enhanced v6 ed.  2.8BSD included process control and
user-land utilities from 4.1BSD

Discussed with:		Clem Cole, Diomidis Spinellis (dds)
Differential Revision:	https://reviews.freebsd.org/D30883
Approved by: re@ (delphij@)

(cherry picked from commit 520a2401a6)
(cherry picked from commit b811e00246)

Sponsored by:		Netflix
2022-03-31 22:55:55 -06:00
Warner Losh c17257605b bsd-family-tree: add DragonFly 6.0.0
Tagged on May 8, 2021.

Sponsored by:		Netflix
Approved by: re@ (delphij@)

(cherry picked from commit 779b70a226)
(cherry picked from commit 79afe55982)
2022-03-31 22:55:49 -06:00
Warner Losh 35e1e1f835 bsd-family-tree: Add NetBSD 9.2
NetBSD 9.2 was released on May 12, 2021

Submitted by:		Martin Husemann
Sponsored by:		Netflix
Approved by: re@ (delphij@)

(cherry picked from commit 71a071be1c)
(cherry picked from commit 127f5e8969)
2022-03-31 22:55:43 -06:00
Maxim Konovalov 7de0323987 Releases history update
Add DragonFly 5.8.1, OpenBSD 6.7, FreeBSD 11.4, DragonFly 5.8.2,
DragonFly 5.8.3, OpenBSD 6.8, NetBSD 9.1, FreeBSD 13.0, OpenBSD 6.9.

Approved by: re@ (delphij@)

(cherry picked from commit f0c914baac)
(cherry picked from commit 04324346c9)
2022-03-31 22:55:20 -06:00
Mark Johnston 3ca78fba96 libc: Restore fp state upon flush error in fputc
This is akin to commit bafaa70b6f.

Approved by:	re (gjb)
Reported by:	Guy Yur <[email protected]>
Fixes:		86a16ada1e
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 6e13794fbe)
(cherry picked from commit 7be0c792c4)
2022-03-31 11:56:37 -04:00
Glen Barber 6fe2900157 13.1: update to RC1
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-03-30 20:17:39 -04:00
D Scott Phillips 8f95edc10d arm64: Add explicit barrier after address translation instruction
Following ARMARM sec D5.2.11, which says:

> Where an instruction results in an update to a System register,
> as is the case with the AT * address translation instructions,
> explicit synchronization must be performed before the result is
> guaranteed to be visible to subsequent direct reads of the
> PAR_EL1.

Approved by:	re (gjb)
Reviewed By:	andrew
MFC after:	3 weeks
Sponsored by:	Ampere Computing
Differential Revision:	https://reviews.freebsd.org/D34665

(cherry picked from commit 7be7bd6775)
(cherry picked from commit 0e19a22dd1)
2022-03-30 13:51:43 -07:00
D Scott Phillips 33a625b1d6 arm64: pmap: Mask VA operand in TLBI instructions
Bits 43:0 of the TLBI operand are bits 55:12 of the VA.  Leaving
bits 63:55 of the VA in bits 51:44 of the operand might wind up
setting the TTL field (47:44) and accidentally restricting which
translation levels are flushed in the TLB.

Approved by:	re (gjb)
Reviewed By:	andrew
MFC after:	3 days
Sponsored by:	Ampere Computing
Differential Revision:	https://reviews.freebsd.org/D34664

(cherry picked from commit a693a30038)
(cherry picked from commit 2c013d142b)
2022-03-30 13:51:37 -07:00
Andrew Turner cf9f384de9 Fix arm64 TLB invalidation with non-4k pages
When using 16k or 64k pages atop will shift the address by more than
the needed amount for a tlbi instruction. Replace this with a new macro
to shift the address by 12 and use PAGE_SIZE in the for loop to let the
code work with any page size.

Approved by:	re (gjb)
Reviewed by:	alc, markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34516

(cherry picked from commit 813738faba)
(cherry picked from commit 89166c063a)
2022-03-30 13:50:58 -07:00
Ed Maste 331335c1b8 Fix kernel build without INET or INET6
Reported by:	Gary Jennejohn
Fixes:		ff3a85d324 ("[lltable] Add per-family lltable ...")
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 818952c638)
(cherry picked from commit 85f3c0a1c3)

Reviewed by:	brooks, melifaro
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33718

(cherry picked from commit a6668e31aa)
(cherry picked from commit 1c487a5d3d)

Approved by:	re (gjb)
2022-03-30 19:06:40 +00:00
Bjoern A. Zeeb ecb691143d LinuxKPI: 802.11: various updates for iwlwifi stability and upcoming rtw
Various updates to the internals of the LinuxKPI 802.11 implementation.
Most notably improving state machine handling for de-assoc/de-auth and
always creating a new station as net80211 does and mac80211 seems to
do.  This avoids firmware crashes for iwlwifi and often panics and
lead to more stability.
Some other secondary changes are in order to support upcoming drivers
so that we could possibly provide them out-of-tree for 13.1.

- implement ieee80211_beacon_loss()

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit bb81db90f7)
(cherry picked from commit 24c2117baf)

- factor out lkpi_lsta_alloc() from lkpi_ic_node_alloc()

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 4f61ef8b78)
(cherry picked from commit 34f8e38ea7)

- factor out dtim/tsf updates

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit fa8f007de9)
(cherry picked from commit bc472e0a3e)

- rework sta state machine compatibility

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit d9f59799fc)
(cherry picked from commit 67674c1cb1)
(cherry picked from commit 471a438a00)

- improve lkpi_80211_mo_sta_state() for non (*sta_state)

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 878fb1e575)
(cherry picked from commit eb58026597)

- use cfg80211_chandef_create()

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 4a07abdeb8)
(cherry picked from commit 4836b8ac0e)

- make lkpi_ic_set_channel() unconditional

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit b2cf3c2125)
(cherry picked from commit beaed0d4b5)

- check IEEE80211_FEXT_SCAN_OFFLOAD on vap

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 768dd32a16)
(cherry picked from commit 39bc4b2949)

- remove special handling for (*ic_scan_curchan)

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 321735f451)
(cherry picked from commit 5f88604cf7)

- improve hw_scan fallback to sw_scan

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 196cfd0b2e)
(cherry picked from commit a1272e7d96)

- 802.11: cleanup debugging

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 9d9ba2b79b)
(cherry picked from commit e269958566)

Approved by:	re (gjb)
2022-03-30 15:47:32 +00:00
Bjoern A. Zeeb fef73ef9c2 LinuxKPI: skbuff: fix skb_queue_splice_init()
In skb_queue_splice_init() we set a next value and then used that new
value to further update the remaining linking rather than the original
value.  Introduce another temporary variable 'n' to hold the original
value and use that.
While here rename q and h to from and to as otherwise it was too
confusing to read.

Also initialize skb->prev and skb->next to point to skb itself if
for nothing else at least to aid debugging.

Approved by:	re (gjb)
Reported by:	phk (panic in iwl_txq_reclaim)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 6a8973c332)
(cherry picked from commit 32d1d7fee6)
2022-03-30 15:47:25 +00:00
Bjoern A. Zeeb 63ec594747 LinuxKPI: allow bsddriver name to be set for PCI
Allow a driver to overwrite the bsddriver name (we use for pci and
for wlan parent devices).  This allows us to to set
.bsddriver.name in struct pci_driver passed to module_pci_driver()
and with that set the BSD driver name while retaining the Linux .name
one.

This is helpful for divers which have different parts depending on
chipset and with that would change driver names which is highly
confusing especially for configuration.   One example is an upcoming
rtw88 driver which would be rtw_8822be or rtw_8822ce depending on
chipset.

Approved by:	re (gjb)
Sponsored by:	The FreeBSD Foundation
Reviewed by:	emaste, hselasky
Differential Revision: https://reviews.freebsd.org/D34653

(cherry picked from commit 81d058df6d)
(cherry picked from commit 00450eeab2)
2022-03-30 15:47:18 +00:00
Bjoern A. Zeeb a85cf68895 LinuxKPI: pci: implement pci_upstream_bridge()
Allow drivers to query the "upstream PCI bridge".
Currently we point back to ourselves on pdev->bus->self rather than
to the parent PCI bridge.
We keep this as status-quo with an extra comment and only on-demand
allocate a pci_dev for the parent bridge if we are asked for in
pci_upstream_bridge().
When releasing the pci_dev we check if pdev->bus->self has changed
and call pci_dev_put() to release the reference count on the parent
bridge as well.

This code moves pci_is_root_bus() higher up in pci.h but no functional
change there.

Approved by:	re (gjb)
Sponsored by:	The FreeBSD Foundation
Reviewed by:	hselasky, (jhb some earlier)
Thanks to:	wulf for handling drm-kmod
Differential Revision: https://reviews.freebsd.org/D34305

(cherry picked from commit b3b836251f)
(cherry picked from commit 5013623384)
2022-03-30 15:46:52 +00:00
Bjoern A. Zeeb 14626b83ef iwlwifi: update man pages
Update man pages given auto-loading is now enabled by default and
no user configuration is needed to load the driver.
Also note that the iwlwifi driver will appear the first time in 13.1-R.

Sponsored by:	The FreeBSD Foundation
Relnotes:	yes
Approved by:	re (gjb)

(cherry picked from commit abf6e1a49e)
(cherry picked from commit 8ed3b807ca)
2022-03-30 15:46:26 +00:00
Bjoern A. Zeeb 7380d82b53 LinuxKPI: pci.h MODULE_DEVICE_TABLE to MODULE_PNP_INFO
Implement MODULE_PNP_INFO() support in LinuxKPI for the Linux
MODULE_DEVICE_TABLE.

This will allow us to auto-load LinuxKPI PCI drivers (drm-kmod do
not currently as they attach to vgapci0 which in turn grabs the PCI
to my understanding) and make any loading from loader or kld_list in
rc.conf unnecessary; see devmatch(8) for more information.

We need to ensure there is a DRIVER_MODULE() (or probably just
a DECLARE_MODULE but that makes not much difference) before the
MODULE_PNP_INFO (which we otherwise would not need).

Approved by:	re (gjb)
Sponsored by:	The FreeBSD Foundation
Reviewed by:	imp, hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D26651

(cherry picked from commit 5493c6277a)
(cherry picked from commit a94b233d5d)
2022-03-30 15:46:17 +00:00
Bjoern A. Zeeb 3b4a991fa6 iwlwifi: adjust the LinuxKPI pci return for now
Rather than having LinuxKPI return BUS_PROBE_DEFAULT, return
"one less" so that on conflict of IDs others would be preferred.

This means that iwm(4) will attach instead of iwlwifi(4) for the
chipsets iwm(4) supports and iwlwifi(4) only for the other--in iwm(4)
unsupported--chipsets.  This is done so that we can enable auto-loading
of drivers but for the upcoming 13.1-Release people with working iwm(4)
will not yet be affected by iwlwifi(4).

Sponsored by:	The FreeBSD Foundation
Approved by:	re (gjb)

(cherry picked from commit 3d248a914d)
(cherry picked from commit fd2c8fe44c)
2022-03-30 15:45:54 +00:00
Bjoern A. Zeeb c325d9edef LinuxKPI: allow a driver to override the default pci probe result
Add bsd_probe_return which a driver can set in their 'struct pci_driver'
definition to set a driver-sepcific LinuxKPI pci return value.
This is helpful in case of multiple drivers with overlapping IDs,
such as iwlwifi(4) and iwm(4).

Contrary to an earlier version we now assume 0 is not BUS_PROBE_SPECIFIC
(which no driver should really return these days) but the bss initialized
value (bsd_probe_return unset) and we will return BUS_PROBE_DEFAULT.

Approved by:	re (gjb)
Suggested by:	jhb
Reviewed by:	jhb
Reviewed by:	hselasky, imp (earlier versions)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33915

(cherry picked from commit b91dd79ba3)
(cherry picked from commit 3166cea632)
2022-03-30 15:45:45 +00:00
Bjoern A. Zeeb 1717f1606b LinuxKPI: remove duplicate include
Remove a duplicate bus.h include from pci.h.

Sponsored by:	The FreeBSD Foundation
Approved by:	re (gjb)

(cherry picked from commit fbedd9d708)
(cherry picked from commit a8c3d6b716)
2022-03-30 15:45:21 +00:00
Bjoern A. Zeeb eb730e379a net80211: introduce (*iv_update_bss)()
Introduce (*iv_update_bss)() with a default implementation to allow
drivers to overload/intercept the time when we swap iv_bss.

This helps firmware based drivers to synchronize state with firmware.
Otherwise, for some state changes, we begin with one ni (and in
LinuxKPI lsta) and try to finish with another ni (and a new lsta
in different state) and may no longer have access to the previous state.
This also saves us from constantly checking for ni changes complicating
code.

No functional changes intended.

Sponsored by:	The FreeBSD Foundation
Approved by:	re (gjb)

(cherry picked from commit 91b4225aa1)
(cherry picked from commit dd39ea27f3)
2022-03-30 15:44:56 +00:00
Bjoern A. Zeeb 708928f4db net80211: improve one debug logging
When forcing DEUATH in ieee80211_sta_join1() log the current state
we are coming from as well.  Note this isn't always the state we
are expecting as iv_state was updated already, so contrary to the
comment we usually do not see RUN there.
Leave a comment earlier with regards to this as well.

Sponsored by:	The FreeBSD Foundation
Approved by:	re (gjb)

(cherry picked from commit 453d1a90f8)
(cherry picked from commit f39c5ab350)
2022-03-30 15:44:34 +00:00
Bjoern A. Zeeb 1c6abf864e bhyve: Do not remove guest physical addresses from IOMMU host domain
This permits I/O devices on the host to directly access wired memory
dedicated to guests using passthru devices.  Note that wired memory
belonging to guests that do not use passthru devices has always been
accessible by I/O devices on the host.

bhyve maps guest physical addresses into the user address space of
the bhyve process by mmap'ing /dev/vmm/<vmname>.  Device models pass
pointers derived from this mapping directly to system calls such as
preadv() to minimize copies when emulating DMA.  If the backing store
for a device model is a raw host device (e.g. when exporting a raw disk
device such as /dev/ada<n> as a drive in the guest), the host device
driver (e.g. ahci for /dev/ada<n>) can itself use DMA on the host
directly to the guest's memory.  However, if the guest's memory is
not present in the host IOMMU domain, these DMA requests by the host
device will fail without raising an error visible to the host device
driver or to the guest resulting in non-working I/O in the guest.

It is unclear why guest addresses were removed from the IOMMU host domain
initially, especially only for VM's with a passthru device as the
host IOMMU domain does not affect the permissions of passthru devices,
only devices on the host.

A considered alternative was using bounce buffers instead (D34535
is a proof of concept), but that adds additional overhead for unclear
benefit.

This solves a long-standing problem when using passthru devices and
physical disks in the same VM.

Approved by:	re (gjb)
Thanks to:	grehan (patience and help)
Thanks to:	jhb (for improving the commit message)
PR:		260178, 215740
Reviewed by:	grehan, jhb
Differential Revision: https://reviews.freebsd.org/D34607

(cherry picked from commit 246c398145)
(cherry picked from commit dd113f67df)
2022-03-30 15:33:47 +00:00
Ed Maste 015991cb97 Clear non-x86 compat stat syscall kernel stack memory disclosure
32-bit architectures other than i386 have 64-bit time_t which results
in a struct timespec with 12 bytes for tv_sec and tv_nsec, and 4 bytes
of padding.  Zero the padding holes in struct stat32 and struct
freebsd11_stat32.

i386 has 32-bit time_t; struct timespec is 8 bytes and has no padding.

Found by inspection, prompted by a report by Reno Robert of Trend Micro
Zero Day Initiative.  The originally reported issue (ZDI-CAN-14538) is
already fixed in all supported FreeBSD versions (it was addressed
incidentally as part of the 64-bit inode project).

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34709

(cherry picked from commit f90cd1ae30)
(cherry picked from commit ccd701d27a)

Approved by:	re (gjb)
2022-03-29 21:25:34 -04:00
Warner Losh abda5677f2 devd: Add rtw to wireless list
rtw88 and rtw89 are coming soon, so add them here now

Approved by:		re@ (gjb)
Sponsored by:		Netflix
MFC After:		1 day

(cherry picked from commit dea368bc5e)
(cherry picked from commit cba6eb5d31)
2022-03-29 17:54:19 -06:00
Warner Losh a5ece99d22 devd: correct wifi regexp
Correct the wifi regexp to include iwlwifi and remove wi driver that was
has been retired.

Approved by:		re@ (gjb)
Sponsored by:		Netflix

(cherry picked from commit e0ab0ff104)
(cherry picked from commit eeec49e0b3)
2022-03-29 17:54:16 -06:00
Warner Losh 713595ca49 devd: remove the scsi regexp
We don't really use the scsi regexp for anything. The rescan was a
workaround that was fixed a long time ago and has been disabled for
ages. And the regexp was incomplete.

Approved by:		re@ (gjb)
Sponsored by:		Netflix

(cherry picked from commit 926e825ef8)
(cherry picked from commit cb95daaa91)
2022-03-29 17:54:00 -06:00
Martin Matuska c19caf8852 libarchive: merge vendor bugfixes
Bugfixes:
  IS #1672 and OSS-Fuzz #38766:
    (zip reader) fix possible out-of-bounds read in zipx_lzma_alone_init()
  PR #1676: (mtree reader) remove the unused variable "detected_bytes"
  PR #1674: (doc) fix use of At mdoc(7) macro in cpio.5

Approved by:	re (gjb)

(cherry picked from commit 0c9c2eb394)
(cherry picked from commit 60338b8069)
2022-03-29 15:53:15 +02:00
Martin Matuska 99c3f15774 zfs: merge openzfs/zfs@52bad4f23 (zfs-2.1-release) into stable/13
OpenZFS release 2.1.4

Notable upstream pull request merges:
  #13219 FreeBSD: add missing replay check to an assert in zfs_xvattr_set
  #13220 module: freebsd: avoid a taking a destroyed lock in zfs_zevent bits
  #13221 Fix ACL checks for NFS kernel server

Obtained from:	OpenZFS
OpenZFS tag:	zfs-2.1.4
OpenZFS commit:	52bad4f23d
Relnotes:	yes
Approved by:	re (gjb)

(cherry picked from commit c088e4d539)
2022-03-29 15:50:47 +02:00
Mateusz Guzik 1544cd332b amd64: bring back asm bcmp, shared with memcmp
Turns out clang converts "memcmp(foo, bar, len) == 0" and similar to
bcmp calls.

Reviewed by:	emaste (previous version), jhb (previous version)
Differential Revision:	https://reviews.freebsd.org/D34673
Approved by:	re (gjb)

(cherry picked from commit fbc002cb72)
(cherry picked from commit c5890784f6)
2022-03-29 12:40:32 +00:00
Piotr Kubaj d30aac1297 riscv: actually enable sanitizers
1. Backport https://github.com/llvm/llvm-project/commit/b475ce39e8b1de3a70ea242473f136a567be46e3.
2. Enable libclang_rt for riscv.

Previous commit missed it.

Reviewed by:	dim
Differential Revision: https://reviews.freebsd.org/D34543
Approved by:	re (gjb)

(cherry picked from commit 3781e77995)
(cherry picked from commit e58a146c5d)
2022-03-28 18:29:53 +02:00
Piotr Kubaj c9edea9b99 riscv: fix riscv64sf build
The library needs to have sf suffix cut off.

Differential revision:	https://reviews.freebsd.org/D34561
Reviewed by:	dim
Approved by:	re (gjb)

(cherry picked from commit 18f71c9b27)
(cherry picked from commit 78e68a3d10)
2022-03-28 18:29:53 +02:00
Alexander V. Chernikov f0b3b85d02 u3g: Add support Quectel EM12-G modem.
Submitted by:	<tda.77793 at gmail.com>
PR:		260218
Approved by:    re(gjb)
MFC after:	2 weeks

(cherry picked from commit 217481a333)
(cherry picked from commit 453b4f8193)
2022-03-28 15:25:31 +00:00
Alexander V. Chernikov ce24fa9b49 ifconfig: remove debug printf introduced in 779fd05344
Reported by:	jhb
Approved by:    re(gjb)

(cherry picked from commit 656f5031c3)
(cherry picked from commit b5b97a95aa)
2022-03-28 15:25:27 +00:00
Alexander V. Chernikov 2eb4ac1e6f ifconfig: improve vlan options parsing
PR:	261136
Reported by:	Daniel O'Connor
Approved by:    re(gjb)
MFC after:	2 weeks

(cherry picked from commit 779fd05344)
(cherry picked from commit 157bf2c996)
2022-03-28 15:25:23 +00:00
Alexander V. Chernikov 9b42da2b33 linux: add sysctl to pass untranslated interface names
Reviewed by:	kib
Approved by:    re(gjb)
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D33792

(cherry picked from commit 1f70a85b4c)
(cherry picked from commit c7655e1f36)
2022-03-28 15:25:20 +00:00
Alexander V. Chernikov 0cde698678 linux: fix linux_recvmsg() MSG_PEEK flag handling
Reviewed by:	kib
Approved by:    re(gjb)
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D33790

(cherry picked from commit 96c524d8b2)
(cherry picked from commit 0b6161db7e)
2022-03-28 15:25:16 +00:00
Alexander V. Chernikov e3f2daff75 routing: Add unified level-based logging support for the routing subsystem.
Summary: MFC after:	2 weeks
Approved by:    re(gjb)
Differential Revision: https://reviews.freebsd.org/D33664

(cherry picked from commit 63f7f3921b)
(cherry picked from commit eb22b73358)
2022-03-28 15:25:12 +00:00
Alexander V. Chernikov a361584323 nhops: split nh_family into nh_upper_family and nh_neigh_family.
With IPv4 over IPv6 nexthops and IP->MPLS support, there is a need
 to distingush "upper" e.g. traffic family and "neighbor" e.g. LLE/gateway
 address family. Store them explicitly in the private part of the nexthop data.

While here, store nhop fibnum in nhop_prip datastructure to make it self-contained.

Approved by:    re(gjb)
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D33663

(cherry picked from commit 823a08d740)
(cherry picked from commit 519bdbb448)
2022-03-28 15:25:07 +00:00
Alexander V. Chernikov fdd84c3608 [lltable] Add per-family lltable getters.
Introduce a new function, lltable_get(), to retrieve lltable pointer
 for the specified interface and family.
Use it to avoid all-iftable list traversal when adding or deleting
 ARP/ND records.

Differential Revision: https://reviews.freebsd.org/D33660
Approved by:    re(gjb)
MFC after:	2 weeks

(cherry picked from commit ff3a85d324)
(cherry picked from commit ffcca53561)
2022-03-28 15:25:02 +00:00
Alexander V. Chernikov 3e624dfad1 netstat: fix nhop prepend printing.
If present, print nexthop L2 prepend data in hex.

Approved by:    re(gjb)
MFC after:	1 week

(cherry picked from commit 731bfa9f18)
(cherry picked from commit bea3efc01c)
2022-03-28 15:24:57 +00:00
Alexander V. Chernikov d64a952f8d tcp: virtualise net.inet.tcp.msl sysctl.
VNET teardown waits 2*MSL (60 seconds by default) before expiring
 tcp PCBs. These PCBs holds references to nexthops, which, in turn,
 reference ifnets. This chain results in VNET interfaces being destroyed
 and moved to default VNET only after 60 seconds.
Allow tcp_msl to be set in jail by virtualising net.inet.tcp.msl sysctl,
 permitting more predictable VNET tests outcomes.

MFC after:	1 week
Reviewed by:	glebius
Approved by:	re(gjb)
Differential Revision: https://reviews.freebsd.org/D33270

(cherry picked from commit c2c8e360d8)
(cherry picked from commit 057793e637)
2022-03-28 15:24:28 +00:00
Piotr Kubaj bf2378688d Merge LLVM commit c03fdd340356 to fix lang/rust on powerpc
Without it building rust fails with:
ld: error: CallSiteSplitting.cpp:(function llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >::operator=(llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >&&): .text._ZN4llvm15SmallVectorImplINSt3__14pairIPNS_10BasicBlockENS_11SmallVectorINS2_IPNS_8ICmpInstEjEELj2EEEEEEaSEOSB_+0xB0): relocation R_PPC_PLTREL24 out of range: -33582208 is not in [-33554432, 33554431]

Reviewed by:	dim
Approved by:	re (gjb)
Differential Revision: https://reviews.freebsd.org/D34652
MFC after:	3 days

(cherry picked from commit 9b597132ae)
(cherry picked from commit 56a4f560d4)
2022-03-28 16:15:32 +02:00
Mateusz Guzik 4e8fa94f33 vfs: add missing bits to vdropl_impl
This completes the patch which was originally meant to go in.

Spotted by:	mhorne
Fixes: c35ec1efdc ("vfs: [1/2] fix stalls in vnode reclaim by not
requeieing from vnlru")
Approved by:	re (implicit)

(cherry picked from commit 2533b5dc82)
2022-03-27 14:39:45 +00:00
Mateusz Guzik 115479c27d vfs: [2/2] fix stalls in vnode reclaim by only counting attempts
... and ignoring if they succeded, which matches historical behavior.

Reported by:	pho
Approved by:    re (gjb)

(cherry picked from commit 3a4c5dab92)
2022-03-25 14:04:00 +00:00
Mateusz Guzik b2516d2f7d vfs: [1/2] fix stalls in vnode reclaim by not requeieing from vnlru
Reported by:	pho
Approved by:	re (gjb)

(cherry picked from commit c35ec1efdc)
2022-03-25 14:03:46 +00:00
hlh-restart bbf3b7bdf8 rtsx: Call rtsx_init() on resume.
Approved by:	re (gjb)

(cherry picked from commit 1b1bab0078)
(cherry picked from commit 205fa5f0a5)
2022-03-24 13:29:59 -04:00
Allan Jude 26714a5fa2 Allow kern.ipc.maxsockets to be set to current value without error
Normally setting kern.ipc.maxsockets returns EINVAL if the new value
is not greater than the previous value. This can cause spurious
error messages when sysctl.conf is processed multiple times, or when
automation systems try to ensure the sysctl is set to the correct
value. If the value is unchanged, then just do nothing.

Approved by:	re (gjb)
PR:	243532
Reviewed by:	markj
Sponsored by:	Modirum MDPay
Sponsored by:	Klara Inc.

(cherry picked from commit c441592a0e)
(cherry picked from commit 4f69c57599)
2022-03-24 13:24:07 -04:00
Mark Johnston 9f83c6fa52 hdac: Handle interrupts racing with device suspend
- Avoid looping forever if a concurrent reset causes a read of the
  interrupt status register to return all ones.
- Lock the softc before reading the interrupt status, so as to avoid a
  similar infinite loop in hdac_one_intr().

This fixes suspend-to-S3 on some laptops.

Approved by:	re (gjb)
PR:		261207
Reviewed by:	mav, imp
Tested by:	uqs
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 077564cfdb)
(cherry picked from commit 18a3bada30)
2022-03-24 11:42:11 -04:00
Glen Barber ca2b1e3480 13.1: update to BETA3
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-03-23 20:01:49 -04:00
Mateusz Piotrowski f23b24655f zfskeys: Support autoloading of keys stored on ZFS
The zfskeys service script starts before the zfs service script, so that
dataset decryption keys are available when `zfs mount -a` is run. One of
the potential edge cases of this design is that if a key is stored on
ZFS it won't be loaded until `zfs mount -a` is issued.

In order to address that let's try to load the additional keys and mount
related ZFS datasets after the zfs script finishes its standard mounting
procedure.

PR:		262468
Reported by:	Graham Perrin <[email protected]>
Reviewed by:	allanjude
Approved by:	re (delphij)
Approved by:	allanjude (src)
Fixes:	33ff39796f Add zfskeys rc.d script for auto-loading encryption keys
Sponsored by:	Modirum
Sponsored by:	Klara Inc.
Differential Revision: https://reviews.freebsd.org/D34601

(cherry picked from commit 97aeda2243)
(cherry picked from commit 2411090f69)
2022-03-23 16:27:44 -04:00
Andrew Turner f5f567c226 Make the arm64 get_pcpu a function again
We assume the pointer returned from get_pcpu will be consistent even
if the thread is moved to a new CPU. Fix this by partially reverting
63c858a04d to make get_pcpu a function again.

Approved by:	re (gjb)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit ed30663426)
(cherry picked from commit 1169099f8f)
2022-03-23 19:46:58 +00:00
Roger Pau Monné b6370a2c00 vt/vga: ignore ACPI_FADT_NO_VGA unless running virtualized
There's too many broken hardware out there that wrongly has the
ACPI_FADT_NO_VGA bit set. Ignore it unless running as a virtualized
guest, as then the expectation would be that the hypervisor does
provide correct ACPI tables.

Reviewed by: emaste, 0mp, eugen
Sponsored by: Citrix Systems R&D
PR: 230172
Approved by: re (gjb)

(cherry picked from commit 0518832011)
2022-03-23 15:51:27 +01:00
Gordon Tetlow af3096f23b Bump version.
Approved by:	re (implicit), so
2022-03-22 09:26:07 -07:00
Philip Paeps b7e7657b02 contrib/tzdata: import tzdata 2022a
Merge commit '971fa603f2bdf16273135a00ff16c5585520c53f'

Changes: https://github.com/eggert/tz/blob/2022a/NEWS

With this merge, we return to our previous long-standing practice of
distributing the IANA Time Zone Database unmodified.

Releases of tzdb since 2021b have merged some time zones where clocks
have agreed since 1970.  The overwhelming majority of users will not be
affected by this change.  A port of the newly created global-tz fork of
the IANA Time Zone database (misc/global-tz) is available for users who
need more granular pre-1970 time zone history.

Approved by:	re (gjb)

(cherry picked from commit 8ea5af2b77)
(cherry picked from commit 5dbd160076)
2022-03-22 15:54:06 +00:00
Xin LI c083dab137 Update leap-seconds to leap-seconds.3676924800
Obtained from:	ftp://ftp.boulder.nist.gov/pub/time/leap-seconds.3676924800
Approved by:	re (gjb)
(cherry picked from commit 1d33307434)
(cherry picked from commit 08038f3cbf)
2022-03-21 19:32:15 -07:00
Glen Barber 928e649f68 13.1: Enable REPRODUCIBLE_BUILD by default
This was missed when branching releng/13.1.

Noticed by:	debdrup
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-03-21 09:50:10 -04:00
Kristof Provost 81c1d7c9c7 if_epair: build fix
66acf7685b failed to build on riscv (and mips). This is because the
atomic_testandset_int() (and friends) functions do not exist there.
Happily those platforms do have the long variant, so switch to that.

PR:		262571
MFC after:	3 days
Approved by:    re (gjb)

(cherry picked from commit 0bf7acd6b7)
2022-03-20 16:25:40 +01:00
Eugene Grosbein fa67c45842 virtio_random(8): MFC: avoid deadlock at shutdown time (regression fix)
FreeBSD 13+ running as virtual guest may load virtio_random(8) driver
by means of devd(8) unless the driver is blacklisted or disabled
via device.hints(5). Currently, the driver may prevent
the system from rebooting or shutting down correctly.

This change deactivates virtio_random at very late stage
during system shutdown sequence to avoid deadlock
that results in kernel hang.

PR:		253175
Tested by:	tom
Relnotes:	yes
Approved by:	re (gjb)

(cherry picked from commit adbf7727b3)
(cherry picked from commit 4a11315a2c)
2022-03-19 19:36:26 +07:00
Toomas Soome 2ac7903dcb WITHOUT_BOOT build option appears to include stand, failing on libsa
building libsa needs to use -I${LDRSRC} for some files.

PR:		260083
Submitted by:	Ivan Rozhuk
Approved by:	re (gjb, early MFC)

(cherry picked from commit 9633c3d874)
2022-03-19 01:18:12 +02:00
Jung-uk Kim e404b2562b OpenSSL: Merge OpenSSL 1.1.1n
Approved by:	re (delphij)

(cherry picked from commit 5ac766ab8e)
(cherry picked from commit 97fe61d5bf)
2022-03-18 09:49:32 -04:00
Dimitry Andric 874e27b5dd Build compiler-rt against libunwind, not libcxxrt
Parts of compiler-rt are also built for libgcc_eh and libgcc_s, and
these were already pointing to the libunwind unwind.h. For the sake of
consistency, also build compiler-rt itself against the libunwind
unwind.h, not the libcxxrt one.

Approved by:	re (gjb)
MFC after:	3 days

(cherry picked from commit 7ecd99fa42)
(cherry picked from commit 4c622a8f05)
2022-03-17 16:14:09 +01:00
Dimitry Andric ea9fa27b94 Remove compat hacks from libcxxrt's _Unwind_Exception
This reverts 9097e3cbca, which was in itself a revert of upstream
libcxxrt commits 88bdf6b290da ("Specify double-word alignment for ARM
unwind") and b96169641f79 ("Updated Itanium unwind"), and a
reapplication of our commit 3c4fd2463b ("libcxxrt: add padding in
__cxa_allocate_* to fix alignment").

The editors/libreoffice port will be patched to be able to cope with the
standards-compliant alignment of _Unwind_Exception and consequently,
that of __cxa_exception. The layouts and sizes of these structures
should then be completely the same for libcxxrt, libunwind and
libc++abi.

PR:		262008
Reviewed by:	emaste, jhb, theraven
Approved by:	re (gjb)
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D34488

(cherry picked from commit 72df847a94)
(cherry picked from commit 93779214f1)
2022-03-17 16:13:06 +01:00
Hans Petter Selasky 5fcfe4717a LinuxKPI: Add comment describing proper use of the on_each_cpu() function.
Sponsored by:	NVIDIA Networking
Approved by:	re (gjb)

(cherry picked from commit c6cf874c7d)
(cherry picked from commit d17c5a4f62)
2022-03-17 13:26:31 +01:00
Hans Petter Selasky cad0a51d38 lindebugfs: Make single_release() NULL safe.
Sponsored by:	NVIDIA Networking
Approved by:	re (gjb)

(cherry picked from commit a23e475c48)
(cherry picked from commit d67b2c9615)
2022-03-17 13:26:26 +01:00
Hans Petter Selasky 9a46464ad6 lindebugfs: The Linux file operations use negative return values in the kernel.
Fix sign.

Sponsored by:	NVIDIA Networking
Approved by:	re (gjb)

(cherry picked from commit 68ec2949ad)
(cherry picked from commit a16772a811)
2022-03-17 13:26:23 +01:00
Hans Petter Selasky 09fcb3900f lindebugfs: Zero the linux_file structure before use.
This avoids clients using garbage values on the stack and makes
debugging easier.

Sponsored by:	NVIDIA Networking
Approved by:	re (gjb)

(cherry picked from commit 88a29d89eb)
(cherry picked from commit b5cc52c21d)
2022-03-17 13:26:19 +01:00
Wuyang Chung a14408a531 newfs(8): Fix a bug in initialization of sblock.fs_maxbsize .
Fixes:		1c85e6a35d (SVN r98542)
Pull Request:	https://github.com/freebsd/freebsd-src/pull/587
Sponsored by:	NVIDIA Networking
Approved by:	re (gjb)

(cherry picked from commit c5f549c1e0)
(cherry picked from commit 4391c305e8)
2022-03-17 13:26:14 +01:00
Hans Petter Selasky 1e126edff1 usbtest: Fix issue when multiple devices are sharing same USB vendor and product ID.
When there are multiple devices sharing the same USB vendor and product ID,
the wrong device may be selected. Fix this by also matching the bus and
device address, ugen<X>.<Y> .

Sponsored by:	NVIDIA Networking
Approved by:	re (gjb)

(cherry picked from commit 16346e1401)
(cherry picked from commit 90afe1886f)
2022-03-17 13:26:10 +01:00
Hans Petter Selasky 0520911be8 xhci(4): Add quirk for "Fresco Logic FL1009 USB3.0 xHCI Controller".
Submitted by:	John F Carr <[email protected]>
Sponsored by:	NVIDIA Networking
Approved by:	re (gjb)

(cherry picked from commit 19837718ab)
(cherry picked from commit 19b779498c)
2022-03-17 13:26:07 +01:00
Hans Petter Selasky 96ba69963a xhci(4): Add quirk for "TUSB73x0 USB3.0 xHCI Controller".
Tested by:	br@
Sponsored by:	NVIDIA Networking
Approved by:	re (gjb)

(cherry picked from commit 33cbbf268f)
(cherry picked from commit ea318f1ad1)
2022-03-17 13:26:03 +01:00
Hans Petter Selasky 56ef5ad21f Make sure the avr32dci_odevd structure is used.
This fixes a compilation error.

Sponsored by:	NVIDIA Networking
Approved by:	re (gjb)

(cherry picked from commit 3f5054862a)
(cherry picked from commit cea6dbdf1b)
2022-03-17 13:25:59 +01:00
Hans Petter Selasky cd60f3f39a Factor out repeated code in the USB controller drivers to avoid bugs
computing the same isochronous start frame number over and over again.

PR:		257082
Sponsored by:	NVIDIA Networking
Approved by:	re (gjb)

(cherry picked from commit 8fc2a3c417)
(cherry picked from commit f52783fcf5)
(cherry picked from commit cf48d1f771)
(cherry picked from commit 9997736943)
2022-03-17 13:25:56 +01:00
Hans Petter Selasky 3e40a842aa Make sure the XHCI driver obeys the isochronous scheduling threshold value
as given by the XHCI hardware parameters to avoid scheduling isochronous
transfers too early.

Sponsored by:	NVIDIA Networking
Approved by:	re (gjb)

(cherry picked from commit d038463bd2)
(cherry picked from commit 2db063c4ce)
2022-03-17 13:25:52 +01:00
Hans Petter Selasky 723a1d1067 Let the xhci_hw_root structure span exactly XHCI_PAGE_SIZE bytes by increasing
the number of completion event TRBs. This avoids wasting memory.

Sponsored by:	NVIDIA Networking
Approved by:	re (gjb)

(cherry picked from commit e036ee6ce2)
(cherry picked from commit afeeccfbed)
2022-03-17 13:25:49 +01:00
Hans Petter Selasky cf3800dc20 ibcore: Fix multiple includes of same header file.
Sponsored by:	NVIDIA Networking
Approved by:	re (gjb)

(cherry picked from commit fc99316ef9)
(cherry picked from commit 2c268e7127)
2022-03-17 13:25:45 +01:00
Hans Petter Selasky d38eb01542 usb(4): Factor out the usb_check_request() function.
No functional change.

Sponsored by:	NVIDIA Networking
Approved by:	re (gjb)

(cherry picked from commit 8ed5bb59e9)
(cherry picked from commit 9157566d7a)
2022-03-17 13:23:32 +01:00
Glen Barber 88358b6dcb 13.1: update to BETA2
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-03-16 20:06:38 -04:00
Michael Gmelin 1ddb6c5518 if_epair: fix race condition on multi-core systems
As an unwanted side effect of the performance improvements in
24f0bfbad5, epair interfaces stop forwarding traffic on higher
load levels when running on multi-core systems.

This happens due to a race condition in the logic that decides when to
place work in the task queue(s) responsible for processing the content
of ring buffers.

In order to fix this, a field named state is added to the epair_queue
structure. This field is used by the affected functions to signal each
other that something happened in the underlying ring buffers that might
require work to be scheduled in task queue(s), replacing the existing
logic, which relied on checking if ring buffers are empty or not.

epair_menq() does:
  - set BIT_MBUF_QUEUED
  - queue mbuf
  - if testandset BIT_QUEUE_TASK:
      enqueue task

epair_tx_start_deferred() does:
  - swap ring buffers
  - process mbufs
  - clear BIT_QUEUE_TASK
  - if testandclear BIT_MBUF_QUEUED
      enqueue task

PR:		262571
Approved by:    re (gjb, early MFC)
Reported by:	Johan Hendriks <[email protected]>
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D34569

(cherry picked from commit 66acf7685b)
(cherry picked from commit bb9ad300f0)
2022-03-17 00:40:40 +01:00
Kirk McKusick 47b50c2318 Ensure that fsck(8) / fsck_ffs(8) produces the correct exit code for missing devices.
PR:          262580
Approved by: re (gjb, early MFC)

(cherry picked from commit 2983ec0a87)
(cherry picked from commit 934ba51bc9)
2022-03-16 16:14:57 -07:00
Gordon Tetlow 942b5e156d Fix a bug in BN_mod_sqrt() that can cause it to loop forever.
Approved by:	re (implicit)
Obtained from:	OpenSSL Project
Security:	CVE-2022-0778
Security:	FreeBSD-SA-22:03.openssl

(cherry picked from commit fdc418f15e)
(cherry picked from commit 5f3d952f6e)
2022-03-15 10:42:48 -07:00
Colin Percival de4045353b Add support for getting early entropy from UEFI
UEFI provides a protocol for accessing randomness. This is a good way
to gather early entropy, especially when there's no driver for the RNG
on the platform (as is the case on the Marvell Armada8k (MACCHIATObin)
for now).

If the entropy_efi_seed option is enabled in loader.conf (default: YES)
obtain 2048 bytes of entropy from UEFI and pass is to the kernel as a
"module" of name "efi_rng_seed" and type "boot_entropy_platform"; if
present, ingest it into the kernel RNG.

Submitted by:	Greg V
Reviewed by:	markm, kevans
Approved by:	csprng (markm), re (delphij)
Differential Revision:	https://reviews.freebsd.org/D20780
2022-03-14 14:26:33 -07:00
Konstantin Belousov 626c1423ee libc __sfvwrite(): roll back FILE buffer pointer on fflush error
__sfvwrite() advances the pointer before calling fflush.  If fflush()
fails, it is not enough to roll back inside it, because we cannot know
how much was advanced by the caller.

Reported by:	Peter <[email protected]>
Approved by:	re (gjb)
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Fixes:	86a16ada1e

(cherry picked from commit bafaa70b6f)
(cherry picked from commit 647f02d68a)
2022-03-14 11:47:24 -04:00
Konstantin Belousov 61f45ca2da buf_alloc(): Stop using LK_NOWAIT, use LK_NOWITNESS
Despite the buffer taken from cache or free list, it still can be
locked, due to 'lockless lookup' in getblkx() potentially operating on
the freed buffers.  The lock is transient, but prevents the use of
LK_NOWAIT there for the goal of neutralizing WITNESS.

Just use LK_NOWITNESS.

Reported and tested by:	pho
Approved by:	re (gjb)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 1fb00c8f10)
(cherry picked from commit dd54e44a27)
2022-03-14 11:47:12 -04:00
Martin Matuska 408fc21842 zfs: merge openzfs/zfs@ef83e07db (zfs-2.1-release) into releng/13.1
OpenZFS release 2.1.3

Notable upstream pull request merges:
  #12569 FreeBSD: Really zero the zero page
  #12828 FreeBSD: Add vop_standard_writecount_nomsyn
  #12828 zfs: Fix a deadlock between page busy and the teardown lock
  #12828 FreeBSD: Catch up with more VFS changes
  #12851 FreeBSD: Provide correct file generation number
  #12857 Verify dRAID empty sectors
  #12874 FreeBSD: Update argument types for VOP_READDIR
  #12896 Reduce number of arc_prune threads
  #12934 FreeBSD: Fix zvol_*_open() locking
  #12961 FreeBSD: Fix leaked strings in libspl mnttab
  #12964 Fix handling of errors from dmu_write_uio_dbuf() on FreeBSD
  #12981 Introduce a flag to skip comparing the local mac when
         raw sending
  #12985 Avoid memory allocations in the ARC eviction thread
  #13014 Report dnodes with faulty bonuslen
  #13016 FreeBSD: Fix zvol_cdev_open locking
  #13027 Fix clearing set-uid and set-gid bits on a file when
         replying a write
  #13031 Add enumerated vdev names to 'zpool iostat -v' and
         'zpool list -v'
  #13074 Enable encrypted raw sending to pools with greater ashift
  #13076 Receive checks should allow unencrypted child datasets
  #13098 Avoid dirtying the final TXGs when exporting a pool
  #13172 Fix ENOSPC when unlinking multiple files from full pool

Obtained from:	OpenZFS
OpenZFS commit:	ef83e07db5
OpenZFS tag:	zfs-2.1.3
Relnotes:	yes

(cherry picked from commit bd2e56ef47)

Approved by:	re (delphij)
2022-03-14 00:51:56 +01:00
Glen Barber ad329796bd 13.1: create releng/13.1 branch
Update from PRERELEASE to BETA1
Switch pkg(8) configuration to use the quarterly repository
Bump __FreeBSD_version

Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-03-09 19:10:32 -05:00
1203 changed files with 27956 additions and 9573 deletions

No files matched your search

+4
View File
@@ -1383,6 +1383,10 @@ distributeworld installworld stageworld: _installcheck_world .PHONY
if [ -z "${CROSSBUILD_HOST}" ] ; then \
libs=$$(ldd -f "%o %p\n" -f "%o %p\n" $$progs 2>/dev/null | sort -u | \
while read line; do \
case $$line in \
"["*"]") \
continue;; \
esac; \
set -- $$line; \
if [ "$$2 $$3" != "not found" ]; then \
echo $$2; \
+1 -305
View File
@@ -1,4 +1,4 @@
Release notes for FreeBSD 13.0.
Release notes for FreeBSD 13.1.
This file describes new user-visible features, changes and updates relevant to
users of binary FreeBSD releases. Each entry should describe the change in no
@@ -76,308 +76,4 @@ various:
They use KTLS to encrypt/decrypt all NFS RPC message traffic, plus
optional verification of machine identity via X.509 certificates.
f76393a6305b6:
Add AES-GCM support to armv8crypto(4) providing accelerated
support for KTLS, IPsec, and other crypto API consumers.
074a91f746bd:
The aesni(4) and armv8crypto(4) devices are now included in
GENERIC on amd64, i386, and arm64.
2e1c94aa1fd5:
Add support for enforcing W^X mapping policy for user
processes. The policy is not enforced by default but can be
enabled by setting the kern.elf32.allow_wx and
kern.elf64.allow_wx sysctls to 0. Individual binaries can be
exempted from the policy by elfctl(1) via the wxneeded
feature.
4979620ece98:
Add AES-XTS support to armv8crypto(4) providing accelerated
software support for the default GELI cipher on arm64 systems.
022ca2fc7fe0:
Add aio_writev(2) and aio_readv(2), vectored analogues of aio_write(2)
and aio_read(2).
92bbfe1f0d1f:
The fusefs(5) protocol has been updated to 7.28. Support for
FUSE_COPY_FILE_RANGE and FUSE_LSEEK is added.
r368667:
GDB 6.1.1 was removed. Users of crashinfo(8) should install the
gdb package or devel/gdb port.
r368559:
The hme(4) driver was removed.
r367660:
Fixes the case where gssd will not startup because /usr is a separate
local file system that is not yet mounted. It does not fix the case
where /usr is a separately mounted remote file system (such as NFS).
This latter case can be fixed by adding mountcritremote to the
REQUIRED line. Unfortunately doing so implies that all Kerberized
NFS mounts in /etc/fstab will need the "late" mount option.
This was not done, since the requirement for "late" would introduce
a POLA violation.
r367423:
This commit added a new startup scripts variable called
nfsv4_server_only which uses the -R option on mountd added by r367026.
When nfsv4_server_only is set to "YES" in /etc/rc.conf, the NFS server
only handles NFSv4 and does not register with rpcbind. As such, rpcbind
does not need to be running. Useful for sites which consider rpcbind a
security issue.
r366267:
Kernel option ACPI_DMAR was renamed to IOMMU. amd64's IOMMU subsystem
was split out from amd64 DMAR support and is now generic, i.e., it can
be used by all architectures.
r364896:
A series of commits ending with r364896 added NFS over TLS
to the kernel. This is believed to be compatible with
the Internet Draft titled "Towards Remote Procedure Call Encryption
By Default" (expected to soon become an RFC).
The mount_nfs(8) and exports(5) man pages describe the mount and
export option(s) related to NFS over TLS.
For NFS over TLS to work, the rpctlscd(8) { client } or rpctlssd(8)
{ server } must be running on a kernel built with "options KERN_TLS"
on an architecture where PMAP_HAS_DMAP != 0.
r364725:
Changes to one obscure devd event generated on resume need to
be documented. The old form will still be generated in 13, but not
in 14.
r363679:
Applications using regex(3), e.g. sed/grep, will no longer accept
redundant escapes for most ordinary characters.
r363253:
SCTP support has been removed from GENERIC kernel configurations.
The SCTP stack is now built as sctp.ko and can be dynamically loaded.
r363233:
Merge sendmail 8.16.1: See contrib/sendmail/RELEASE_NOTES for details.
r363180:
The safexcel(4) crypto offload driver has been added.
r363084:
nc(1) now implements SCTP mode, enabled by specifying the --sctp option.
r362681:
A new implementation of bc and dc has been imported. It offers
better standards compliance, performance, localization and comes
with extensive test cases that are optionally installed.
Use WITHOUT_GH_BC=yes to build and install the world with the
previous version instead of the new one, if required.
r362158, r362163:
struct export_args has changed so that the "user" specified for
the -maproot and -mapall exports(5) options may be in more than
16 groups.
r361884:
sed(1) has learned about hex escapes (e.g. \x27) and will now do the
right thing with them, removing the need for printf magic or obnoxious
escaping in many scenarios.
r361238, r361798, r361799:
ZFS will now unconditionally reject read(2) of a directory with EISDIR.
Additionally, read(2) of a directory is now rejected with EISDIR by
default and may be re-enabled for non-ZFS filesystems that allow it with
the sysctl(8) MIB 'security.bsd.allow_read_dir'.
Aliases for grep to default to '-d skip' may be desired if commonly
non-recursively grepping a list that includes directories and the
possibility of EISDIR errors in stderr is not tolerable. Example
aliases, commented out, have been installed in /root/.cshrc and
/root/.shrc.
r361066:
Add exec.prepare and exec.release hooks for jail(8) and jail.conf(5).
exec.prepare runs before mounts, so can be used to populate new jails.
exec.release runs after unmounts, so can be used to remove ephemeral
jails.
r360920,r360923,r360924,r360927,r360928,r360931,r360933,r360936:
Remove support for ARC4, Blowfish, Cast, DES, Triple DES, MD5,
MD5-KPDK, MD5-HMAC, SHA1-KPDK, and Skipjack algorithms from
the kernel open cryptographic framework (OCF).
r360562:
Remove support for ARC4, Blowfish, Cast, DES, Triple DES,
MD5-HMAC, and Skipjack algorithms from /dev/crypto.
r360557:
Remove support for DES, Triple DES, Blowfish, Cast, and
Camellia ciphers from IPsec(4). Remove support for MD5-HMAC,
Keyed MD5, Keyed SHA1, and RIPEMD160-HMAC from IPsec(4).
r359945:
Remove support for Triple DES, Blowfish, and MD5 HMAC from
geli(4).
r359786-r359787:
Remove support for DES, Triple DES, and RC4 from in-kernel GSS
authentication.
r357627:
remove elf2aout.
r357560-r357565:
init(8), service(8), and cron(8) will now adopt user/class environment
variables (excluding PATH, by default, which will be overwritten) by
default. Notably, environment variables for all cron jobs and rc
services can now be set via login.conf(5).
r357455:
sparc64 has been removed from FreeBSD.
r355677:
Adds support for NFSv4.2 (RFC-7862) and Extended Attributes
(RFC-8276) to the NFS client and server.
NFSv4.2 is comprised of several optional features that can be supported
in addition to NFSv4.1. This patch adds the following optional features:
- posix_fadvise(POSIX_FADV_WILLNEED/POSIX_FADV_DONTNEED)
- posix_fallocate()
- intra server file range copying via the copy_file_range(2) syscall
--> Avoiding data tranfer over the wire to/from the NFS client.
- lseek(SEEK_DATA/SEEK_HOLE)
- Extended attribute syscalls for "user" namespace attributes as defined
by RFC-8276.
For the client, NFSv4.2 is only used if the mount command line option
minorversion=2 is specified.
For the server, two new sysctls called vfs.nfsd.server_min_minorversion4
and vfs.nfsd.server_max_minorversion4 have been added that allow
sysadmins to limit the minor versions of NFSv4 supported by the nfsd
server.
Setting vfs.nfsd.server_max_minorversion4 to 0 or 1 will disable NFSv4.2
on the server.
r356263:
armv5 support has been removed from FreeBSD.
r354517:
iwm(4) now supports most Intel 9260, 9460 and 9560 Wi-Fi devices.
r354269:
sqlite3 is updated to sqlite3-3.30.1.
r352668:
cron(8) now supports the -n (suppress mail on succesful run) and -q
(suppress logging of command execution) options in the crontab format.
See the crontab(5) manpage for details.
r352304:
ntpd is no longer by default locked in memory. rlimit memlock 32
or rlimit memlock 0 can be used to restore this behaviour.
r351863:
rc.subr(8) now honors ${name}_env in all rc(8) scripts. Previously,
environment variables set by a user via ${name}_env were ignored
if the service defined a custom *_cmd variable to control the behavior
of the run_rc_command function, e.g., start_cmd, instead of relying on
the variables like command and command_args,
r351770,r352920,r352922,r352923:
dd(1) now supports conv=fsync, conv=fdatasync, oflag=fsync, oflag=sync,
and iflag=fullblock flags, compatible with illumos and GNU.
r351522:
Add kernel-side support for in-kernel Transport Layer Security
(KTLS). KTLS permits using sendfile(2) over sockets using
TLS.
r351397:
WPA is updated from 2.8 to 2.9.
r351361:
Add probes for lockmgr(9) to the lockstat DTrace provider, add
corresponding lockstat(1) events, and document the new probes in
dtrace_lockstat.4.
r351356:
Intel RST is a new 'feature' that remaps NVMe devices from
their normal location to part of the AHCI bar space. This
will eliminate the need to set the BIOS SATA setting from RST
to AHCI causing the nvme drive to be erased before FreeBSD
will see the nvme drive. FreeBSD will now be able to see the
nvme drive now in the default config.
r351201, r351372:
Add a vop_stdioctl() call, so that file systems that do not support
holes will have a trivial implementation of lseek(SEEK_DATA/SEEK_HOLE).
The algorithm appears to be compatible with the POSIX draft and
the implementation in Linux for the case of a file system that
does not support holes. Prior to this patch, lseek(2) would reply
-1 with errno set to ENOTTY for SEEK_DATA/SEEK_HOLE on files in
file systems that do not support holes.
r351372 maps ENOTTY to EINVAL for lseek(SEEK_DATA/SEEK_HOLE) for
any other cases, such as a ENOTTY return from vn_bmap_seekhole().
r350665:
The fuse driver has been renamed to fusefs(5) and been substantially
rewritten. The new driver includes many bug fixes and performance
enhancements, as well as the following user-visible features:
* Optional kernel-side permissions checks (-o default_permissions)
* mknod(2), socket(2), and pipe(2) support
* server side locking with fcntl(2)
* FUSE operations are now interruptible when mounted with -o intr
* server side handling of UTIME_NOW during utimensat(2)
* mount options may be updated with "mount -u"
* fusefs file system may now be exported over NFS
* RLIMIT_FSIZE support
* support for fuse file systems using protocols as old as 7.4
FUSE file system developers should also take note of the following new
features:
* The protocol level has been raised from 7.8 to 7.23
* kqueue support on /dev/fuse
* server-initiated cache invalidation via FUSE_NOTIFY_REPLY
r350471:
gnop(8) can now configure a delay to be applied to read and write
request delays. See the -d, -q and -x parameters.
r350315, r350316:
Adds a Linux compatible copy_file_range(2) syscall.
r350307:
libcap_random(3) has been removed. Applications can use native
APIs to get random data in capability mode.
r349529,r349530:
Add support for using unmapped mbufs with sendfile(2).
r349352:
nand(4) and related components have been removed.
r349349:
The UEFI loader now supports HTTP boot.
r349335:
bhyve(8) now implements a High Definition Audio (HDA) driver, allowing
guests to play to and record audio data from the host.
r349286:
swapon(8) can now erase a swap device immediately before enabling it,
similar to newfs(8)'s -E option. This behaviour can be specified by
adding -E to swapon(8)'s command-line parameters, or by adding the
"trimonce" option to a swap device's /etc/fstab entry.
r347908-r347923:
The following network drivers have been removed: bm(4), cs(4), de(4),
ed(4), ep(4), ex(4), fe(4), pcn(4), sf(4), sn(4), tl(4), tx(4), txp(4),
vx(4), wb(4), xe(4).
r347532:
Wired page accounting has been split into kernel wirings and user
wirings (e.g., by mlock(2)). Kernel wirings no long count towards
the global limit, which is renamed to vm.max_user_wired. bhyve -S
allocates user-wired memory and is now subject to that limit.
$FreeBSD$
+3
View File
@@ -12,6 +12,9 @@ Items affecting the ports and packages system can be found in
/usr/ports/UPDATING. Please read that file before updating system packages
and/or ports.
20220516:
13.1-RELEASE.
20220123:
For 64-bit architectures the base system is now built with Position
Independent Executable (PIE) support enabled by default. It may be
+234 -137
View File
@@ -87,48 +87,85 @@ ctf_create(int *errp)
}
static uchar_t *
ctf_copy_smembers(ctf_dtdef_t *dtd, uint_t soff, uchar_t *t)
ctf_copy_smembers(const ctf_file_t *fp, ctf_dtdef_t *dtd, uint_t soff,
uchar_t *t)
{
ctf_dmdef_t *dmd = ctf_list_next(&dtd->dtd_u.dtu_members);
ctf_member_t ctm;
size_t sz;
uint_t name;
for (; dmd != NULL; dmd = ctf_list_next(dmd)) {
if (dmd->dmd_name) {
ctm.ctm_name = soff;
name = soff;
soff += strlen(dmd->dmd_name) + 1;
} else
ctm.ctm_name = 0;
name = 0;
ctm.ctm_type = (ushort_t)dmd->dmd_type;
ctm.ctm_offset = (ushort_t)dmd->dmd_offset;
if (fp->ctf_version == CTF_VERSION_2) {
struct ctf_member_v2 ctm;
bcopy(&ctm, t, sizeof (ctm));
t += sizeof (ctm);
ctm.ctm_name = name;
ctm.ctm_type = (ushort_t)dmd->dmd_type;
ctm.ctm_offset = (ushort_t)dmd->dmd_offset;
sz = sizeof (ctm);
bcopy(&ctm, t, sz);
t += sz;
} else {
struct ctf_member_v3 ctm;
ctm.ctm_name = name;
ctm.ctm_type = dmd->dmd_type;
ctm.ctm_offset = dmd->dmd_offset;
sz = sizeof (ctm);
bcopy(&ctm, t, sz);
t += sz;
}
}
return (t);
}
static uchar_t *
ctf_copy_lmembers(ctf_dtdef_t *dtd, uint_t soff, uchar_t *t)
ctf_copy_lmembers(const ctf_file_t *fp, ctf_dtdef_t *dtd, uint_t soff,
uchar_t *t)
{
ctf_dmdef_t *dmd = ctf_list_next(&dtd->dtd_u.dtu_members);
ctf_lmember_t ctlm;
size_t sz;
uint_t name;
for (; dmd != NULL; dmd = ctf_list_next(dmd)) {
if (dmd->dmd_name) {
ctlm.ctlm_name = soff;
name = soff;
soff += strlen(dmd->dmd_name) + 1;
} else
ctlm.ctlm_name = 0;
name = 0;
ctlm.ctlm_type = (ushort_t)dmd->dmd_type;
ctlm.ctlm_pad = 0;
ctlm.ctlm_offsethi = CTF_OFFSET_TO_LMEMHI(dmd->dmd_offset);
ctlm.ctlm_offsetlo = CTF_OFFSET_TO_LMEMLO(dmd->dmd_offset);
if (fp->ctf_version == CTF_VERSION_2) {
struct ctf_lmember_v2 ctlm;
bcopy(&ctlm, t, sizeof (ctlm));
t += sizeof (ctlm);
ctlm.ctlm_name = name;
ctlm.ctlm_type = (ushort_t)dmd->dmd_type;
ctlm.ctlm_pad = 0;
ctlm.ctlm_offsethi = CTF_OFFSET_TO_LMEMHI(dmd->dmd_offset);
ctlm.ctlm_offsetlo = CTF_OFFSET_TO_LMEMLO(dmd->dmd_offset);
sz = sizeof (ctlm);
bcopy(&ctlm, t, sz);
t += sz;
} else {
struct ctf_lmember_v3 ctlm;
ctlm.ctlm_name = name;
ctlm.ctlm_type = dmd->dmd_type;
ctlm.ctlm_offsethi = CTF_OFFSET_TO_LMEMHI(dmd->dmd_offset);
ctlm.ctlm_offsetlo = CTF_OFFSET_TO_LMEMLO(dmd->dmd_offset);
sz = sizeof (ctlm);
bcopy(&ctlm, t, sz);
t += sz;
}
}
return (t);
@@ -259,7 +296,7 @@ ctf_update(ctf_file_t *fp)
*/
bzero(&hdr, sizeof (hdr));
hdr.cth_magic = CTF_MAGIC;
hdr.cth_version = CTF_VERSION;
hdr.cth_version = fp->ctf_version;
if (fp->ctf_flags & LCTF_CHILD)
hdr.cth_parname = 1; /* i.e. _CTF_STRTAB_TEMPLATE[1] */
@@ -271,13 +308,20 @@ ctf_update(ctf_file_t *fp)
for (size = 0, dtd = ctf_list_next(&fp->ctf_dtdefs);
dtd != NULL; dtd = ctf_list_next(dtd)) {
uint_t kind = CTF_INFO_KIND(dtd->dtd_data.ctt_info);
uint_t vlen = CTF_INFO_VLEN(dtd->dtd_data.ctt_info);
uint_t kind = LCTF_INFO_KIND(fp, dtd->dtd_data.ctt_info);
uint_t vlen = LCTF_INFO_VLEN(fp, dtd->dtd_data.ctt_info);
if (dtd->dtd_data.ctt_size != CTF_LSIZE_SENT)
size += sizeof (ctf_stype_t);
else
size += sizeof (ctf_type_t);
if (fp->ctf_version == CTF_VERSION_2) {
if (dtd->dtd_data.ctt_size != CTF_V2_LSIZE_SENT)
size += sizeof (struct ctf_stype_v2);
else
size += sizeof (struct ctf_type_v2);
} else {
if (dtd->dtd_data.ctt_size != LCTF_LSIZE_SENT(fp))
size += sizeof (struct ctf_stype_v3);
else
size += sizeof (struct ctf_type_v3);
}
switch (kind) {
case CTF_K_INTEGER:
@@ -285,17 +329,32 @@ ctf_update(ctf_file_t *fp)
size += sizeof (uint_t);
break;
case CTF_K_ARRAY:
size += sizeof (ctf_array_t);
size += fp->ctf_version == CTF_VERSION_2 ?
sizeof (struct ctf_array_v2) :
sizeof (struct ctf_array_v3);
break;
case CTF_K_FUNCTION:
size += sizeof (ushort_t) * (vlen + (vlen & 1));
size += roundup2(fp->ctf_idwidth * vlen, 4);
break;
case CTF_K_STRUCT:
case CTF_K_UNION:
if (dtd->dtd_data.ctt_size < CTF_LSTRUCT_THRESH)
size += sizeof (ctf_member_t) * vlen;
else
size += sizeof (ctf_lmember_t) * vlen;
if (fp->ctf_version == CTF_VERSION_2) {
if (dtd->dtd_data.ctt_size <
LCTF_LSTRUCT_THRESH(fp))
size += sizeof (struct ctf_member_v2) *
vlen;
else
size += sizeof (struct ctf_lmember_v2) *
vlen;
} else {
if (dtd->dtd_data.ctt_size <
LCTF_LSTRUCT_THRESH(fp))
size += sizeof (struct ctf_member_v3) *
vlen;
else
size += sizeof (struct ctf_lmember_v3) *
vlen;
}
break;
case CTF_K_ENUM:
size += sizeof (ctf_enum_t) * vlen;
@@ -328,11 +387,11 @@ ctf_update(ctf_file_t *fp)
*/
for (dtd = ctf_list_next(&fp->ctf_dtdefs);
dtd != NULL; dtd = ctf_list_next(dtd)) {
void *tp;
uint_t kind = LCTF_INFO_KIND(fp, dtd->dtd_data.ctt_info);
uint_t vlen = LCTF_INFO_VLEN(fp, dtd->dtd_data.ctt_info);
struct ctf_type_v2 ctt;
uint_t kind = CTF_INFO_KIND(dtd->dtd_data.ctt_info);
uint_t vlen = CTF_INFO_VLEN(dtd->dtd_data.ctt_info);
ctf_array_t cta;
uint_t encoding;
size_t len;
@@ -344,12 +403,27 @@ ctf_update(ctf_file_t *fp)
} else
dtd->dtd_data.ctt_name = 0;
if (dtd->dtd_data.ctt_size != CTF_LSIZE_SENT)
len = sizeof (ctf_stype_t);
else
len = sizeof (ctf_type_t);
if (fp->ctf_version == CTF_VERSION_2) {
ctt.ctt_name = dtd->dtd_data.ctt_name;
ctt.ctt_info = (ushort_t)dtd->dtd_data.ctt_info;
ctt.ctt_size = (ushort_t)dtd->dtd_data.ctt_size;
if (dtd->dtd_data.ctt_size != CTF_V2_LSIZE_SENT)
len = sizeof (struct ctf_stype_v2);
else {
len = sizeof (struct ctf_type_v2);
ctt.ctt_lsizehi = dtd->dtd_data.ctt_lsizehi;
ctt.ctt_lsizelo = dtd->dtd_data.ctt_lsizelo;
}
tp = &ctt;
} else {
if (dtd->dtd_data.ctt_size != LCTF_LSIZE_SENT(fp))
len = sizeof (struct ctf_stype_v3);
else
len = sizeof (struct ctf_type_v3);
tp = &dtd->dtd_data;
}
bcopy(&dtd->dtd_data, t, len);
bcopy(tp, t, len);
t += len;
switch (kind) {
@@ -371,24 +445,52 @@ ctf_update(ctf_file_t *fp)
break;
case CTF_K_ARRAY:
cta.cta_contents = (ushort_t)
dtd->dtd_u.dtu_arr.ctr_contents;
cta.cta_index = (ushort_t)
dtd->dtd_u.dtu_arr.ctr_index;
cta.cta_nelems = dtd->dtd_u.dtu_arr.ctr_nelems;
bcopy(&cta, t, sizeof (cta));
t += sizeof (cta);
if (fp->ctf_version == CTF_VERSION_2) {
struct ctf_array_v2 cta;
cta.cta_contents =
(uint16_t)dtd->dtd_u.dtu_arr.ctr_contents;
cta.cta_index =
(uint16_t)dtd->dtd_u.dtu_arr.ctr_index;
cta.cta_nelems = dtd->dtd_u.dtu_arr.ctr_nelems;
bcopy(&cta, t, sizeof (cta));
t += sizeof (cta);
} else {
struct ctf_array_v3 cta;
cta.cta_contents =
dtd->dtd_u.dtu_arr.ctr_contents;
cta.cta_index = dtd->dtd_u.dtu_arr.ctr_index;
cta.cta_nelems = dtd->dtd_u.dtu_arr.ctr_nelems;
bcopy(&cta, t, sizeof (cta));
t += sizeof (cta);
}
break;
case CTF_K_FUNCTION: {
ushort_t *argv = (ushort_t *)(uintptr_t)t;
char *argv = (char *)(uintptr_t)t;
uint_t argc;
for (argc = 0; argc < vlen; argc++)
*argv++ = (ushort_t)dtd->dtd_u.dtu_argv[argc];
if (fp->ctf_version == CTF_VERSION_2) {
ushort_t arg;
if (vlen & 1)
*argv++ = 0; /* pad to 4-byte boundary */
for (argc = 0; argc < vlen;
argc++, argv += sizeof(arg)) {
arg =
(ushort_t)dtd->dtd_u.dtu_argv[argc];
memcpy(argv, &arg, sizeof(arg));
}
} else {
uint_t arg;
for (argc = 0; argc < vlen;
argc++, argv += sizeof(arg)) {
arg = (uint_t)dtd->dtd_u.dtu_argv[argc];
memcpy(argv, &arg, sizeof(arg));
}
}
t = (uchar_t *)argv;
break;
@@ -396,10 +498,12 @@ ctf_update(ctf_file_t *fp)
case CTF_K_STRUCT:
case CTF_K_UNION:
if (dtd->dtd_data.ctt_size < CTF_LSTRUCT_THRESH)
t = ctf_copy_smembers(dtd, (uint_t)(s - s0), t);
if (dtd->dtd_data.ctt_size < LCTF_LSTRUCT_THRESH(fp))
t = ctf_copy_smembers(fp, dtd, (uint_t)(s - s0),
t);
else
t = ctf_copy_lmembers(dtd, (uint_t)(s - s0), t);
t = ctf_copy_lmembers(fp, dtd, (uint_t)(s - s0),
t);
s = ctf_copy_membnames(dtd, s);
break;
@@ -495,7 +599,7 @@ ctf_dtd_delete(ctf_file_t *fp, ctf_dtdef_t *dtd)
if (p != NULL)
*q = p->dtd_hash;
kind = CTF_INFO_KIND(dtd->dtd_data.ctt_info);
kind = LCTF_INFO_KIND(fp, dtd->dtd_data.ctt_info);
switch (kind) {
case CTF_K_STRUCT:
case CTF_K_UNION:
@@ -515,11 +619,11 @@ ctf_dtd_delete(ctf_file_t *fp, ctf_dtdef_t *dtd)
break;
case CTF_K_FUNCTION:
ctf_ref_dec(fp, dtd->dtd_data.ctt_type);
for (i = 0; i < CTF_INFO_VLEN(dtd->dtd_data.ctt_info); i++)
for (i = 0; i < LCTF_INFO_VLEN(fp, dtd->dtd_data.ctt_info); i++)
if (dtd->dtd_u.dtu_argv[i] != 0)
ctf_ref_dec(fp, dtd->dtd_u.dtu_argv[i]);
ctf_free(dtd->dtd_u.dtu_argv, sizeof (ctf_id_t) *
CTF_INFO_VLEN(dtd->dtd_data.ctt_info));
LCTF_INFO_VLEN(fp, dtd->dtd_data.ctt_info));
break;
case CTF_K_ARRAY:
ctf_ref_dec(fp, dtd->dtd_u.dtu_arr.ctr_contents);
@@ -584,7 +688,7 @@ ctf_discard(ctf_file_t *fp)
for (dtd = ctf_list_prev(&fp->ctf_dtdefs); dtd != NULL; dtd = ntd) {
ntd = ctf_list_prev(dtd);
if (CTF_TYPE_TO_INDEX(dtd->dtd_type) <= fp->ctf_dtoldid)
if (LCTF_TYPE_TO_INDEX(fp, dtd->dtd_type) <= fp->ctf_dtoldid)
continue; /* skip types that have been committed */
ctf_dtd_delete(fp, dtd);
@@ -609,7 +713,7 @@ ctf_add_generic(ctf_file_t *fp, uint_t flag, const char *name, ctf_dtdef_t **rp)
if (!(fp->ctf_flags & LCTF_RDWR))
return (ctf_set_errno(fp, ECTF_RDONLY));
if (CTF_INDEX_TO_TYPE(fp->ctf_dtnextid, 1) > CTF_MAX_TYPE)
if (LCTF_INDEX_TO_TYPE(fp, fp->ctf_dtnextid, 1) > LCTF_MAX_TYPE(fp))
return (ctf_set_errno(fp, ECTF_FULL));
if ((dtd = ctf_alloc(sizeof (ctf_dtdef_t))) == NULL)
@@ -621,7 +725,7 @@ ctf_add_generic(ctf_file_t *fp, uint_t flag, const char *name, ctf_dtdef_t **rp)
}
type = fp->ctf_dtnextid++;
type = CTF_INDEX_TO_TYPE(type, (fp->ctf_flags & LCTF_CHILD));
type = LCTF_INDEX_TO_TYPE(fp, type, (fp->ctf_flags & LCTF_CHILD));
bzero(dtd, sizeof (ctf_dtdef_t));
dtd->dtd_name = s;
@@ -669,7 +773,7 @@ ctf_add_encoded(ctf_file_t *fp, uint_t flag,
if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR)
return (CTF_ERR); /* errno is set for us */
dtd->dtd_data.ctt_info = CTF_TYPE_INFO(kind, flag, 0);
dtd->dtd_data.ctt_info = LCTF_TYPE_INFO(fp, kind, flag, 0);
dtd->dtd_data.ctt_size = clp2(P2ROUNDUP(ep->cte_bits, NBBY) / NBBY);
dtd->dtd_u.dtu_enc = *ep;
@@ -682,7 +786,7 @@ ctf_add_reftype(ctf_file_t *fp, uint_t flag, ctf_id_t ref, uint_t kind)
ctf_dtdef_t *dtd;
ctf_id_t type;
if (ref == CTF_ERR || ref < 0 || ref > CTF_MAX_TYPE)
if (ref == CTF_ERR || ref > LCTF_MAX_TYPE(fp))
return (ctf_set_errno(fp, EINVAL));
if ((type = ctf_add_generic(fp, flag, NULL, &dtd)) == CTF_ERR)
@@ -690,8 +794,8 @@ ctf_add_reftype(ctf_file_t *fp, uint_t flag, ctf_id_t ref, uint_t kind)
ctf_ref_inc(fp, ref);
dtd->dtd_data.ctt_info = CTF_TYPE_INFO(kind, flag, 0);
dtd->dtd_data.ctt_type = (ushort_t)ref;
dtd->dtd_data.ctt_info = LCTF_TYPE_INFO(fp, kind, flag, 0);
dtd->dtd_data.ctt_type = (uint_t)ref;
return (type);
}
@@ -739,7 +843,7 @@ ctf_add_array(ctf_file_t *fp, uint_t flag, const ctf_arinfo_t *arp)
if ((type = ctf_add_generic(fp, flag, NULL, &dtd)) == CTF_ERR)
return (CTF_ERR); /* errno is set for us */
dtd->dtd_data.ctt_info = CTF_TYPE_INFO(CTF_K_ARRAY, flag, 0);
dtd->dtd_data.ctt_info = LCTF_TYPE_INFO(fp, CTF_K_ARRAY, flag, 0);
dtd->dtd_data.ctt_size = 0;
dtd->dtd_u.dtu_arr = *arp;
ctf_ref_inc(fp, arp->ctr_contents);
@@ -757,7 +861,8 @@ ctf_set_array(ctf_file_t *fp, ctf_id_t type, const ctf_arinfo_t *arp)
if (!(fp->ctf_flags & LCTF_RDWR))
return (ctf_set_errno(fp, ECTF_RDONLY));
if (dtd == NULL || CTF_INFO_KIND(dtd->dtd_data.ctt_info) != CTF_K_ARRAY)
if (dtd == NULL ||
LCTF_INFO_KIND(fp, dtd->dtd_data.ctt_info) != CTF_K_ARRAY)
return (ctf_set_errno(fp, ECTF_BADID));
fpd = fp;
@@ -799,7 +904,7 @@ ctf_add_function(ctf_file_t *fp, uint_t flag,
if (ctc->ctc_flags & CTF_FUNC_VARARG)
vlen++; /* add trailing zero to indicate varargs (see below) */
if (vlen > CTF_MAX_VLEN)
if (vlen > LCTF_MAX_VLEN(fp))
return (ctf_set_errno(fp, EOVERFLOW));
fpd = fp;
@@ -822,8 +927,8 @@ ctf_add_function(ctf_file_t *fp, uint_t flag,
return (CTF_ERR); /* errno is set for us */
}
dtd->dtd_data.ctt_info = CTF_TYPE_INFO(CTF_K_FUNCTION, flag, vlen);
dtd->dtd_data.ctt_type = (ushort_t)ctc->ctc_return;
dtd->dtd_data.ctt_info = LCTF_TYPE_INFO(fp, CTF_K_FUNCTION, flag, vlen);
dtd->dtd_data.ctt_type = ctc->ctc_return;
ctf_ref_inc(fp, ctc->ctc_return);
for (i = 0; i < ctc->ctc_argc; i++)
@@ -853,7 +958,7 @@ ctf_add_struct(ctf_file_t *fp, uint_t flag, const char *name)
else if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR)
return (CTF_ERR); /* errno is set for us */
dtd->dtd_data.ctt_info = CTF_TYPE_INFO(CTF_K_STRUCT, flag, 0);
dtd->dtd_data.ctt_info = LCTF_TYPE_INFO(fp, CTF_K_STRUCT, flag, 0);
dtd->dtd_data.ctt_size = 0;
return (type);
@@ -875,7 +980,7 @@ ctf_add_union(ctf_file_t *fp, uint_t flag, const char *name)
else if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR)
return (CTF_ERR); /* errno is set for us */
dtd->dtd_data.ctt_info = CTF_TYPE_INFO(CTF_K_UNION, flag, 0);
dtd->dtd_data.ctt_info = LCTF_TYPE_INFO(fp, CTF_K_UNION, flag, 0);
dtd->dtd_data.ctt_size = 0;
return (type);
@@ -897,7 +1002,7 @@ ctf_add_enum(ctf_file_t *fp, uint_t flag, const char *name)
else if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR)
return (CTF_ERR); /* errno is set for us */
dtd->dtd_data.ctt_info = CTF_TYPE_INFO(CTF_K_ENUM, flag, 0);
dtd->dtd_data.ctt_info = LCTF_TYPE_INFO(fp, CTF_K_ENUM, flag, 0);
dtd->dtd_data.ctt_size = fp->ctf_dmodel->ctd_int;
return (type);
@@ -936,7 +1041,7 @@ ctf_add_forward(ctf_file_t *fp, uint_t flag, const char *name, uint_t kind)
if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR)
return (CTF_ERR); /* errno is set for us */
dtd->dtd_data.ctt_info = CTF_TYPE_INFO(CTF_K_FORWARD, flag, 0);
dtd->dtd_data.ctt_info = LCTF_TYPE_INFO(fp, CTF_K_FORWARD, flag, 0);
dtd->dtd_data.ctt_type = kind;
return (type);
@@ -957,8 +1062,8 @@ ctf_add_typedef(ctf_file_t *fp, uint_t flag, const char *name, ctf_id_t ref)
if ((type = ctf_add_generic(fp, flag, name, &dtd)) == CTF_ERR)
return (CTF_ERR); /* errno is set for us */
dtd->dtd_data.ctt_info = CTF_TYPE_INFO(CTF_K_TYPEDEF, flag, 0);
dtd->dtd_data.ctt_type = (ushort_t)ref;
dtd->dtd_data.ctt_info = LCTF_TYPE_INFO(fp, CTF_K_TYPEDEF, flag, 0);
dtd->dtd_data.ctt_type = ref;
ctf_ref_inc(fp, ref);
return (type);
@@ -1000,14 +1105,14 @@ ctf_add_enumerator(ctf_file_t *fp, ctf_id_t enid, const char *name, int value)
if (dtd == NULL)
return (ctf_set_errno(fp, ECTF_BADID));
kind = CTF_INFO_KIND(dtd->dtd_data.ctt_info);
root = CTF_INFO_ISROOT(dtd->dtd_data.ctt_info);
vlen = CTF_INFO_VLEN(dtd->dtd_data.ctt_info);
kind = LCTF_INFO_KIND(fp, dtd->dtd_data.ctt_info);
root = LCTF_INFO_ROOT(fp, dtd->dtd_data.ctt_info);
vlen = LCTF_INFO_VLEN(fp, dtd->dtd_data.ctt_info);
if (kind != CTF_K_ENUM)
return (ctf_set_errno(fp, ECTF_NOTENUM));
if (vlen == CTF_MAX_VLEN)
if (vlen > LCTF_MAX_VLEN(fp))
return (ctf_set_errno(fp, ECTF_DTFULL));
for (dmd = ctf_list_next(&dtd->dtd_u.dtu_members);
@@ -1029,7 +1134,7 @@ ctf_add_enumerator(ctf_file_t *fp, ctf_id_t enid, const char *name, int value)
dmd->dmd_offset = 0;
dmd->dmd_value = value;
dtd->dtd_data.ctt_info = CTF_TYPE_INFO(kind, root, vlen + 1);
dtd->dtd_data.ctt_info = LCTF_TYPE_INFO(fp, kind, root, vlen + 1);
ctf_list_append(&dtd->dtd_u.dtu_members, dmd);
fp->ctf_dtstrlen += strlen(s) + 1;
@@ -1054,14 +1159,14 @@ ctf_add_member(ctf_file_t *fp, ctf_id_t souid, const char *name, ctf_id_t type)
if (dtd == NULL)
return (ctf_set_errno(fp, ECTF_BADID));
kind = CTF_INFO_KIND(dtd->dtd_data.ctt_info);
root = CTF_INFO_ISROOT(dtd->dtd_data.ctt_info);
vlen = CTF_INFO_VLEN(dtd->dtd_data.ctt_info);
kind = LCTF_INFO_KIND(fp, dtd->dtd_data.ctt_info);
root = LCTF_INFO_ROOT(fp, dtd->dtd_data.ctt_info);
vlen = LCTF_INFO_VLEN(fp, dtd->dtd_data.ctt_info);
if (kind != CTF_K_STRUCT && kind != CTF_K_UNION)
return (ctf_set_errno(fp, ECTF_NOTSOU));
if (vlen == CTF_MAX_VLEN)
if (vlen > LCTF_MAX_VLEN(fp))
return (ctf_set_errno(fp, ECTF_DTFULL));
if (name != NULL) {
@@ -1121,14 +1226,14 @@ ctf_add_member(ctf_file_t *fp, ctf_id_t souid, const char *name, ctf_id_t type)
ssize = MAX(ssize, msize);
}
if (ssize > CTF_MAX_SIZE) {
dtd->dtd_data.ctt_size = CTF_LSIZE_SENT;
if (ssize > LCTF_MAX_SIZE(fp)) {
dtd->dtd_data.ctt_size = LCTF_LSIZE_SENT(fp);
dtd->dtd_data.ctt_lsizehi = CTF_SIZE_TO_LSIZE_HI(ssize);
dtd->dtd_data.ctt_lsizelo = CTF_SIZE_TO_LSIZE_LO(ssize);
} else
dtd->dtd_data.ctt_size = (ushort_t)ssize;
dtd->dtd_data.ctt_size = ssize;
dtd->dtd_data.ctt_info = CTF_TYPE_INFO(kind, root, vlen + 1);
dtd->dtd_data.ctt_info = LCTF_TYPE_INFO(fp, kind, root, vlen + 1);
ctf_list_append(&dtd->dtd_u.dtu_members, dmd);
if (s != NULL)
@@ -1233,10 +1338,10 @@ static long
soucmp(ctf_file_t *src_fp, ctf_id_t src_type, ctf_file_t *dst_fp,
ctf_id_t dst_type)
{
const ctf_type_t *src_tp, *dst_tp;
const void *src_tp, *dst_tp;
const char *src_name, *dst_name;
ssize_t src_sz, dst_sz, src_inc, dst_inc;
uint_t kind, n;
uint_t dst_kind, dst_vlen, src_kind, src_vlen, n;
if ((src_type = ctf_type_resolve(src_fp, src_type)) == CTF_ERR)
return (CTF_ERR);
@@ -1248,47 +1353,37 @@ soucmp(ctf_file_t *src_fp, ctf_id_t src_type, ctf_file_t *dst_fp,
if ((dst_tp = ctf_lookup_by_id(&dst_fp, dst_type)) == NULL)
return (CTF_ERR);
if ((kind = LCTF_INFO_KIND(src_fp, src_tp->ctt_info)) !=
LCTF_INFO_KIND(dst_fp, dst_tp->ctt_info))
ctf_get_ctt_info(src_fp, src_tp, &src_kind, &src_vlen, NULL);
ctf_get_ctt_info(dst_fp, dst_tp, &dst_kind, &dst_vlen, NULL);
if (src_kind != dst_kind)
return (ctf_set_errno(dst_fp, ECTF_CONFLICT));
if (kind != CTF_K_STRUCT && kind != CTF_K_UNION)
if (src_kind != CTF_K_STRUCT && src_kind != CTF_K_UNION)
return (ctf_set_errno(dst_fp, ECTF_CONFLICT));
if ((n = LCTF_INFO_VLEN(src_fp, src_tp->ctt_info)) !=
LCTF_INFO_VLEN(dst_fp, dst_tp->ctt_info))
if (src_vlen != dst_vlen)
return (ctf_set_errno(dst_fp, ECTF_CONFLICT));
(void) ctf_get_ctt_size(src_fp, src_tp, &src_sz, &src_inc);
(void) ctf_get_ctt_size(dst_fp, dst_tp, &dst_sz, &dst_inc);
if (src_sz != dst_sz || src_inc != dst_inc)
if (src_sz != dst_sz)
return (ctf_set_errno(dst_fp, ECTF_CONFLICT));
if (src_sz < CTF_LSTRUCT_THRESH) {
const ctf_member_t *src_mp, *dst_mp;
const char *src_mp, *dst_mp;
ulong_t src_offset, dst_offset;
src_mp = (const ctf_member_t *)((uintptr_t)src_tp + src_inc);
dst_mp = (const ctf_member_t *)((uintptr_t)dst_tp + dst_inc);
for (; n != 0; n--, src_mp++, dst_mp++) {
if (src_mp->ctm_offset != dst_mp->ctm_offset)
return (ctf_set_errno(dst_fp, ECTF_CONFLICT));
src_name = ctf_strptr(src_fp, src_mp->ctm_name);
dst_name = ctf_strptr(dst_fp, dst_mp->ctm_name);
if (strcmp(src_name, dst_name) != 0)
return (ctf_set_errno(dst_fp, ECTF_CONFLICT));
}
} else {
const ctf_lmember_t *src_mp, *dst_mp;
src_mp = (const char *)src_tp + src_inc;
dst_mp = (const char *)dst_tp + dst_inc;
for (n = src_vlen; n != 0;
n--, src_mp += src_inc, dst_mp += dst_inc) {
ctf_get_ctm_info(src_fp, src_mp, src_sz, &src_inc, NULL,
&src_offset, &src_name);
ctf_get_ctm_info(dst_fp, dst_mp, dst_sz, &dst_inc, NULL,
&dst_offset, &dst_name);
src_mp = (const ctf_lmember_t *)((uintptr_t)src_tp + src_inc);
dst_mp = (const ctf_lmember_t *)((uintptr_t)dst_tp + dst_inc);
for (; n != 0; n--, src_mp++, dst_mp++) {
if (src_mp->ctlm_offsethi != dst_mp->ctlm_offsethi ||
src_mp->ctlm_offsetlo != dst_mp->ctlm_offsetlo)
return (ctf_set_errno(dst_fp, ECTF_CONFLICT));
src_name = ctf_strptr(src_fp, src_mp->ctlm_name);
dst_name = ctf_strptr(dst_fp, dst_mp->ctlm_name);
if (strcmp(src_name, dst_name) != 0)
return (ctf_set_errno(dst_fp, ECTF_CONFLICT));
}
if (src_offset != dst_offset)
return (ctf_set_errno(dst_fp, ECTF_CONFLICT));
if (strcmp(src_name, dst_name) != 0)
return (ctf_set_errno(dst_fp, ECTF_CONFLICT));
}
return (0);
@@ -1307,9 +1402,9 @@ ctf_add_type(ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type)
ctf_id_t dst_type = CTF_ERR;
uint_t dst_kind = CTF_K_UNKNOWN;
const ctf_type_t *tp;
const void *tp;
const char *name;
uint_t kind, flag, vlen;
uint_t type, kind, flag, vlen;
ctf_bundle_t src, dst;
ctf_encoding_t src_en, main_en, dst_en;
@@ -1331,10 +1426,9 @@ ctf_add_type(ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type)
if ((tp = ctf_lookup_by_id(&src_fp, src_type)) == NULL)
return (ctf_set_errno(dst_fp, ctf_errno(src_fp)));
name = ctf_strptr(src_fp, tp->ctt_name);
kind = LCTF_INFO_KIND(src_fp, tp->ctt_info);
flag = LCTF_INFO_ROOT(src_fp, tp->ctt_info);
vlen = LCTF_INFO_VLEN(src_fp, tp->ctt_info);
name = ctf_type_rname(src_fp, tp);
ctf_get_ctt_info(src_fp, tp, &kind, &vlen, &flag);
switch (kind) {
case CTF_K_STRUCT:
@@ -1389,10 +1483,10 @@ ctf_add_type(ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type)
*/
if (dst_type == CTF_ERR && name[0] != '\0') {
for (dtd = ctf_list_prev(&dst_fp->ctf_dtdefs); dtd != NULL &&
CTF_TYPE_TO_INDEX(dtd->dtd_type) > dst_fp->ctf_dtoldid;
dtd = ctf_list_prev(dtd)) {
if (CTF_INFO_KIND(dtd->dtd_data.ctt_info) != kind ||
dtd->dtd_name == NULL ||
LCTF_TYPE_TO_INDEX(dst_fp, dtd->dtd_type) >
dst_fp->ctf_dtoldid; dtd = ctf_list_prev(dtd)) {
if (LCTF_INFO_KIND(dst_fp, dtd->dtd_data.ctt_info) !=
kind || dtd->dtd_name == NULL ||
strcmp(dtd->dtd_name, name) != 0)
continue;
if (kind == CTF_K_INTEGER || kind == CTF_K_FLOAT) {
@@ -1499,7 +1593,8 @@ ctf_add_type(ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type)
break;
case CTF_K_FUNCTION:
ctc.ctc_return = ctf_add_type(dst_fp, src_fp, tp->ctt_type);
ctf_get_ctt_index(src_fp, tp, NULL, &type, NULL);
ctc.ctc_return = ctf_add_type(dst_fp, src_fp, type);
ctc.ctc_argc = 0;
ctc.ctc_flags = 0;
@@ -1541,14 +1636,16 @@ ctf_add_type(ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type)
if (ctf_member_iter(src_fp, src_type, membadd, &dst) != 0)
errs++; /* increment errs and fail at bottom of case */
if ((size = ctf_type_size(src_fp, src_type)) > CTF_MAX_SIZE) {
dtd->dtd_data.ctt_size = CTF_LSIZE_SENT;
if ((size = ctf_type_size(src_fp, src_type)) >
LCTF_MAX_SIZE(src_fp)) {
dtd->dtd_data.ctt_size = LCTF_LSIZE_SENT(dst_fp);
dtd->dtd_data.ctt_lsizehi = CTF_SIZE_TO_LSIZE_HI(size);
dtd->dtd_data.ctt_lsizelo = CTF_SIZE_TO_LSIZE_LO(size);
} else
dtd->dtd_data.ctt_size = (ushort_t)size;
dtd->dtd_data.ctt_size = size;
dtd->dtd_data.ctt_info = CTF_TYPE_INFO(kind, flag, vlen);
dtd->dtd_data.ctt_info = LCTF_TYPE_INFO(dst_fp, kind, flag,
vlen);
/*
* Make a final pass through the members changing each dmd_type
+11 -8
View File
@@ -88,10 +88,10 @@ ctf_decl_push(ctf_decl_t *cd, ctf_file_t *fp, ctf_id_t type)
{
ctf_decl_node_t *cdp;
ctf_decl_prec_t prec;
uint_t kind, n = 1;
uint_t ctype, kind, n = 1;
int is_qual = 0;
const ctf_type_t *tp;
const void *tp;
ctf_arinfo_t ar;
if ((tp = ctf_lookup_by_id(&fp, type)) == NULL) {
@@ -99,7 +99,10 @@ ctf_decl_push(ctf_decl_t *cd, ctf_file_t *fp, ctf_id_t type)
return;
}
switch (kind = LCTF_INFO_KIND(fp, tp->ctt_info)) {
ctf_get_ctt_info(fp, tp, &kind, NULL, NULL);
ctf_get_ctt_index(fp, tp, NULL, &ctype, NULL);
switch (kind) {
case CTF_K_ARRAY:
(void) ctf_array_info(fp, type, &ar);
ctf_decl_push(cd, fp, ar.ctr_contents);
@@ -108,27 +111,27 @@ ctf_decl_push(ctf_decl_t *cd, ctf_file_t *fp, ctf_id_t type)
break;
case CTF_K_TYPEDEF:
if (ctf_strptr(fp, tp->ctt_name)[0] == '\0') {
ctf_decl_push(cd, fp, tp->ctt_type);
if (ctf_type_rname(fp, tp)[0] == '\0') {
ctf_decl_push(cd, fp, ctype);
return;
}
prec = CTF_PREC_BASE;
break;
case CTF_K_FUNCTION:
ctf_decl_push(cd, fp, tp->ctt_type);
ctf_decl_push(cd, fp, ctype);
prec = CTF_PREC_FUNCTION;
break;
case CTF_K_POINTER:
ctf_decl_push(cd, fp, tp->ctt_type);
ctf_decl_push(cd, fp, ctype);
prec = CTF_PREC_POINTER;
break;
case CTF_K_VOLATILE:
case CTF_K_CONST:
case CTF_K_RESTRICT:
ctf_decl_push(cd, fp, tp->ctt_type);
ctf_decl_push(cd, fp, ctype);
prec = cd->cd_qualp;
is_qual++;
break;
@@ -29,7 +29,7 @@
#include <ctf_impl.h>
static const ushort_t _CTF_EMPTY[1] = { 0 };
static const uint_t _CTF_EMPTY[1] = { 0 };
int
ctf_hash_create(ctf_hash_t *hp, ulong_t nelems)
@@ -43,7 +43,7 @@ ctf_hash_create(ctf_hash_t *hp, ulong_t nelems)
*/
if (nelems == 0) {
bzero(hp, sizeof (ctf_hash_t));
hp->h_buckets = (ushort_t *)_CTF_EMPTY;
hp->h_buckets = (uint_t *)_CTF_EMPTY;
hp->h_nbuckets = 1;
return (0);
}
@@ -52,7 +52,7 @@ ctf_hash_create(ctf_hash_t *hp, ulong_t nelems)
hp->h_nelems = nelems + 1; /* we use index zero as a sentinel */
hp->h_free = 1; /* first free element is index 1 */
hp->h_buckets = ctf_alloc(sizeof (ushort_t) * hp->h_nbuckets);
hp->h_buckets = ctf_alloc(sizeof (uint_t) * hp->h_nbuckets);
hp->h_chains = ctf_alloc(sizeof (ctf_helem_t) * hp->h_nelems);
if (hp->h_buckets == NULL || hp->h_chains == NULL) {
@@ -60,7 +60,7 @@ ctf_hash_create(ctf_hash_t *hp, ulong_t nelems)
return (EAGAIN);
}
bzero(hp->h_buckets, sizeof (ushort_t) * hp->h_nbuckets);
bzero(hp->h_buckets, sizeof (uint_t) * hp->h_nbuckets);
bzero(hp->h_chains, sizeof (ctf_helem_t) * hp->h_nelems);
return (0);
@@ -92,7 +92,7 @@ ctf_hash_compute(const char *key, size_t len)
}
int
ctf_hash_insert(ctf_hash_t *hp, ctf_file_t *fp, ushort_t type, uint_t name)
ctf_hash_insert(ctf_hash_t *hp, ctf_file_t *fp, uint_t type, uint_t name)
{
ctf_strs_t *ctsp = &fp->ctf_str[CTF_NAME_STID(name)];
const char *str = ctsp->cts_strs + CTF_NAME_OFFSET(name);
@@ -129,7 +129,7 @@ ctf_hash_insert(ctf_hash_t *hp, ctf_file_t *fp, ushort_t type, uint_t name)
* If the key is not present, then call ctf_hash_insert() and hash it in.
*/
int
ctf_hash_define(ctf_hash_t *hp, ctf_file_t *fp, ushort_t type, uint_t name)
ctf_hash_define(ctf_hash_t *hp, ctf_file_t *fp, uint_t type, uint_t name)
{
const char *str = ctf_strptr(fp, name);
ctf_helem_t *hep = ctf_hash_lookup(hp, fp, str, strlen(str));
@@ -147,7 +147,7 @@ ctf_hash_lookup(ctf_hash_t *hp, ctf_file_t *fp, const char *key, size_t len)
ctf_helem_t *hep;
ctf_strs_t *ctsp;
const char *str;
ushort_t i;
uint_t i;
ulong_t h = ctf_hash_compute(key, len) % hp->h_nbuckets;
@@ -167,7 +167,7 @@ void
ctf_hash_destroy(ctf_hash_t *hp)
{
if (hp->h_buckets != NULL && hp->h_nbuckets != 1) {
ctf_free(hp->h_buckets, sizeof (ushort_t) * hp->h_nbuckets);
ctf_free(hp->h_buckets, sizeof (uint_t) * hp->h_nbuckets);
hp->h_buckets = NULL;
}
+49 -16
View File
@@ -65,15 +65,15 @@ extern "C" {
typedef struct ctf_helem {
uint_t h_name; /* reference to name in string table */
ushort_t h_type; /* corresponding type ID number */
ushort_t h_next; /* index of next element in hash chain */
uint_t h_type; /* corresponding type ID number */
uint_t h_next; /* index of next element in hash chain */
} ctf_helem_t;
typedef struct ctf_hash {
ushort_t *h_buckets; /* hash bucket array (chain indices) */
uint_t *h_buckets; /* hash bucket array (chain indices) */
ctf_helem_t *h_chains; /* hash chains buffer */
ushort_t h_nbuckets; /* number of elements in bucket array */
ushort_t h_nelems; /* number of elements in hash table */
uint_t h_nbuckets; /* number of elements in bucket array */
uint_t h_nelems; /* number of elements in hash table */
uint_t h_free; /* index of next free hash element */
} ctf_hash_t;
@@ -99,9 +99,20 @@ typedef struct ctf_lookup {
} ctf_lookup_t;
typedef struct ctf_fileops {
ushort_t (*ctfo_get_kind)(ushort_t);
ushort_t (*ctfo_get_root)(ushort_t);
ushort_t (*ctfo_get_vlen)(ushort_t);
uint_t (*ctfo_get_kind)(uint_t);
uint_t (*ctfo_get_root)(uint_t);
uint_t (*ctfo_get_vlen)(uint_t);
uint_t (*ctfo_get_max_vlen)(void);
uint_t (*ctfo_get_max_size)(void);
uint_t (*ctfo_get_max_type)(void);
uint_t (*ctfo_get_lsize_sent)(void);
uint_t (*ctfo_get_lstruct_thresh)(void);
uint_t (*ctfo_type_info)(uint_t, uint_t, uint_t);
int (*ctfo_type_isparent)(uint_t);
int (*ctfo_type_ischild)(uint_t);
uint_t (*ctfo_type_to_index)(uint_t);
uint_t (*ctfo_index_to_type)(uint_t, uint_t);
} ctf_fileops_t;
typedef struct ctf_list {
@@ -149,7 +160,7 @@ typedef struct ctf_dtdef {
struct ctf_dtdef *dtd_hash; /* hash chain pointer for ctf_dthash */
char *dtd_name; /* name associated with definition (if any) */
ctf_id_t dtd_type; /* type identifier for this definition */
ctf_type_t dtd_data; /* type node (see <sys/ctf.h>) */
struct ctf_type_v3 dtd_data; /* type node (see <sys/ctf.h>) */
int dtd_ref; /* recfount for dyanmic types */
union {
ctf_list_t dtu_members; /* struct, union, or enum */
@@ -194,7 +205,7 @@ struct ctf_file {
uint_t *ctf_sxlate; /* translation table for symtab entries */
ulong_t ctf_nsyms; /* number of entries in symtab xlate table */
uint_t *ctf_txlate; /* translation table for type IDs */
ushort_t *ctf_ptrtab; /* translation table for pointer-to lookups */
uint_t *ctf_ptrtab; /* translation table for pointer-to lookups */
ulong_t ctf_typemax; /* maximum valid type ID number */
const ctf_dmodel_t *ctf_dmodel; /* data model pointer (see above) */
struct ctf_file *ctf_parent; /* parent CTF container (if any) */
@@ -204,6 +215,7 @@ struct ctf_file {
uint_t ctf_flags; /* libctf flags (see below) */
int ctf_errno; /* error code for most recent error */
int ctf_version; /* CTF data version */
size_t ctf_idwidth; /* Size, in bytes, of a type ID */
ctf_dtdef_t **ctf_dthash; /* hash of dynamic type definitions */
ulong_t ctf_dthashlen; /* size of dynamic type hash bucket array */
ctf_list_t ctf_dtdefs; /* list of dynamic type definitions */
@@ -214,11 +226,24 @@ struct ctf_file {
};
#define LCTF_INDEX_TO_TYPEPTR(fp, i) \
((ctf_type_t *)((uintptr_t)(fp)->ctf_buf + (fp)->ctf_txlate[(i)]))
((void *)((uintptr_t)(fp)->ctf_buf + (fp)->ctf_txlate[(i)]))
#define LCTF_INFO_KIND(fp, info) ((fp)->ctf_fileops->ctfo_get_kind(info))
#define LCTF_INFO_ROOT(fp, info) ((fp)->ctf_fileops->ctfo_get_root(info))
#define LCTF_INFO_VLEN(fp, info) ((fp)->ctf_fileops->ctfo_get_vlen(info))
#define LCTF_MAX_VLEN(fp) ((fp)->ctf_fileops->ctfo_get_max_vlen())
#define LCTF_MAX_SIZE(fp) ((fp)->ctf_fileops->ctfo_get_max_size())
#define LCTF_MAX_TYPE(fp) ((fp)->ctf_fileops->ctfo_get_max_type())
#define LCTF_LSIZE_SENT(fp) \
((fp)->ctf_fileops->ctfo_get_lsize_sent())
#define LCTF_LSTRUCT_THRESH(fp) \
((fp)->ctf_fileops->ctfo_get_lstruct_thresh())
#define LCTF_TYPE_INFO(fp, k, r, l) ((fp)->ctf_fileops->ctfo_type_info(k, r, l))
#define LCTF_TYPE_ISPARENT(fp, id) ((fp)->ctf_fileops->ctfo_type_isparent(id))
#define LCTF_TYPE_ISCHILD(fp, id) ((fp)->ctf_fileops->ctfo_type_ischild(id))
#define LCTF_TYPE_TO_INDEX(fp, t) ((fp)->ctf_fileops->ctfo_type_to_index(t))
#define LCTF_INDEX_TO_TYPE(fp, id, c) ((fp)->ctf_fileops->ctfo_index_to_type(id, c))
#define LCTF_MMAP 0x0001 /* libctf should munmap buffers on close */
#define LCTF_CHILD 0x0002 /* CTF container is a child */
@@ -276,14 +301,22 @@ enum {
ECTF_NOTDYN /* type is not a dynamic type */
};
extern ssize_t ctf_get_ctt_size(const ctf_file_t *, const ctf_type_t *,
ssize_t *, ssize_t *);
extern void ctf_get_ctt_index(const ctf_file_t *fp, const void *v,
uint_t *indexp, uint_t *typep, int *ischildp);
extern ssize_t ctf_get_ctt_size(const ctf_file_t *, const void *v, ssize_t *,
ssize_t *);
extern void ctf_get_ctt_info(const ctf_file_t *, const void *v, uint_t *kind,
uint_t *vlen, int *isroot);
extern const ctf_type_t *ctf_lookup_by_id(ctf_file_t **, ctf_id_t);
extern void ctf_get_ctm_info(const ctf_file_t *fp, const void *v, size_t sz,
size_t *incrementp, uint_t *typep, ulong_t *offsetp, const char **namep);
extern const void *ctf_lookup_by_id(ctf_file_t **, ctf_id_t);
extern const char *ctf_type_rname(ctf_file_t *, const void *);
extern int ctf_hash_create(ctf_hash_t *, ulong_t);
extern int ctf_hash_insert(ctf_hash_t *, ctf_file_t *, ushort_t, uint_t);
extern int ctf_hash_define(ctf_hash_t *, ctf_file_t *, ushort_t, uint_t);
extern int ctf_hash_insert(ctf_hash_t *, ctf_file_t *, uint_t, uint_t);
extern int ctf_hash_define(ctf_hash_t *, ctf_file_t *, uint_t, uint_t);
extern ctf_helem_t *ctf_hash_lookup(ctf_hash_t *, ctf_file_t *,
const char *, size_t);
extern uint_t ctf_hash_size(const ctf_hash_t *);
@@ -111,17 +111,17 @@ ctf_lookup_by_name(ctf_file_t *fp, const char *name)
* data includes "struct foo *" but not "foo_t *" and
* the user tries to access "foo_t *" in the debugger.
*/
ntype = fp->ctf_ptrtab[CTF_TYPE_TO_INDEX(type)];
ntype = fp->ctf_ptrtab[LCTF_TYPE_TO_INDEX(fp, type)];
if (ntype == 0) {
ntype = ctf_type_resolve(fp, type);
if (ntype == CTF_ERR || (ntype = fp->ctf_ptrtab[
CTF_TYPE_TO_INDEX(ntype)]) == 0) {
LCTF_TYPE_TO_INDEX(fp, ntype)]) == 0) {
(void) ctf_set_errno(fp, ECTF_NOTYPE);
goto err;
}
}
type = CTF_INDEX_TO_TYPE(ntype,
type = LCTF_INDEX_TO_TYPE(fp, ntype,
(fp->ctf_flags & LCTF_CHILD));
q = p + 1;
@@ -203,7 +203,7 @@ ctf_lookup_by_symbol(ctf_file_t *fp, ulong_t symidx)
if (fp->ctf_sxlate[symidx] == -1u)
return (ctf_set_errno(fp, ECTF_NOTYPEDAT));
type = *(ushort_t *)((uintptr_t)fp->ctf_buf + fp->ctf_sxlate[symidx]);
type = *(uint_t *)((uintptr_t)fp->ctf_buf + fp->ctf_sxlate[symidx]);
if (type == 0)
return (ctf_set_errno(fp, ECTF_NOTYPEDAT));
@@ -215,18 +215,24 @@ ctf_lookup_by_symbol(ctf_file_t *fp, ulong_t symidx)
* given type ID. If the ID is invalid, the function returns NULL.
* This function is not exported outside of the library.
*/
const ctf_type_t *
const void *
ctf_lookup_by_id(ctf_file_t **fpp, ctf_id_t type)
{
ctf_file_t *fp = *fpp; /* caller passes in starting CTF container */
if ((fp->ctf_flags & LCTF_CHILD) && CTF_TYPE_ISPARENT(type) &&
(fp = fp->ctf_parent) == NULL) {
(void) ctf_set_errno(*fpp, ECTF_NOPARENT);
return (NULL);
if ((fp->ctf_flags & LCTF_CHILD) && LCTF_TYPE_ISPARENT(fp, type)) {
if (fp->ctf_parent == NULL) {
(void) ctf_set_errno(*fpp, ECTF_NOPARENT);
return (NULL);
}
/* The parent may be using a different CTF version. */
type = LCTF_TYPE_TO_INDEX(fp, type);
fp = fp->ctf_parent;
} else {
type = LCTF_TYPE_TO_INDEX(fp, type);
}
type = CTF_TYPE_TO_INDEX(type);
if (type > 0 && type <= fp->ctf_typemax) {
*fpp = fp; /* function returns ending CTF container */
return (LCTF_INDEX_TO_TYPEPTR(fp, type));
@@ -244,8 +250,8 @@ int
ctf_func_info(ctf_file_t *fp, ulong_t symidx, ctf_funcinfo_t *fip)
{
const ctf_sect_t *sp = &fp->ctf_symtab;
const ushort_t *dp;
ushort_t info, kind, n;
const uint_t *dp;
uint_t info, kind, n;
if (sp->cts_data == NULL)
return (ctf_set_errno(fp, ECTF_NOSYMTAB));
@@ -266,7 +272,7 @@ ctf_func_info(ctf_file_t *fp, ulong_t symidx, ctf_funcinfo_t *fip)
if (fp->ctf_sxlate[symidx] == -1u)
return (ctf_set_errno(fp, ECTF_NOFUNCDAT));
dp = (ushort_t *)((uintptr_t)fp->ctf_buf + fp->ctf_sxlate[symidx]);
dp = (uint_t *)((uintptr_t)fp->ctf_buf + fp->ctf_sxlate[symidx]);
info = *dp++;
kind = LCTF_INFO_KIND(fp, info);
@@ -297,17 +303,17 @@ ctf_func_info(ctf_file_t *fp, ulong_t symidx, ctf_funcinfo_t *fip)
int
ctf_func_args(ctf_file_t *fp, ulong_t symidx, uint_t argc, ctf_id_t *argv)
{
const ushort_t *dp;
const uint_t *dp;
ctf_funcinfo_t f;
if (ctf_func_info(fp, symidx, &f) == CTF_ERR)
return (CTF_ERR); /* errno is set for us */
/*
* The argument data is two ushort_t's past the translation table
* The argument data is two uint_t's past the translation table
* offset: one for the function info, and one for the return type.
*/
dp = (ushort_t *)((uintptr_t)fp->ctf_buf + fp->ctf_sxlate[symidx]) + 2;
dp = (uint_t *)((uintptr_t)fp->ctf_buf + fp->ctf_sxlate[symidx]) + 2;
for (argc = MIN(argc, f.ctc_argc); argc != 0; argc--)
*argv++ = *dp++;
+283 -86
View File
@@ -44,28 +44,184 @@ const char _CTF_NULLSTR[] = "";
int _libctf_version = CTF_VERSION; /* library client version */
int _libctf_debug = 0; /* debugging messages enabled */
static ushort_t
get_kind_v2(ushort_t info)
static uint_t
get_kind_v2(uint_t info)
{
return (CTF_INFO_KIND(info));
return (CTF_V2_INFO_KIND((ushort_t)info));
}
static ushort_t
get_root_v2(ushort_t info)
static uint_t
get_root_v2(uint_t info)
{
return (CTF_INFO_ISROOT(info));
return (CTF_V2_INFO_ISROOT((ushort_t)info));
}
static ushort_t
get_vlen_v2(ushort_t info)
static uint_t
get_vlen_v2(uint_t info)
{
return (CTF_INFO_VLEN(info));
return (CTF_V2_INFO_VLEN((ushort_t)info));
}
static uint_t
get_max_vlen_v2(void)
{
return (CTF_V2_MAX_VLEN);
}
static uint_t
get_max_size_v2(void)
{
return (CTF_V2_MAX_SIZE);
}
static uint_t
get_max_type_v2(void)
{
return (CTF_V2_MAX_TYPE);
}
static uint_t
get_lsize_sent_v2(void)
{
return (CTF_V2_LSIZE_SENT);
}
static uint_t
get_lstruct_thresh_v2(void)
{
return (CTF_V2_LSTRUCT_THRESH);
}
static uint_t
type_info_v2(uint_t kind, uint_t isroot, uint_t len)
{
return (CTF_V2_TYPE_INFO(kind, isroot, len));
}
static int
type_isparent_v2(uint_t id)
{
return (CTF_V2_TYPE_ISPARENT(id));
}
static int
type_ischild_v2(uint_t id)
{
return (CTF_V2_TYPE_ISCHILD(id));
}
static uint_t
type_to_index_v2(uint_t t)
{
return (CTF_V2_TYPE_TO_INDEX(t));
}
static uint_t
index_to_type_v2(uint_t id, uint_t child)
{
return (CTF_V2_INDEX_TO_TYPE(id, child));
}
static uint_t
get_kind_v3(uint_t info)
{
return (CTF_V3_INFO_KIND(info));
}
static uint_t
get_root_v3(uint_t info)
{
return (CTF_V3_INFO_ISROOT(info));
}
static uint_t
get_vlen_v3(uint_t info)
{
return (CTF_V3_INFO_VLEN(info));
}
static uint_t
get_max_vlen_v3(void)
{
return (CTF_V3_MAX_VLEN);
}
static uint_t
get_max_size_v3(void)
{
return (CTF_V3_MAX_SIZE);
}
static uint_t
get_max_type_v3(void)
{
return (CTF_V3_MAX_TYPE);
}
static uint_t
get_lsize_sent_v3(void)
{
return (CTF_V3_LSIZE_SENT);
}
static uint_t
get_lstruct_thresh_v3(void)
{
return (CTF_V3_LSTRUCT_THRESH);
}
static uint_t
type_info_v3(uint_t kind, uint_t isroot, uint_t len)
{
return (CTF_V3_TYPE_INFO(kind, isroot, len));
}
static int
type_isparent_v3(uint_t id)
{
return (CTF_V3_TYPE_ISPARENT(id));
}
static int
type_ischild_v3(uint_t id)
{
return (CTF_V3_TYPE_ISCHILD(id));
}
static uint_t
type_to_index_v3(uint_t t)
{
return (CTF_V3_TYPE_TO_INDEX(t));
}
static uint_t
index_to_type_v3(uint_t id, uint_t child)
{
return (CTF_V3_INDEX_TO_TYPE(id, child));
}
#define CTF_FILEOPS_ENTRY(v) \
{ \
.ctfo_get_kind = get_kind_v ## v, \
.ctfo_get_root = get_root_v ## v, \
.ctfo_get_vlen = get_vlen_v ## v, \
.ctfo_get_max_vlen = get_max_vlen_v ## v, \
.ctfo_get_max_size = get_max_size_v ## v, \
.ctfo_get_max_type = get_max_type_v ## v, \
.ctfo_get_lsize_sent = get_lsize_sent_v ## v, \
.ctfo_get_lstruct_thresh = get_lstruct_thresh_v ## v, \
.ctfo_type_info = type_info_v ## v, \
.ctfo_type_isparent = type_isparent_v ## v, \
.ctfo_type_ischild = type_ischild_v ## v, \
.ctfo_type_to_index = type_to_index_v ## v, \
.ctfo_index_to_type = index_to_type_v ## v \
}
static const ctf_fileops_t ctf_fileops[] = {
{ NULL, NULL },
{ NULL, NULL },
{ get_kind_v2, get_root_v2, get_vlen_v2 },
CTF_FILEOPS_ENTRY(2),
CTF_FILEOPS_ENTRY(3),
};
/*
@@ -100,7 +256,8 @@ init_symtab(ctf_file_t *fp, const ctf_header_t *hp,
uint_t objtoff = hp->cth_objtoff;
uint_t funcoff = hp->cth_funcoff;
ushort_t info, vlen;
uint_t info, vlen;
Elf64_Sym sym, *gsp;
const char *name;
@@ -138,7 +295,7 @@ init_symtab(ctf_file_t *fp, const ctf_header_t *hp,
}
*xp = objtoff;
objtoff += sizeof (ushort_t);
objtoff += fp->ctf_idwidth;
break;
case STT_FUNC:
@@ -149,7 +306,7 @@ init_symtab(ctf_file_t *fp, const ctf_header_t *hp,
*xp = funcoff;
info = *(ushort_t *)((uintptr_t)fp->ctf_buf + funcoff);
info = *(uint_t *)((uintptr_t)fp->ctf_buf + funcoff);
vlen = LCTF_INFO_VLEN(fp, info);
/*
@@ -159,9 +316,10 @@ init_symtab(ctf_file_t *fp, const ctf_header_t *hp,
*/
if (LCTF_INFO_KIND(fp, info) == CTF_K_UNKNOWN &&
vlen == 0)
funcoff += sizeof (ushort_t); /* skip pad */
funcoff += fp->ctf_idwidth;
else
funcoff += sizeof (ushort_t) * (vlen + 2);
funcoff +=
roundup2(fp->ctf_idwidth * (vlen + 2), 4);
break;
default:
@@ -181,15 +339,13 @@ init_symtab(ctf_file_t *fp, const ctf_header_t *hp,
static int
init_types(ctf_file_t *fp, const ctf_header_t *cth)
{
/* LINTED - pointer alignment */
const ctf_type_t *tbuf = (ctf_type_t *)(fp->ctf_buf + cth->cth_typeoff);
/* LINTED - pointer alignment */
const ctf_type_t *tend = (ctf_type_t *)(fp->ctf_buf + cth->cth_stroff);
const void *tbuf = (const void *)(fp->ctf_buf + cth->cth_typeoff);
const void *tend = (const void *)(fp->ctf_buf + cth->cth_stroff);
ulong_t pop[CTF_K_MAX + 1] = { 0 };
const ctf_type_t *tp;
const void *tp;
ctf_hash_t *hp;
ushort_t id, dst;
uint_t id, dst;
uint_t *xp;
/*
@@ -207,14 +363,14 @@ init_types(ctf_file_t *fp, const ctf_header_t *cth)
* pass, we count the number of each type and the total number of types.
*/
for (tp = tbuf; tp < tend; fp->ctf_typemax++) {
ushort_t kind = LCTF_INFO_KIND(fp, tp->ctt_info);
ulong_t vlen = LCTF_INFO_VLEN(fp, tp->ctt_info);
ssize_t size, increment;
size_t vbytes;
uint_t n;
uint_t kind, n, type, vlen;
(void) ctf_get_ctt_size(fp, tp, &size, &increment);
ctf_get_ctt_info(fp, tp, &kind, &vlen, NULL);
ctf_get_ctt_index(fp, tp, NULL, &type, NULL);
switch (kind) {
case CTF_K_INTEGER:
@@ -222,30 +378,30 @@ init_types(ctf_file_t *fp, const ctf_header_t *cth)
vbytes = sizeof (uint_t);
break;
case CTF_K_ARRAY:
vbytes = sizeof (ctf_array_t);
if (fp->ctf_version == CTF_VERSION_2)
vbytes = sizeof (struct ctf_array_v2);
else
vbytes = sizeof (struct ctf_array_v3);
break;
case CTF_K_FUNCTION:
vbytes = sizeof (ushort_t) * (vlen + (vlen & 1));
vbytes = roundup2(fp->ctf_idwidth * vlen, 4);
break;
case CTF_K_STRUCT:
case CTF_K_UNION:
if (size < CTF_LSTRUCT_THRESH) {
ctf_member_t *mp = (ctf_member_t *)
((uintptr_t)tp + increment);
case CTF_K_UNION: {
size_t increment1;
uint_t type;
const void *mp =
(const void *)((uintptr_t)tp + increment);
vbytes = sizeof (ctf_member_t) * vlen;
for (n = vlen; n != 0; n--, mp++)
child |= CTF_TYPE_ISCHILD(mp->ctm_type);
} else {
ctf_lmember_t *lmp = (ctf_lmember_t *)
((uintptr_t)tp + increment);
vbytes = sizeof (ctf_lmember_t) * vlen;
for (n = vlen; n != 0; n--, lmp++)
child |=
CTF_TYPE_ISCHILD(lmp->ctlm_type);
vbytes = 0;
for (n = vlen; n != 0; n--, mp += increment1) {
ctf_get_ctm_info(fp, mp, size, &increment1, &type,
NULL, NULL);
child |= LCTF_TYPE_ISCHILD(fp, type);
vbytes += increment1;
}
break;
}
case CTF_K_ENUM:
vbytes = sizeof (ctf_enum_t) * vlen;
break;
@@ -255,11 +411,10 @@ init_types(ctf_file_t *fp, const ctf_header_t *cth)
* kind for the tag, so bump that population count too.
* If ctt_type is unknown, treat the tag as a struct.
*/
if (tp->ctt_type == CTF_K_UNKNOWN ||
tp->ctt_type >= CTF_K_MAX)
if (type == CTF_K_UNKNOWN || type >= CTF_K_MAX)
pop[CTF_K_STRUCT]++;
else
pop[tp->ctt_type]++;
pop[type]++;
/*FALLTHRU*/
case CTF_K_UNKNOWN:
vbytes = 0;
@@ -269,14 +424,14 @@ init_types(ctf_file_t *fp, const ctf_header_t *cth)
case CTF_K_VOLATILE:
case CTF_K_CONST:
case CTF_K_RESTRICT:
child |= CTF_TYPE_ISCHILD(tp->ctt_type);
child |= LCTF_TYPE_ISCHILD(fp, type);
vbytes = 0;
break;
default:
ctf_dprintf("detected invalid CTF kind -- %u\n", kind);
return (ECTF_CORRUPT);
}
tp = (ctf_type_t *)((uintptr_t)tp + increment + vbytes);
tp = (const void *)((uintptr_t)tp + increment + vbytes);
pop[kind]++;
}
@@ -310,7 +465,7 @@ init_types(ctf_file_t *fp, const ctf_header_t *cth)
return (err);
fp->ctf_txlate = ctf_alloc(sizeof (uint_t) * (fp->ctf_typemax + 1));
fp->ctf_ptrtab = ctf_alloc(sizeof (ushort_t) * (fp->ctf_typemax + 1));
fp->ctf_ptrtab = ctf_alloc(sizeof (uint_t) * (fp->ctf_typemax + 1));
if (fp->ctf_txlate == NULL || fp->ctf_ptrtab == NULL)
return (EAGAIN); /* memory allocation failed */
@@ -319,15 +474,15 @@ init_types(ctf_file_t *fp, const ctf_header_t *cth)
*xp++ = 0; /* type id 0 is used as a sentinel value */
bzero(fp->ctf_txlate, sizeof (uint_t) * (fp->ctf_typemax + 1));
bzero(fp->ctf_ptrtab, sizeof (ushort_t) * (fp->ctf_typemax + 1));
bzero(fp->ctf_ptrtab, sizeof (uint_t) * (fp->ctf_typemax + 1));
/*
* In the second pass through the types, we fill in each entry of the
* type and pointer tables and add names to the appropriate hashes.
*/
for (id = 1, tp = tbuf; tp < tend; xp++, id++) {
ushort_t kind = LCTF_INFO_KIND(fp, tp->ctt_info);
ulong_t vlen = LCTF_INFO_VLEN(fp, tp->ctt_info);
const struct ctf_type_v3 *ctt = tp;
uint_t kind, type, vlen;
ssize_t size, increment;
const char *name;
@@ -336,7 +491,9 @@ init_types(ctf_file_t *fp, const ctf_header_t *cth)
ctf_encoding_t cte;
(void) ctf_get_ctt_size(fp, tp, &size, &increment);
name = ctf_strptr(fp, tp->ctt_name);
ctf_get_ctt_info(fp, tp, &kind, &vlen, NULL);
ctf_get_ctt_index(fp, tp, NULL, &type, NULL);
name = ctf_type_rname(fp, tp);
switch (kind) {
case CTF_K_INTEGER:
@@ -349,7 +506,8 @@ init_types(ctf_file_t *fp, const ctf_header_t *cth)
if ((hep = ctf_hash_lookup(&fp->ctf_names, fp,
name, strlen(name))) == NULL) {
err = ctf_hash_insert(&fp->ctf_names, fp,
CTF_INDEX_TO_TYPE(id, child), tp->ctt_name);
LCTF_INDEX_TO_TYPE(fp, id, child),
ctt->ctt_name);
if (err != 0 && err != ECTF_STRTAB)
return (err);
} else if (ctf_type_encoding(fp, hep->h_type,
@@ -358,56 +516,89 @@ init_types(ctf_file_t *fp, const ctf_header_t *cth)
* Work-around SOS8 stabs bug: replace existing
* intrinsic w/ same name if it was zero bits.
*/
hep->h_type = CTF_INDEX_TO_TYPE(id, child);
hep->h_type = LCTF_INDEX_TO_TYPE(fp, id, child);
}
vbytes = sizeof (uint_t);
break;
case CTF_K_ARRAY:
vbytes = sizeof (ctf_array_t);
if (fp->ctf_version == CTF_VERSION_2)
vbytes = sizeof (struct ctf_array_v2);
else
vbytes = sizeof (struct ctf_array_v3);
break;
case CTF_K_FUNCTION:
err = ctf_hash_insert(&fp->ctf_names, fp,
CTF_INDEX_TO_TYPE(id, child), tp->ctt_name);
LCTF_INDEX_TO_TYPE(fp, id, child), ctt->ctt_name);
if (err != 0 && err != ECTF_STRTAB)
return (err);
vbytes = sizeof (ushort_t) * (vlen + (vlen & 1));
vbytes = roundup2(fp->ctf_idwidth * vlen, 4);
break;
case CTF_K_STRUCT:
err = ctf_hash_define(&fp->ctf_structs, fp,
CTF_INDEX_TO_TYPE(id, child), tp->ctt_name);
LCTF_INDEX_TO_TYPE(fp, id, child), ctt->ctt_name);
if (err != 0 && err != ECTF_STRTAB)
return (err);
if (size < CTF_LSTRUCT_THRESH)
vbytes = sizeof (ctf_member_t) * vlen;
else {
vbytes = sizeof (ctf_lmember_t) * vlen;
nlstructs++;
if (fp->ctf_version == CTF_VERSION_2) {
if (size < LCTF_LSTRUCT_THRESH(fp))
vbytes = sizeof (struct ctf_member_v2) *
vlen;
else {
vbytes =
sizeof (struct ctf_lmember_v2) *
vlen;
nlstructs++;
}
} else {
if (size < LCTF_LSTRUCT_THRESH(fp))
vbytes = sizeof (struct ctf_member_v3) *
vlen;
else {
vbytes =
sizeof (struct ctf_lmember_v3) *
vlen;
nlstructs++;
}
}
break;
case CTF_K_UNION:
err = ctf_hash_define(&fp->ctf_unions, fp,
CTF_INDEX_TO_TYPE(id, child), tp->ctt_name);
LCTF_INDEX_TO_TYPE(fp, id, child), ctt->ctt_name);
if (err != 0 && err != ECTF_STRTAB)
return (err);
if (size < CTF_LSTRUCT_THRESH)
vbytes = sizeof (ctf_member_t) * vlen;
else {
vbytes = sizeof (ctf_lmember_t) * vlen;
nlunions++;
if (fp->ctf_version == CTF_VERSION_2) {
if (size < LCTF_LSTRUCT_THRESH(fp))
vbytes = sizeof (struct ctf_member_v2) *
vlen;
else {
vbytes =
sizeof (struct ctf_lmember_v2) *
vlen;
nlunions++;
}
} else {
if (size < LCTF_LSTRUCT_THRESH(fp))
vbytes = sizeof (struct ctf_member_v3) *
vlen;
else {
vbytes =
sizeof (struct ctf_lmember_v3) *
vlen;
nlunions++;
}
}
break;
case CTF_K_ENUM:
err = ctf_hash_define(&fp->ctf_enums, fp,
CTF_INDEX_TO_TYPE(id, child), tp->ctt_name);
LCTF_INDEX_TO_TYPE(fp, id, child), ctt->ctt_name);
if (err != 0 && err != ECTF_STRTAB)
return (err);
@@ -417,7 +608,7 @@ init_types(ctf_file_t *fp, const ctf_header_t *cth)
case CTF_K_TYPEDEF:
err = ctf_hash_insert(&fp->ctf_names, fp,
CTF_INDEX_TO_TYPE(id, child), tp->ctt_name);
LCTF_INDEX_TO_TYPE(fp, id, child), ctt->ctt_name);
if (err != 0 && err != ECTF_STRTAB)
return (err);
vbytes = 0;
@@ -428,7 +619,7 @@ init_types(ctf_file_t *fp, const ctf_header_t *cth)
* Only insert forward tags into the given hash if the
* type or tag name is not already present.
*/
switch (tp->ctt_type) {
switch (type) {
case CTF_K_STRUCT:
hp = &fp->ctf_structs;
break;
@@ -445,7 +636,8 @@ init_types(ctf_file_t *fp, const ctf_header_t *cth)
if (ctf_hash_lookup(hp, fp,
name, strlen(name)) == NULL) {
err = ctf_hash_insert(hp, fp,
CTF_INDEX_TO_TYPE(id, child), tp->ctt_name);
LCTF_INDEX_TO_TYPE(fp, id, child),
ctt->ctt_name);
if (err != 0 && err != ECTF_STRTAB)
return (err);
}
@@ -458,17 +650,17 @@ init_types(ctf_file_t *fp, const ctf_header_t *cth)
* container, then store the index of the pointer type
* in fp->ctf_ptrtab[ index of referenced type ].
*/
if (CTF_TYPE_ISCHILD(tp->ctt_type) == child &&
CTF_TYPE_TO_INDEX(tp->ctt_type) <= fp->ctf_typemax)
if (LCTF_TYPE_ISCHILD(fp, type) == child &&
LCTF_TYPE_TO_INDEX(fp, type) <= fp->ctf_typemax)
fp->ctf_ptrtab[
CTF_TYPE_TO_INDEX(tp->ctt_type)] = id;
LCTF_TYPE_TO_INDEX(fp, type)] = id;
/*FALLTHRU*/
case CTF_K_VOLATILE:
case CTF_K_CONST:
case CTF_K_RESTRICT:
err = ctf_hash_insert(&fp->ctf_names, fp,
CTF_INDEX_TO_TYPE(id, child), tp->ctt_name);
LCTF_INDEX_TO_TYPE(fp, id, child), ctt->ctt_name);
if (err != 0 && err != ECTF_STRTAB)
return (err);
/*FALLTHRU*/
@@ -479,7 +671,7 @@ init_types(ctf_file_t *fp, const ctf_header_t *cth)
}
*xp = (uint_t)((uintptr_t)tp - (uintptr_t)fp->ctf_buf);
tp = (ctf_type_t *)((uintptr_t)tp + increment + vbytes);
tp = (const void *)((uintptr_t)tp + increment + vbytes);
}
ctf_dprintf("%lu total types processed\n", fp->ctf_typemax);
@@ -499,14 +691,17 @@ init_types(ctf_file_t *fp, const ctf_header_t *cth)
*/
for (id = 1; id <= fp->ctf_typemax; id++) {
if ((dst = fp->ctf_ptrtab[id]) != 0) {
tp = LCTF_INDEX_TO_TYPEPTR(fp, id);
uint_t index, kind;
int ischild;
if (LCTF_INFO_KIND(fp, tp->ctt_info) == CTF_K_TYPEDEF &&
strcmp(ctf_strptr(fp, tp->ctt_name), "") == 0 &&
CTF_TYPE_ISCHILD(tp->ctt_type) == child &&
CTF_TYPE_TO_INDEX(tp->ctt_type) <= fp->ctf_typemax)
fp->ctf_ptrtab[
CTF_TYPE_TO_INDEX(tp->ctt_type)] = dst;
tp = LCTF_INDEX_TO_TYPEPTR(fp, id);
ctf_get_ctt_info(fp, tp, &kind, NULL, NULL);
ctf_get_ctt_index(fp, tp, &index, NULL, &ischild);
if (kind == CTF_K_TYPEDEF &&
strcmp(ctf_type_rname(fp, tp), "") == 0 &&
ischild == child && index <= fp->ctf_typemax)
fp->ctf_ptrtab[index] = dst;
}
}
@@ -560,7 +755,8 @@ ctf_bufopen(const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
if (pp->ctp_magic != CTF_MAGIC)
return (ctf_set_open_errno(errp, ECTF_NOCTFBUF));
if (pp->ctp_version == CTF_VERSION_2) {
if (pp->ctp_version == CTF_VERSION_2 ||
pp->ctp_version == CTF_VERSION_3) {
if (ctfsect->cts_size < sizeof (ctf_header_t))
return (ctf_set_open_errno(errp, ECTF_NOCTFBUF));
@@ -642,6 +838,7 @@ ctf_bufopen(const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
bzero(fp, sizeof (ctf_file_t));
fp->ctf_version = hp.cth_version;
fp->ctf_idwidth = fp->ctf_version == CTF_VERSION_2 ? 2 : 4;
fp->ctf_fileops = &ctf_fileops[hp.cth_version];
bcopy(ctfsect, &fp->ctf_data, sizeof (ctf_sect_t));
@@ -911,7 +1108,7 @@ ctf_close(ctf_file_t *fp)
if (fp->ctf_ptrtab != NULL) {
ctf_free(fp->ctf_ptrtab,
sizeof (ushort_t) * (fp->ctf_typemax + 1));
sizeof (uint_t) * (fp->ctf_typemax + 1));
}
ctf_hash_destroy(&fp->ctf_structs);
+285 -148
View File
@@ -27,18 +27,90 @@
#include <ctf_impl.h>
void
ctf_get_ctt_index(const ctf_file_t *fp, const void *v, uint_t *indexp,
uint_t *typep, int *ischildp)
{
uint_t index, type;
int ischild;
if (fp->ctf_version == CTF_VERSION_2) {
const struct ctf_type_v2 *ctt = v;
type = ctt->ctt_type;
index = CTF_V2_TYPE_TO_INDEX(ctt->ctt_type);
ischild = CTF_V2_TYPE_ISCHILD(ctt->ctt_type);
} else {
const struct ctf_type_v3 *ctt = v;
type = ctt->ctt_type;
index = CTF_V3_TYPE_TO_INDEX(ctt->ctt_type);
ischild = CTF_V3_TYPE_ISCHILD(ctt->ctt_type);
}
if (indexp != NULL)
*indexp = index;
if (typep != NULL)
*typep = type;
if (ischildp != NULL)
*ischildp = ischild;
}
void
ctf_get_ctt_info(const ctf_file_t *fp, const void *v, uint_t *kindp,
uint_t *vlenp, int *isrootp)
{
uint_t kind, vlen;
int isroot;
if (fp->ctf_version == CTF_VERSION_2) {
const struct ctf_type_v2 *ctt = v;
kind = CTF_V2_INFO_KIND(ctt->ctt_info);
vlen = CTF_V2_INFO_VLEN(ctt->ctt_info);
isroot = CTF_V2_INFO_ISROOT(ctt->ctt_info);
} else {
const struct ctf_type_v3 *ctt = v;
kind = CTF_V3_INFO_KIND(ctt->ctt_info);
vlen = CTF_V3_INFO_VLEN(ctt->ctt_info);
isroot = CTF_V3_INFO_ISROOT(ctt->ctt_info);
}
if (kindp != NULL)
*kindp = kind;
if (vlenp != NULL)
*vlenp = vlen;
if (isrootp != NULL)
*isrootp = isroot;
}
ssize_t
ctf_get_ctt_size(const ctf_file_t *fp, const ctf_type_t *tp, ssize_t *sizep,
ctf_get_ctt_size(const ctf_file_t *fp, const void *v, ssize_t *sizep,
ssize_t *incrementp)
{
ssize_t size, increment;
if (tp->ctt_size == CTF_LSIZE_SENT) {
size = CTF_TYPE_LSIZE(tp);
increment = sizeof (ctf_type_t);
if (fp->ctf_version == CTF_VERSION_2) {
const struct ctf_type_v2 *ctt = v;
if (ctt->ctt_size == CTF_V2_LSIZE_SENT) {
size = (size_t)CTF_TYPE_LSIZE(ctt);
increment = sizeof (struct ctf_type_v2);
} else {
size = ctt->ctt_size;
increment = sizeof (struct ctf_stype_v2);
}
} else {
size = tp->ctt_size;
increment = sizeof (ctf_stype_t);
const struct ctf_type_v3 *ctt = v;
if (ctt->ctt_size == CTF_V3_LSIZE_SENT) {
size = (size_t)CTF_TYPE_LSIZE(ctt);
increment = sizeof (struct ctf_type_v3);
} else {
size = ctt->ctt_size;
increment = sizeof (struct ctf_stype_v3);
}
}
if (sizep)
@@ -49,6 +121,61 @@ ctf_get_ctt_size(const ctf_file_t *fp, const ctf_type_t *tp, ssize_t *sizep,
return (size);
}
/*
* Fetch info for a struct or union member.
*/
void
ctf_get_ctm_info(const ctf_file_t *fp, const void *v, size_t size,
size_t *incrementp, uint_t *typep, ulong_t *offsetp, const char **namep)
{
size_t increment;
ulong_t offset;
uint_t name, type;
if (fp->ctf_version == CTF_VERSION_2) {
if (size < CTF_V2_LSTRUCT_THRESH) {
const struct ctf_member_v2 *ctm = v;
name = ctm->ctm_name;
type = ctm->ctm_type;
offset = ctm->ctm_offset;
increment = sizeof(*ctm);
} else {
const struct ctf_lmember_v2 *ctlm = v;
name = ctlm->ctlm_name;
type = ctlm->ctlm_type;
offset = (ulong_t)CTF_LMEM_OFFSET(ctlm);
increment = sizeof(*ctlm);
}
} else {
if (size < CTF_V3_LSTRUCT_THRESH) {
const struct ctf_member_v3 *ctm = v;
name = ctm->ctm_name;
type = ctm->ctm_type;
offset = ctm->ctm_offset;
increment = sizeof(*ctm);
} else {
const struct ctf_lmember_v3 *ctlm = v;
name = ctlm->ctlm_name;
type = ctlm->ctlm_type;
offset = (ulong_t)CTF_LMEM_OFFSET(ctlm);
increment = sizeof(*ctlm);
}
}
if (incrementp != NULL)
*incrementp = increment;
if (typep != NULL)
*typep = type;
if (offsetp != NULL)
*offsetp = offset;
if (namep != NULL)
*namep = ctf_strraw(fp, name);
}
/*
* Iterate over the members of a STRUCT or UNION. We pass the name, member
* type, and offset of each member to the specified callback function.
@@ -57,9 +184,9 @@ int
ctf_member_iter(ctf_file_t *fp, ctf_id_t type, ctf_member_f *func, void *arg)
{
ctf_file_t *ofp = fp;
const ctf_type_t *tp;
const void *tp;
ssize_t size, increment;
uint_t kind, n;
uint_t kind, n, vlen;
int rc;
if ((type = ctf_type_resolve(fp, type)) == CTF_ERR)
@@ -69,32 +196,22 @@ ctf_member_iter(ctf_file_t *fp, ctf_id_t type, ctf_member_f *func, void *arg)
return (CTF_ERR); /* errno is set for us */
(void) ctf_get_ctt_size(fp, tp, &size, &increment);
kind = LCTF_INFO_KIND(fp, tp->ctt_info);
ctf_get_ctt_info(fp, tp, &kind, &vlen, NULL);
if (kind != CTF_K_STRUCT && kind != CTF_K_UNION)
return (ctf_set_errno(ofp, ECTF_NOTSOU));
if (size < CTF_LSTRUCT_THRESH) {
const ctf_member_t *mp = (const ctf_member_t *)
((uintptr_t)tp + increment);
const char *mp = (const char *)((uintptr_t)tp + increment);
for (n = LCTF_INFO_VLEN(fp, tp->ctt_info); n != 0; n--, mp++) {
const char *name = ctf_strptr(fp, mp->ctm_name);
if ((rc = func(name, mp->ctm_type, mp->ctm_offset,
arg)) != 0)
return (rc);
}
for (n = vlen; n != 0; n--, mp += increment) {
const char *name;
ulong_t offset;
uint_t type;
} else {
const ctf_lmember_t *lmp = (const ctf_lmember_t *)
((uintptr_t)tp + increment);
for (n = LCTF_INFO_VLEN(fp, tp->ctt_info); n != 0; n--, lmp++) {
const char *name = ctf_strptr(fp, lmp->ctlm_name);
if ((rc = func(name, lmp->ctlm_type,
(ulong_t)CTF_LMEM_OFFSET(lmp), arg)) != 0)
return (rc);
}
ctf_get_ctm_info(fp, mp, size, &increment, &type, &offset,
&name);
if ((rc = func(name, type, offset, arg)) != 0)
return (rc);
}
return (0);
@@ -108,10 +225,10 @@ int
ctf_enum_iter(ctf_file_t *fp, ctf_id_t type, ctf_enum_f *func, void *arg)
{
ctf_file_t *ofp = fp;
const ctf_type_t *tp;
const void *tp;
const ctf_enum_t *ep;
ssize_t increment;
uint_t n;
uint_t kind, n, vlen;
int rc;
if ((type = ctf_type_resolve(fp, type)) == CTF_ERR)
@@ -120,14 +237,15 @@ ctf_enum_iter(ctf_file_t *fp, ctf_id_t type, ctf_enum_f *func, void *arg)
if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
return (CTF_ERR); /* errno is set for us */
if (LCTF_INFO_KIND(fp, tp->ctt_info) != CTF_K_ENUM)
ctf_get_ctt_info(fp, tp, &kind, &vlen, NULL);
if (kind != CTF_K_ENUM)
return (ctf_set_errno(ofp, ECTF_NOTENUM));
(void) ctf_get_ctt_size(fp, tp, NULL, &increment);
ep = (const ctf_enum_t *)((uintptr_t)tp + increment);
for (n = LCTF_INFO_VLEN(fp, tp->ctt_info); n != 0; n--, ep++) {
for (n = vlen; n != 0; n--, ep++) {
const char *name = ctf_strptr(fp, ep->cte_name);
if ((rc = func(name, ep->cte_value, arg)) != 0)
return (rc);
@@ -145,11 +263,13 @@ ctf_type_iter(ctf_file_t *fp, ctf_type_f *func, void *arg)
{
ctf_id_t id, max = fp->ctf_typemax;
int rc, child = (fp->ctf_flags & LCTF_CHILD);
int isroot;
for (id = 1; id <= max; id++) {
const ctf_type_t *tp = LCTF_INDEX_TO_TYPEPTR(fp, id);
if (CTF_INFO_ISROOT(tp->ctt_info) &&
(rc = func(CTF_INDEX_TO_TYPE(id, child), arg)) != 0)
const void *tp = LCTF_INDEX_TO_TYPEPTR(fp, id);
ctf_get_ctt_info(fp, tp, NULL, NULL, &isroot);
if (isroot &&
(rc = func(LCTF_INDEX_TO_TYPE(fp, id, child), arg)) != 0)
return (rc);
}
@@ -168,21 +288,23 @@ ctf_type_resolve(ctf_file_t *fp, ctf_id_t type)
{
ctf_id_t prev = type, otype = type;
ctf_file_t *ofp = fp;
const ctf_type_t *tp;
const void *tp;
uint_t kind, ctype;
while ((tp = ctf_lookup_by_id(&fp, type)) != NULL) {
switch (LCTF_INFO_KIND(fp, tp->ctt_info)) {
ctf_get_ctt_info(fp, tp, &kind, NULL, NULL);
switch (kind) {
case CTF_K_TYPEDEF:
case CTF_K_VOLATILE:
case CTF_K_CONST:
case CTF_K_RESTRICT:
if (tp->ctt_type == type || tp->ctt_type == otype ||
tp->ctt_type == prev) {
ctf_get_ctt_index(fp, tp, NULL, &ctype, NULL);
if (ctype == type || ctype == otype || ctype == prev) {
ctf_dprintf("type %ld cycle detected\n", otype);
return (ctf_set_errno(ofp, ECTF_CORRUPT));
}
prev = type;
type = tp->ctt_type;
type = ctype;
break;
default:
return (type);
@@ -237,9 +359,8 @@ ctf_type_qlname(ctf_file_t *fp, ctf_id_t type, char *buf, size_t len,
cdp != NULL; cdp = ctf_list_next(cdp)) {
ctf_file_t *rfp = fp;
const ctf_type_t *tp =
ctf_lookup_by_id(&rfp, cdp->cd_type);
const char *name = ctf_strptr(rfp, tp->ctt_name);
const void *tp = ctf_lookup_by_id(&rfp, cdp->cd_type);
const char *name = ctf_type_rname(rfp, tp);
if (k != CTF_K_POINTER && k != CTF_K_ARRAY)
ctf_decl_sprintf(&cd, " ");
@@ -335,6 +456,23 @@ ctf_type_qname(ctf_file_t *fp, ctf_id_t type, char *buf, size_t len,
return (rv >= 0 && rv < len ? buf : NULL);
}
const char *
ctf_type_rname(ctf_file_t *fp, const void *v)
{
uint_t name;
if (fp->ctf_version == CTF_VERSION_2) {
const struct ctf_type_v2 *ctt = v;
name = ctt->ctt_name;
} else {
const struct ctf_type_v3 *ctt = v;
name = ctt->ctt_name;
}
return (ctf_strptr(fp, name));
}
/*
* Resolve the type down to a base type node, and then return the size
@@ -343,9 +481,10 @@ ctf_type_qname(ctf_file_t *fp, ctf_id_t type, char *buf, size_t len,
ssize_t
ctf_type_size(ctf_file_t *fp, ctf_id_t type)
{
const ctf_type_t *tp;
const void *tp;
ssize_t size;
ctf_arinfo_t ar;
uint_t kind;
if ((type = ctf_type_resolve(fp, type)) == CTF_ERR)
return (-1); /* errno is set for us */
@@ -353,7 +492,9 @@ ctf_type_size(ctf_file_t *fp, ctf_id_t type)
if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
return (-1); /* errno is set for us */
switch (LCTF_INFO_KIND(fp, tp->ctt_info)) {
ctf_get_ctt_info(fp, tp, &kind, NULL, NULL);
switch (kind) {
case CTF_K_POINTER:
return (fp->ctf_dmodel->ctd_pointer);
@@ -392,8 +533,9 @@ ctf_type_size(ctf_file_t *fp, ctf_id_t type)
ssize_t
ctf_type_align(ctf_file_t *fp, ctf_id_t type)
{
const ctf_type_t *tp;
const void *tp;
ctf_arinfo_t r;
uint_t kind, vlen;
if ((type = ctf_type_resolve(fp, type)) == CTF_ERR)
return (-1); /* errno is set for us */
@@ -401,7 +543,9 @@ ctf_type_align(ctf_file_t *fp, ctf_id_t type)
if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
return (-1); /* errno is set for us */
switch (LCTF_INFO_KIND(fp, tp->ctt_info)) {
ctf_get_ctt_info(fp, tp, &kind, &vlen, NULL);
switch (kind) {
case CTF_K_POINTER:
case CTF_K_FUNCTION:
return (fp->ctf_dmodel->ctd_pointer);
@@ -413,7 +557,7 @@ ctf_type_align(ctf_file_t *fp, ctf_id_t type)
case CTF_K_STRUCT:
case CTF_K_UNION: {
uint_t n = LCTF_INFO_VLEN(fp, tp->ctt_info);
uint_t n = vlen;
ssize_t size, increment;
size_t align = 0;
const void *vmp;
@@ -421,21 +565,16 @@ ctf_type_align(ctf_file_t *fp, ctf_id_t type)
(void) ctf_get_ctt_size(fp, tp, &size, &increment);
vmp = (uchar_t *)tp + increment;
if (LCTF_INFO_KIND(fp, tp->ctt_info) == CTF_K_STRUCT)
if (kind == CTF_K_STRUCT)
n = MIN(n, 1); /* only use first member for structs */
if (size < CTF_LSTRUCT_THRESH) {
const ctf_member_t *mp = vmp;
for (; n != 0; n--, mp++) {
ssize_t am = ctf_type_align(fp, mp->ctm_type);
align = MAX(align, am);
}
} else {
const ctf_lmember_t *lmp = vmp;
for (; n != 0; n--, lmp++) {
ssize_t am = ctf_type_align(fp, lmp->ctlm_type);
align = MAX(align, am);
}
for (const char *mp = vmp; n != 0; n--, mp += increment) {
uint_t type;
ctf_get_ctm_info(fp, mp, size, &increment, &type,
NULL, NULL);
ssize_t am = ctf_type_align(fp, type);
align = MAX(align, am);
}
return (align);
@@ -455,12 +594,15 @@ ctf_type_align(ctf_file_t *fp, ctf_id_t type)
int
ctf_type_kind(ctf_file_t *fp, ctf_id_t type)
{
const ctf_type_t *tp;
const void *tp;
uint_t kind;
if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
return (CTF_ERR); /* errno is set for us */
return (LCTF_INFO_KIND(fp, tp->ctt_info));
ctf_get_ctt_info(fp, tp, &kind, NULL, NULL);
return (kind);
}
/*
@@ -471,18 +613,22 @@ ctf_id_t
ctf_type_reference(ctf_file_t *fp, ctf_id_t type)
{
ctf_file_t *ofp = fp;
const ctf_type_t *tp;
const void *tp;
uint_t ctype, kind;
if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
return (CTF_ERR); /* errno is set for us */
switch (LCTF_INFO_KIND(fp, tp->ctt_info)) {
ctf_get_ctt_info(fp, tp, &kind, NULL, NULL);
switch (kind) {
case CTF_K_POINTER:
case CTF_K_TYPEDEF:
case CTF_K_VOLATILE:
case CTF_K_CONST:
case CTF_K_RESTRICT:
return (tp->ctt_type);
ctf_get_ctt_index(fp, tp, NULL, &ctype, NULL);
return (ctype);
default:
return (ctf_set_errno(ofp, ECTF_NOTREF));
}
@@ -504,8 +650,8 @@ ctf_type_pointer(ctf_file_t *fp, ctf_id_t type)
if (ctf_lookup_by_id(&fp, type) == NULL)
return (CTF_ERR); /* errno is set for us */
if ((ntype = fp->ctf_ptrtab[CTF_TYPE_TO_INDEX(type)]) != 0)
return (CTF_INDEX_TO_TYPE(ntype, (fp->ctf_flags & LCTF_CHILD)));
if ((ntype = fp->ctf_ptrtab[LCTF_TYPE_TO_INDEX(fp, type)]) != 0)
return (LCTF_INDEX_TO_TYPE(fp, ntype, (fp->ctf_flags & LCTF_CHILD)));
if ((type = ctf_type_resolve(fp, type)) == CTF_ERR)
return (ctf_set_errno(ofp, ECTF_NOTYPE));
@@ -513,8 +659,8 @@ ctf_type_pointer(ctf_file_t *fp, ctf_id_t type)
if (ctf_lookup_by_id(&fp, type) == NULL)
return (ctf_set_errno(ofp, ECTF_NOTYPE));
if ((ntype = fp->ctf_ptrtab[CTF_TYPE_TO_INDEX(type)]) != 0)
return (CTF_INDEX_TO_TYPE(ntype, (fp->ctf_flags & LCTF_CHILD)));
if ((ntype = fp->ctf_ptrtab[LCTF_TYPE_TO_INDEX(fp, type)]) != 0)
return (LCTF_INDEX_TO_TYPE(fp, ntype, (fp->ctf_flags & LCTF_CHILD)));
return (ctf_set_errno(ofp, ECTF_NOTYPE));
}
@@ -526,16 +672,17 @@ int
ctf_type_encoding(ctf_file_t *fp, ctf_id_t type, ctf_encoding_t *ep)
{
ctf_file_t *ofp = fp;
const ctf_type_t *tp;
const void *tp;
ssize_t increment;
uint_t data;
uint_t data, kind;
if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
return (CTF_ERR); /* errno is set for us */
(void) ctf_get_ctt_size(fp, tp, NULL, &increment);
ctf_get_ctt_info(fp, tp, &kind, NULL, NULL);
switch (LCTF_INFO_KIND(fp, tp->ctt_info)) {
switch (kind) {
case CTF_K_INTEGER:
data = *(const uint_t *)((uintptr_t)tp + increment);
ep->cte_format = CTF_INT_ENCODING(data);
@@ -570,10 +717,10 @@ ctf_type_cmp(ctf_file_t *lfp, ctf_id_t ltype, ctf_file_t *rfp, ctf_id_t rtype)
if (lfp == rfp)
return (rval);
if (CTF_TYPE_ISPARENT(ltype) && lfp->ctf_parent != NULL)
if (LCTF_TYPE_ISPARENT(lfp, ltype) && lfp->ctf_parent != NULL)
lfp = lfp->ctf_parent;
if (CTF_TYPE_ISPARENT(rtype) && rfp->ctf_parent != NULL)
if (LCTF_TYPE_ISPARENT(rfp, rtype) && rfp->ctf_parent != NULL)
rfp = rfp->ctf_parent;
if (lfp < rfp)
@@ -595,7 +742,7 @@ int
ctf_type_compat(ctf_file_t *lfp, ctf_id_t ltype,
ctf_file_t *rfp, ctf_id_t rtype)
{
const ctf_type_t *ltp, *rtp;
const void *ltp, *rtp;
ctf_encoding_t le, re;
ctf_arinfo_t la, ra;
uint_t lkind, rkind;
@@ -612,8 +759,7 @@ ctf_type_compat(ctf_file_t *lfp, ctf_id_t ltype,
if (lkind != rkind ||
(ltp = ctf_lookup_by_id(&lfp, ltype)) == NULL ||
(rtp = ctf_lookup_by_id(&rfp, rtype)) == NULL ||
strcmp(ctf_strptr(lfp, ltp->ctt_name),
ctf_strptr(rfp, rtp->ctt_name)) != 0)
strcmp(ctf_type_rname(lfp, ltp), ctf_type_rname(rfp, rtp)) != 0)
return (0);
switch (lkind) {
@@ -647,9 +793,9 @@ _ctf_member_info(ctf_file_t *fp, ctf_id_t type, const char *name, ulong_t off,
ctf_membinfo_t *mip)
{
ctf_file_t *ofp = fp;
const ctf_type_t *tp;
const void *tp;
ssize_t size, increment;
uint_t kind, n;
uint_t kind, n, vlen;
if ((type = ctf_type_resolve(fp, type)) == CTF_ERR)
return (CTF_ERR); /* errno is set for us */
@@ -658,41 +804,27 @@ _ctf_member_info(ctf_file_t *fp, ctf_id_t type, const char *name, ulong_t off,
return (CTF_ERR); /* errno is set for us */
(void) ctf_get_ctt_size(fp, tp, &size, &increment);
kind = LCTF_INFO_KIND(fp, tp->ctt_info);
ctf_get_ctt_info(fp, tp, &kind, &vlen, NULL);
if (kind != CTF_K_STRUCT && kind != CTF_K_UNION)
return (ctf_set_errno(ofp, ECTF_NOTSOU));
if (size < CTF_LSTRUCT_THRESH) {
const ctf_member_t *mp = (const ctf_member_t *)
((uintptr_t)tp + increment);
const char *mp = (const char *)((uintptr_t)tp + increment);
for (n = LCTF_INFO_VLEN(fp, tp->ctt_info); n != 0; n--, mp++) {
if (mp->ctm_name == 0 &&
_ctf_member_info(fp, mp->ctm_type, name,
mp->ctm_offset + off, mip) == 0)
return (0);
if (strcmp(ctf_strptr(fp, mp->ctm_name), name) == 0) {
mip->ctm_type = mp->ctm_type;
mip->ctm_offset = mp->ctm_offset + off;
return (0);
}
}
} else {
const ctf_lmember_t *lmp = (const ctf_lmember_t *)
((uintptr_t)tp + increment);
for (n = vlen; n != 0; n--, mp += increment) {
const char *name1;
ulong_t offset;
uint_t type;
for (n = LCTF_INFO_VLEN(fp, tp->ctt_info); n != 0; n--, lmp++) {
if (lmp->ctlm_name == 0 &&
_ctf_member_info(fp, lmp->ctlm_name, name,
(ulong_t)CTF_LMEM_OFFSET(lmp) + off, mip) == 0)
return (0);
if (strcmp(ctf_strptr(fp, lmp->ctlm_name), name) == 0) {
mip->ctm_type = lmp->ctlm_type;
mip->ctm_offset =
(ulong_t)CTF_LMEM_OFFSET(lmp) + off;
return (0);
}
ctf_get_ctm_info(fp, mp, size, &increment, &type, &offset,
&name1);
if (name1[0] == '\0' &&
_ctf_member_info(fp, type, name, offset + off, mip) == 0)
return (0);
if (strcmp(name1, name) == 0) {
mip->ctm_type = type;
mip->ctm_offset = offset + off;
return (0);
}
}
@@ -717,22 +849,34 @@ int
ctf_array_info(ctf_file_t *fp, ctf_id_t type, ctf_arinfo_t *arp)
{
ctf_file_t *ofp = fp;
const ctf_type_t *tp;
const ctf_array_t *ap;
const void *ap, *tp;
ssize_t increment;
uint_t kind;
if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
return (CTF_ERR); /* errno is set for us */
if (LCTF_INFO_KIND(fp, tp->ctt_info) != CTF_K_ARRAY)
ctf_get_ctt_info(fp, tp, &kind, NULL, NULL);
if (kind != CTF_K_ARRAY)
return (ctf_set_errno(ofp, ECTF_NOTARRAY));
(void) ctf_get_ctt_size(fp, tp, NULL, &increment);
ap = (const ctf_array_t *)((uintptr_t)tp + increment);
arp->ctr_contents = ap->cta_contents;
arp->ctr_index = ap->cta_index;
arp->ctr_nelems = ap->cta_nelems;
ap = (const void *)((uintptr_t)tp + increment);
if (fp->ctf_version == CTF_VERSION_2) {
const struct ctf_array_v2 *ap2 = ap;
arp->ctr_contents = ap2->cta_contents;
arp->ctr_index = ap2->cta_index;
arp->ctr_nelems = ap2->cta_nelems;
} else {
const struct ctf_array_v3 *ap3 = ap;
arp->ctr_contents = ap3->cta_contents;
arp->ctr_index = ap3->cta_index;
arp->ctr_nelems = ap3->cta_nelems;
}
return (0);
}
@@ -745,10 +889,10 @@ const char *
ctf_enum_name(ctf_file_t *fp, ctf_id_t type, int value)
{
ctf_file_t *ofp = fp;
const ctf_type_t *tp;
const void *tp;
const ctf_enum_t *ep;
ssize_t increment;
uint_t n;
uint_t kind, n, vlen;
if ((type = ctf_type_resolve(fp, type)) == CTF_ERR)
return (NULL); /* errno is set for us */
@@ -756,7 +900,9 @@ ctf_enum_name(ctf_file_t *fp, ctf_id_t type, int value)
if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
return (NULL); /* errno is set for us */
if (LCTF_INFO_KIND(fp, tp->ctt_info) != CTF_K_ENUM) {
ctf_get_ctt_info(fp, tp, &kind, &vlen, NULL);
if (kind != CTF_K_ENUM) {
(void) ctf_set_errno(ofp, ECTF_NOTENUM);
return (NULL);
}
@@ -765,7 +911,7 @@ ctf_enum_name(ctf_file_t *fp, ctf_id_t type, int value)
ep = (const ctf_enum_t *)((uintptr_t)tp + increment);
for (n = LCTF_INFO_VLEN(fp, tp->ctt_info); n != 0; n--, ep++) {
for (n = vlen; n != 0; n--, ep++) {
if (ep->cte_value == value)
return (ctf_strptr(fp, ep->cte_name));
}
@@ -782,10 +928,10 @@ int
ctf_enum_value(ctf_file_t *fp, ctf_id_t type, const char *name, int *valp)
{
ctf_file_t *ofp = fp;
const ctf_type_t *tp;
const void *tp;
const ctf_enum_t *ep;
ssize_t size, increment;
uint_t n;
uint_t kind, n, vlen;
if ((type = ctf_type_resolve(fp, type)) == CTF_ERR)
return (CTF_ERR); /* errno is set for us */
@@ -793,7 +939,9 @@ ctf_enum_value(ctf_file_t *fp, ctf_id_t type, const char *name, int *valp)
if ((tp = ctf_lookup_by_id(&fp, type)) == NULL)
return (CTF_ERR); /* errno is set for us */
if (LCTF_INFO_KIND(fp, tp->ctt_info) != CTF_K_ENUM) {
ctf_get_ctt_info(fp, tp, &kind, &vlen, NULL);
if (kind != CTF_K_ENUM) {
(void) ctf_set_errno(ofp, ECTF_NOTENUM);
return (CTF_ERR);
}
@@ -802,7 +950,7 @@ ctf_enum_value(ctf_file_t *fp, ctf_id_t type, const char *name, int *valp)
ep = (const ctf_enum_t *)((uintptr_t)tp + increment);
for (n = LCTF_INFO_VLEN(fp, tp->ctt_info); n != 0; n--, ep++) {
for (n = vlen; n != 0; n--, ep++) {
if (strcmp(ctf_strptr(fp, ep->cte_name), name) == 0) {
if (valp != NULL)
*valp = ep->cte_value;
@@ -826,9 +974,9 @@ ctf_type_rvisit(ctf_file_t *fp, ctf_id_t type, ctf_visit_f *func, void *arg,
const char *name, ulong_t offset, int depth)
{
ctf_id_t otype = type;
const ctf_type_t *tp;
const void *tp;
ssize_t size, increment;
uint_t kind, n;
uint_t kind, n, vlen;
int rc;
if ((type = ctf_type_resolve(fp, type)) == CTF_ERR)
@@ -840,35 +988,24 @@ ctf_type_rvisit(ctf_file_t *fp, ctf_id_t type, ctf_visit_f *func, void *arg,
if ((rc = func(name, otype, offset, depth, arg)) != 0)
return (rc);
kind = LCTF_INFO_KIND(fp, tp->ctt_info);
ctf_get_ctt_info(fp, tp, &kind, &vlen, NULL);
if (kind != CTF_K_STRUCT && kind != CTF_K_UNION)
return (0);
(void) ctf_get_ctt_size(fp, tp, &size, &increment);
if (size < CTF_LSTRUCT_THRESH) {
const ctf_member_t *mp = (const ctf_member_t *)
((uintptr_t)tp + increment);
const char *mp = (const char *)((uintptr_t)tp + increment);
for (n = vlen; n != 0; n--, mp += increment) {
const char *name;
ulong_t offset1;
uint_t type;
for (n = LCTF_INFO_VLEN(fp, tp->ctt_info); n != 0; n--, mp++) {
if ((rc = ctf_type_rvisit(fp, mp->ctm_type,
func, arg, ctf_strptr(fp, mp->ctm_name),
offset + mp->ctm_offset, depth + 1)) != 0)
return (rc);
}
} else {
const ctf_lmember_t *lmp = (const ctf_lmember_t *)
((uintptr_t)tp + increment);
for (n = LCTF_INFO_VLEN(fp, tp->ctt_info); n != 0; n--, lmp++) {
if ((rc = ctf_type_rvisit(fp, lmp->ctlm_type,
func, arg, ctf_strptr(fp, lmp->ctlm_name),
offset + (ulong_t)CTF_LMEM_OFFSET(lmp),
depth + 1)) != 0)
return (rc);
}
ctf_get_ctm_info(fp, mp, size, &increment, &type, &offset1,
&name);
if ((rc = ctf_type_rvisit(fp, type, func, arg, name,
offset + offset1, depth + 1)) != 0)
return (rc);
}
return (0);
+114 -94
View File
@@ -11,7 +11,7 @@
.\"
.\" Copyright (c) 2014 Joyent, Inc.
.\"
.Dd Sep 26, 2014
.Dd February 28, 2022
.Dt CTF 5
.Os
.Sh NAME
@@ -65,11 +65,11 @@ data can be obtained through libctf.
The
.Nm
file format is broken down into seven different sections.
The first section is the
The first two sections are the
.Sy preamble
and
.Sy header ,
which describes the version of the
which describe the version of the
.Nm
file, the links it has to other
.Nm
@@ -129,15 +129,22 @@ and the type information that comes from the
module.
This means that a module only has types that are unique to itself and the most
common types in the kernel are not duplicated.
Uniquification is not used when building kernel modules on
.Fx .
.Sh FILE FORMAT
This documents version
.Em two
.Em three
of the
.Nm
file format.
All applications and tools on
.Fx
currently produce and operate on this version.
The
.Xr ctfconvert 1
and
.Xr ctfmerge 1
utilities emit
.Nm
version 3, and all other applications and libraries can operate on
versions 2 and 3.
.Lp
The file format can be summarized with the following image, the
following sections will cover this in more detail.
@@ -164,7 +171,7 @@ following sections will cover this in more detail.
||||||| +-- magic - vers flags
||||||| | | | |
||||||| +------+------+------+------+
+---------| 0xcf | 0xf1 | 0x02 | 0x00 |
+---------| 0xcf | 0xf1 | 0x03 | 0x00 |
|||||| +------+------+------+------+
|||||| 0 1 2 3 4
||||||
@@ -191,7 +198,7 @@ following sections will cover this in more detail.
|||| +------+------+------+-----+
+----------| 0x00 | 0x42 | 0x36 | ... |
||| +------+------+------+-----+
||| cth_objtoff +0x2 +0x4 +0x6 cth_funcoff
||| cth_objtoff +0x4 +0x8 +0xc cth_funcoff
|||
||| + CTF_TYPE_INFO + CTF_TYPE_INFO
||| | + Return type |
@@ -199,7 +206,7 @@ following sections will cover this in more detail.
||| +--------+------+------+-----+
+---------| 0x2c10 | 0x08 | 0x0c | ... |
|| +--------+------+------+-----+
|| cth_funcff +0x2 +0x4 +0x6 cth_typeoff
|| cth_funcff +0x4 +0x8 +0xc cth_typeoff
||
|| + ctf_stype_t for type 1
|| | integer + integer encoding
@@ -208,7 +215,7 @@ following sections will cover this in more detail.
|| +--------------------+-----------+-----+
+--------| 0x19 * 0xc01 * 0x0 | 0x1000000 | ... |
| +--------------------+-----------+-----+
| cth_typeoff +0x08 +0x0c cth_stroff
| cth_typeoff +0x0c +0x10 cth_stroff
|
| +--- str 0
| | +--- str 1 + str 2
@@ -265,7 +272,7 @@ member defines the version of the
.Nm
file.
The current version is
.Li 2 .
.Li 3 .
It is possible to encounter an unsupported version.
In that case, software should not try to parse the format, as it may have
changed.
@@ -296,7 +303,7 @@ always refer to the
.Sy uncompressed
data.
.Lp
In version two of the
In versions two and three of the
.Nm
file format, the
.Sy header
@@ -327,7 +334,7 @@ typedef struct ctf_header {
After the
.Sy preamble ,
the next two members
.Em cth_parlablel
.Em cth_parlabel
and
.Em cth_parname ,
are used to identify the parent.
@@ -364,7 +371,7 @@ file.
The difference between members indicates the size of the section itself.
Different offsets have different alignment requirements.
The start of the
.Em cth_objotoff
.Em cth_objtoff
and
.Em cth_funcoff
must be two byte aligned, while the sections
@@ -381,9 +388,9 @@ section, one should subtract the offset of the section from the following one.
For example, the size of the
.Sy types
section can be calculated by subtracting
.Em cth_stroff
.Em cth_typeoff
from
.Em cth_typeoff .
.Em cth_stroff .
.Lp
Finally, the member
.Em cth_strlen
@@ -402,16 +409,20 @@ Through the
data, types are referred to by identifiers.
A given
.Nm
file supports up to 32767 (0x7fff) types.
file supports up to 2147483646 (0x7ffffffe) types.
.Nm
version 2 had a much smaller limit of 32767 types.
The first valid type identifier is 0x1.
When a given
.Nm
file is a child, indicated by a non-zero entry for the
.Sy header Ns 's
.Em cth_parname ,
then the first valid type identifier is 0x8000 and the last is 0xffff.
In this case, type identifiers 0x1 through 0x7fff are references to the
then the first valid type identifier is 0x80000000 and the last is 0xfffffffe.
In this case, type identifiers 0x1 through 0x7ffffffe are references to the
parent.
0x7fffffff and 0xffffffff are not treated as valid type identifiers so as to
enable the use of -1 as an error value.
.Lp
The type identifier zero is a sentinel value used to indicate that there
is no type information available or it is an unknown type.
@@ -444,7 +455,7 @@ container.
Every
.Nm
type begins with metadata encoded into a
.Sy uint16_t .
.Sy uint32_t .
This encoded information tells us three different pieces of information:
.Bl -bullet -offset indent -compact
.It
@@ -455,16 +466,9 @@ Whether this type is a root type or not
The length of the variable data
.El
.Lp
The 16 bits that make up the encoding are broken down such that you have
five bits for the kind, one bit for indicating whether or not it is a
root type, and 10 bits for the variable length.
This is laid out as follows:
.Bd -literal -offset indent
+--------------------+
| kind | root | vlen |
+--------------------+
15 11 10 9 0
.Ed
The 32 bits that make up the encoding are broken down into six bits
for the kind (bits 26 to 31), one bit for the root type flag (bit 25),
and 25 bits for the length of the variable data.
.Lp
The current version of the file format defines 14 different kinds.
The interpretation of these different kinds will be discussed in the section
@@ -502,7 +506,7 @@ That type is not considered a
type.
If a type is a
.Sy root
type, then it will have bit 10 set.
type, then it will have bit 25 set.
.Lp
The variable length section is specific to each kind and is discussed in the
section
@@ -512,13 +516,13 @@ The following macros are useful for constructing and deconstructing the encoded
type information:
.Bd -literal -offset indent
#define CTF_MAX_VLEN 0x3ff
#define CTF_INFO_KIND(info) (((info) & 0xf800) >> 11)
#define CTF_INFO_ISROOT(info) (((info) & 0x0400) >> 10)
#define CTF_INFO_VLEN(info) (((info) & CTF_MAX_VLEN))
#define CTF_V3_MAX_VLEN 0x00ffffff
#define CTF_V3_INFO_KIND(info) (((info) & 0xfc000000) >> 26)
#define CTF_V3_INFO_ISROOT(info) (((info) & 0x02000000) >> 25)
#define CTF_V3_INFO_VLEN(info) (((info) & CTF_V3_MAX_VLEN))
#define CTF_TYPE_INFO(kind, isroot, vlen) \\
(((kind) << 11) | (((isroot) ? 1 : 0) << 10) | ((vlen) & CTF_MAX_VLEN))
#define CTF_V3_TYPE_INFO(kind, isroot, vlen) \\
(((kind) << 26) | (((isroot) ? 1 : 0) << 25) | ((vlen) & CTF_V3_MAX_VLEN))
.Ed
.Ss The Label Section
When consuming
@@ -536,6 +540,11 @@ releases, that they are not used together by tools, particularly when a child
needs to refer to a type in the parent.
Because they are linked using the type identifiers, if the wrong parent is used
then the wrong type will be encountered.
Note that this mechanism is not currently used on
.Fx .
In particular, kernel modules built on
.Fx
each contain a complete type graph.
.Lp
Each label is encoded in the file format using the following eight byte
structure:
@@ -573,7 +582,7 @@ The object section provides a mapping from ELF symbols of type
.Sy STT_OBJECT
in the symbol table to a type identifier.
Every entry in this section is a
.Sy uint16_t
.Sy uint32_t
which contains a type identifier as described in the section
.Sx Type Identifiers .
If there is no information for an object, then the type identifier 0x0
@@ -617,14 +626,17 @@ section and skipping the correct symbols:
#include <stdio.h>
/*
* Given the start of the object section in the CTF file, the number of symbols,
* Given the start of the object section in a CTFv3 file, the number of symbols,
* and the ELF Data sections for the symbol table and the string table, this
* prints the type identifiers that correspond to objects. Note, a more robust
* implementation should ensure that they don't walk beyond the end of the CTF
* object section.
*
* An implementation that handles CTFv2 must take into account the fact that
* type identifiers are 16 bits wide rather than 32 bits wide.
*/
static int
walk_symbols(uint16_t *objtoff, Elf_Data *symdata, Elf_Data *strdata,
walk_symbols(uint32_t *objtoff, Elf_Data *symdata, Elf_Data *strdata,
long nsyms)
{
long i;
@@ -667,9 +679,9 @@ Unlike with objects, because functions have a variable number of arguments, they
start with a type encoding as defined in
.Sx Type Encoding ,
which is the size of a
.Sy uint16_t .
.Sy uint32_t .
For functions which have no type information available, they are encoded as
.Li CTF_TYPE_INFO(CTF_K_UNKNOWN, 0, 0) .
.Li CTF_V3_TYPE_INFO(CTF_K_UNKNOWN, 0, 0) .
Functions with arguments are encoded differently.
Here, the variable length is turned into the number of arguments in the
function.
@@ -677,12 +689,12 @@ If a function is a
.Sy varargs
type function, then the number of arguments is increased by one.
Functions with type information are encoded as:
.Li CTF_TYPE_INFO(CTF_K_FUNCTION, 0, nargs) .
.Li CTF_V3_TYPE_INFO(CTF_K_FUNCTION, 0, nargs) .
.Lp
For functions that have no type information, nothing else is encoded, and the
next function is encoded.
For functions with type information, the next
.Sy uint16_t
.Sy uint32_t
is encoded with the type identifier of the return type of the function.
It is followed by each of the type identifiers of the arguments, if any exist,
in the order that they appear in the function.
@@ -723,29 +735,29 @@ The base of the type information comes in two forms, a short form and a long
form, each of which may be followed by a variable number of arguments.
The following definitions describe the short and long forms:
.Bd -literal
#define CTF_MAX_SIZE 0xfffe /* max size of a type in bytes */
#define CTF_LSIZE_SENT 0xffff /* sentinel for ctt_size */
#define CTF_MAX_LSIZE UINT64_MAX
#define CTF_V3_MAX_SIZE 0xfffffffe /* max size of a type in bytes */
#define CTF_V3_LSIZE_SENT 0xffffffff /* sentinel for ctt_size */
#define CTF_V3_MAX_LSIZE UINT64_MAX
typedef struct ctf_stype {
struct ctf_stype_v3 {
uint32_t ctt_name; /* reference to name in string table */
uint16_t ctt_info; /* encoded kind, variant length */
uint32_t ctt_info; /* encoded kind, variant length */
union {
uint16_t _size; /* size of entire type in bytes */
uint16_t _type; /* reference to another type */
uint32_t _size; /* size of entire type in bytes */
uint32_t _type; /* reference to another type */
} _u;
} ctf_stype_t;
};
typedef struct ctf_type {
struct ctf_type_v3 {
uint32_t ctt_name; /* reference to name in string table */
uint16_t ctt_info; /* encoded kind, variant length */
uint32_t ctt_info; /* encoded kind, variant length */
union {
uint16_t _size; /* always CTF_LSIZE_SENT */
uint16_t _type; /* do not use */
uint32_t _size; /* always CTF_LSIZE_SENT */
uint32_t _type; /* do not use */
} _u;
uint32_t ctt_lsizehi; /* high 32 bits of type size in bytes */
uint32_t ctt_lsizelo; /* low 32 bits of type size in bytes */
} ctf_type_t;
};
#define ctt_size _u._size /* for fundamental types that have a size */
#define ctt_type _u._type /* for types that reference another type */
@@ -754,29 +766,29 @@ typedef struct ctf_type {
Type sizes are stored in
.Sy bytes .
The basic small form uses a
.Sy uint16_t
.Sy uint32_t
to store the number of bytes.
If the number of bytes in a structure would exceed 0xfffe, then the alternate
form, the
.Sy ctf_type_t ,
If the number of bytes in a structure would exceed 0xfffffffe, then the
alternate form, the
.Sy struct ctf_type_v3 ,
is used instead.
To indicate that the larger form is being used, the member
.Em ctt_size
is set to value of
.Sy CTF_LSIZE_SENT
(0xffff).
.Sy CTF_V3_LSIZE_SENT
(0xffffffff).
In general, when going through the type section, consumers use the
.Sy ctf_type_t
.Sy struct ctf_type_v3
structure, but pay attention to the value of the member
.Em ctt_size
to determine whether they should increment their scan by the size of the
.Sy ctf_stype_t
to determine whether they should increment their scan by the size of
.Sy struct ctf_stype_v3
or
.Sy ctf_type_t .
.Sy struct ctf_type_v3 .
Not all kinds of types use
.Sy ctt_size .
Those which do not, will always use the
.Sy ctf_stype_t
.Sy struct ctf_stype_v3
structure.
The individual sections for each kind have more information.
.Lp
@@ -798,7 +810,7 @@ The next member, the
is encoded as described in the section
.Sx Type Encoding .
The type's kind tells us how to interpret the remaining data in the
.Sy ctf_type_t
.Sy struct ctf_type_v3
and any variable length data that may exist.
The rest of this section will be broken down into the interpretation of the
various kinds.
@@ -936,11 +948,11 @@ With arrays, the
member is set to zero.
The structure that follows an array is defined as:
.Bd -literal
typedef struct ctf_array {
uint16_t cta_contents; /* reference to type of array contents */
uint16_t cta_index; /* reference to type of array index */
struct ctf_array_v3 {
uint32_t cta_contents; /* reference to type of array contents */
uint32_t cta_index; /* reference to type of array index */
uint32_t cta_nelems; /* number of elements */
} ctf_array_t;
};
.Ed
.Lp
The
@@ -948,7 +960,7 @@ The
and
.Em cta_index
members of the
.Sy ctf_array_t
.Sy struct ctf_array_v3
are type identifiers which are encoded as per the section
.Sx Type Identifiers .
The member
@@ -971,17 +983,23 @@ member is not used here.
The variable argument list contains the type identifiers for the arguments of
the function, if any.
Each one is represented by a
.Sy uint16_t
.Sy uint32_t
and encoded according to the
.Sx Type Identifiers
section.
If the function's last argument is of type varargs, then it is also written out,
but the type identifier is zero.
This is included in the count of the function's arguments.
An extra type identifier may follow the argument and return type identifiers
in order to maintain four-byte alignment for the following type definition.
In
.Nm
version 2, an extra type identifier may follow the argument and return type
identifiers in order to maintain four-byte alignment for the following type
definition.
Such a type identifier is not included in the argument count and has a value
of zero.
In
.Nm
version 3, four-byte alignment occurs naturally and no padding is used.
.Ss Encoding of Structures and Unions
Structures and Unions, which are encoded with
.Sy CTF_K_STRUCT
@@ -1000,23 +1018,22 @@ is the size of the structure and union.
There are two different structures which are used to encode members in the
variable list.
When the size of a structure or union is greater than or equal to the large
member threshold, 8192, then a different structure is used to encode the member,
all members are encoded using the same structure.
member threshold, 536870912, then a different structure is used to encode the
member; all members are encoded using the same structure.
The structure for members is as follows:
.Bd -literal
typedef struct ctf_member {
struct ctf_member_v3 {
uint32_t ctm_name; /* reference to name in string table */
uint16_t ctm_type; /* reference to type of member */
uint16_t ctm_offset; /* offset of this member in bits */
} ctf_member_t;
uint32_t ctm_type; /* reference to type of member */
uint32_t ctm_offset; /* offset of this member in bits */
};
typedef struct ctf_lmember {
struct ctf_lmember_v3 {
uint32_t ctlm_name; /* reference to name in string table */
uint16_t ctlm_type; /* reference to type of member */
uint16_t ctlm_pad; /* padding */
uint32_t ctlm_type; /* reference to type of member */
uint32_t ctlm_offsethi; /* high 32 bits of member offset in bits */
uint32_t ctlm_offsetlo; /* low 32 bits of member offset in bits */
} ctf_lmember_t;
};
.Ed
.Lp
Both the
@@ -1045,13 +1062,13 @@ at which the member begins.
Note that a compiler may lay out a type with padding.
This means that the difference in offset between two consecutive members may be
larger than the size of the member.
When the size of the overall structure is strictly less than 8192 bytes, the
normal structure,
.Sy ctf_member_t ,
When the size of the overall structure is strictly less than 536870912 bytes,
the normal structure,
.Sy struct ctf_member_v3 ,
is used and the offset in bits is stored in the member
.Em ctm_offset .
However, when the size of the structure is greater than or equal to 8192 bytes,
then the number of bits is split into two 32-bit quantities.
However, when the size of the structure is greater than or equal to 536870912
bytes, then the number of bits is split into two 32-bit quantities.
One member,
.Em ctlm_offsethi ,
represents the upper 32 bits of the offset, while the other member,
@@ -1114,7 +1131,7 @@ actual type in the parent, otherwise the definition may be in another
.Nm
container or may not be known at all.
The only member of the
.Sy ctf_type_t
.Sy struct ctf_type_v3
that matters for a forward declaration is the
.Em ctt_name
which points to the name of the forward reference in the string table as
@@ -1216,6 +1233,9 @@ The type of the section must be
The section should have a link set to the symbol table and its address
alignment must be 4.
.Sh SEE ALSO
.Xr ctfconvert 1 ,
.Xr ctfdump 1 ,
.Xr ctfmerge 1 ,
.Xr dtrace 1 ,
.Xr elf 3 ,
.Xr gelf 3 ,
@@ -245,7 +245,8 @@ ctf_fdopen(int fd, int *errp)
*/
if (nbytes >= (ssize_t) sizeof (ctf_preamble_t) &&
hdr.ctf.ctp_magic == CTF_MAGIC) {
if (hdr.ctf.ctp_version > CTF_VERSION)
if (hdr.ctf.ctp_version != CTF_VERSION_2 &&
hdr.ctf.ctp_version != CTF_VERSION_3)
return (ctf_set_open_errno(errp, ECTF_CTFVERS));
ctfsect.cts_data = mmap64(NULL, st.st_size, PROT_READ,
@@ -65,7 +65,7 @@
* an explicit path #include.
*/
#include <uts/common/sys/ctf.h>
#include <sys/ctf.h>
#include <uts/common/sys/ctf_api.h>
#include <lib/libctf/common/libctf.h>
+279 -170
View File
@@ -58,8 +58,7 @@ struct ctf_buf {
caddr_t ctb_end; /* pointer to end of buffer */
caddr_t ctb_ptr; /* pointer to empty buffer space */
size_t ctb_size; /* size of buffer */
int nptent; /* number of processed types */
int ntholes; /* number of type holes */
uint_t nptent; /* number of processed types */
};
/*
@@ -165,10 +164,10 @@ write_label(void *arg1, void *arg2)
static void
write_objects(iidesc_t *idp, ctf_buf_t *b)
{
ushort_t id = (idp ? idp->ii_dtype->t_id : 0);
uint_t id = (idp ? idp->ii_dtype->t_id : 0);
if (target_requires_swap) {
SWAP_16(id);
SWAP_32(id);
}
ctf_buf_write(b, &id, sizeof (id));
@@ -179,8 +178,8 @@ write_objects(iidesc_t *idp, ctf_buf_t *b)
static void
write_functions(iidesc_t *idp, ctf_buf_t *b)
{
ushort_t fdata[2];
ushort_t id;
uint_t fdata[2];
uint_t id;
int nargs;
int i;
@@ -194,17 +193,17 @@ write_functions(iidesc_t *idp, ctf_buf_t *b)
nargs = idp->ii_nargs + (idp->ii_vargs != 0);
if (nargs > CTF_MAX_VLEN) {
if (nargs > CTF_V3_MAX_VLEN) {
terminate("function %s has too many args: %d > %d\n",
idp->ii_name, nargs, CTF_MAX_VLEN);
idp->ii_name, nargs, CTF_V3_MAX_VLEN);
}
fdata[0] = CTF_TYPE_INFO(CTF_K_FUNCTION, 1, nargs);
fdata[0] = CTF_V3_TYPE_INFO(CTF_K_FUNCTION, 1, nargs);
fdata[1] = idp->ii_dtype->t_id;
if (target_requires_swap) {
SWAP_16(fdata[0]);
SWAP_16(fdata[1]);
SWAP_32(fdata[0]);
SWAP_32(fdata[1]);
}
ctf_buf_write(b, fdata, sizeof (fdata));
@@ -213,7 +212,7 @@ write_functions(iidesc_t *idp, ctf_buf_t *b)
id = idp->ii_args[i]->t_id;
if (target_requires_swap) {
SWAP_16(id);
SWAP_32(id);
}
ctf_buf_write(b, &id, sizeof (id));
@@ -234,29 +233,29 @@ write_functions(iidesc_t *idp, ctf_buf_t *b)
* doesn't need to care.
*/
static void
write_sized_type_rec(ctf_buf_t *b, ctf_type_t *ctt, size_t size)
write_sized_type_rec(ctf_buf_t *b, struct ctf_type_v3 *ctt, size_t size)
{
if (size > CTF_MAX_SIZE) {
ctt->ctt_size = CTF_LSIZE_SENT;
if (size > CTF_V3_MAX_SIZE) {
ctt->ctt_size = CTF_V3_LSIZE_SENT;
ctt->ctt_lsizehi = CTF_SIZE_TO_LSIZE_HI(size);
ctt->ctt_lsizelo = CTF_SIZE_TO_LSIZE_LO(size);
if (target_requires_swap) {
SWAP_32(ctt->ctt_name);
SWAP_16(ctt->ctt_info);
SWAP_16(ctt->ctt_size);
SWAP_32(ctt->ctt_info);
SWAP_32(ctt->ctt_size);
SWAP_32(ctt->ctt_lsizehi);
SWAP_32(ctt->ctt_lsizelo);
}
ctf_buf_write(b, ctt, sizeof (*ctt));
} else {
ctf_stype_t *cts = (ctf_stype_t *)ctt;
struct ctf_stype_v3 *cts = (struct ctf_stype_v3 *)ctt;
cts->ctt_size = (ushort_t)size;
cts->ctt_size = size;
if (target_requires_swap) {
SWAP_32(cts->ctt_name);
SWAP_16(cts->ctt_info);
SWAP_16(cts->ctt_size);
SWAP_32(cts->ctt_info);
SWAP_32(cts->ctt_size);
}
ctf_buf_write(b, cts, sizeof (*cts));
@@ -264,14 +263,14 @@ write_sized_type_rec(ctf_buf_t *b, ctf_type_t *ctt, size_t size)
}
static void
write_unsized_type_rec(ctf_buf_t *b, ctf_type_t *ctt)
write_unsized_type_rec(ctf_buf_t *b, struct ctf_type_v3 *ctt)
{
ctf_stype_t *cts = (ctf_stype_t *)ctt;
struct ctf_stype_v3 *cts = (struct ctf_stype_v3 *)ctt;
if (target_requires_swap) {
SWAP_32(cts->ctt_name);
SWAP_16(cts->ctt_info);
SWAP_16(cts->ctt_size);
SWAP_32(cts->ctt_info);
SWAP_32(cts->ctt_size);
}
ctf_buf_write(b, cts, sizeof (*cts));
@@ -292,14 +291,12 @@ write_type(void *arg1, void *arg2)
int isroot = tp->t_flags & TDESC_F_ISROOT;
int i;
ctf_type_t ctt;
ctf_array_t cta;
ctf_member_t ctm;
ctf_lmember_t ctlm;
ctf_enum_t cte;
ushort_t id;
ctlm.ctlm_pad = 0;
struct ctf_type_v3 ctt;
struct ctf_array_v3 cta;
struct ctf_member_v3 ctm;
struct ctf_lmember_v3 ctlm;
struct ctf_enum cte;
uint_t id;
/*
* There shouldn't be any holes in the type list (where a hole is
@@ -308,13 +305,13 @@ write_type(void *arg1, void *arg2)
* fake entries to fill the holes, or we won't be able to reconstruct
* the tree from the written data.
*/
if (++b->nptent < CTF_TYPE_TO_INDEX(tp->t_id)) {
if (++b->nptent < CTF_V3_TYPE_TO_INDEX(tp->t_id)) {
debug(2, "genctf: type hole from %d < x < %d\n",
b->nptent - 1, CTF_TYPE_TO_INDEX(tp->t_id));
b->nptent - 1, CTF_V3_TYPE_TO_INDEX(tp->t_id));
ctt.ctt_name = CTF_TYPE_NAME(CTF_STRTAB_0, 0);
ctt.ctt_info = CTF_TYPE_INFO(0, 0, 0);
while (b->nptent < CTF_TYPE_TO_INDEX(tp->t_id)) {
ctt.ctt_info = CTF_V3_TYPE_INFO(0, 0, 0);
while (b->nptent < CTF_V3_TYPE_TO_INDEX(tp->t_id)) {
write_sized_type_rec(b, &ctt, 0);
b->nptent++;
}
@@ -327,10 +324,10 @@ write_type(void *arg1, void *arg2)
case INTRINSIC:
ip = tp->t_intr;
if (ip->intr_type == INTR_INT)
ctt.ctt_info = CTF_TYPE_INFO(CTF_K_INTEGER,
ctt.ctt_info = CTF_V3_TYPE_INFO(CTF_K_INTEGER,
isroot, 1);
else
ctt.ctt_info = CTF_TYPE_INFO(CTF_K_FLOAT, isroot, 1);
ctt.ctt_info = CTF_V3_TYPE_INFO(CTF_K_FLOAT, isroot, 1);
write_sized_type_rec(b, &ctt, tp->t_size);
encoding = 0;
@@ -355,21 +352,21 @@ write_type(void *arg1, void *arg2)
break;
case POINTER:
ctt.ctt_info = CTF_TYPE_INFO(CTF_K_POINTER, isroot, 0);
ctt.ctt_info = CTF_V3_TYPE_INFO(CTF_K_POINTER, isroot, 0);
ctt.ctt_type = tp->t_tdesc->t_id;
write_unsized_type_rec(b, &ctt);
break;
case ARRAY:
ctt.ctt_info = CTF_TYPE_INFO(CTF_K_ARRAY, isroot, 1);
ctt.ctt_info = CTF_V3_TYPE_INFO(CTF_K_ARRAY, isroot, 1);
write_sized_type_rec(b, &ctt, tp->t_size);
cta.cta_contents = tp->t_ardef->ad_contents->t_id;
cta.cta_index = tp->t_ardef->ad_idxtype->t_id;
cta.cta_nelems = tp->t_ardef->ad_nelems;
if (target_requires_swap) {
SWAP_16(cta.cta_contents);
SWAP_16(cta.cta_index);
SWAP_32(cta.cta_contents);
SWAP_32(cta.cta_index);
SWAP_32(cta.cta_nelems);
}
ctf_buf_write(b, &cta, sizeof (cta));
@@ -380,19 +377,19 @@ write_type(void *arg1, void *arg2)
for (i = 0, mp = tp->t_members; mp != NULL; mp = mp->ml_next)
i++; /* count up struct or union members */
if (i > CTF_MAX_VLEN) {
if (i > CTF_V3_MAX_VLEN) {
terminate("sou %s has too many members: %d > %d\n",
tdesc_name(tp), i, CTF_MAX_VLEN);
tdesc_name(tp), i, CTF_V3_MAX_VLEN);
}
if (tp->t_type == STRUCT)
ctt.ctt_info = CTF_TYPE_INFO(CTF_K_STRUCT, isroot, i);
ctt.ctt_info = CTF_V3_TYPE_INFO(CTF_K_STRUCT, isroot, i);
else
ctt.ctt_info = CTF_TYPE_INFO(CTF_K_UNION, isroot, i);
ctt.ctt_info = CTF_V3_TYPE_INFO(CTF_K_UNION, isroot, i);
write_sized_type_rec(b, &ctt, tp->t_size);
if (tp->t_size < CTF_LSTRUCT_THRESH) {
if (tp->t_size < CTF_V3_LSTRUCT_THRESH) {
for (mp = tp->t_members; mp != NULL; mp = mp->ml_next) {
offset = strtab_insert(&b->ctb_strtab,
mp->ml_name);
@@ -403,8 +400,8 @@ write_type(void *arg1, void *arg2)
ctm.ctm_offset = mp->ml_offset;
if (target_requires_swap) {
SWAP_32(ctm.ctm_name);
SWAP_16(ctm.ctm_type);
SWAP_16(ctm.ctm_offset);
SWAP_32(ctm.ctm_type);
SWAP_32(ctm.ctm_offset);
}
ctf_buf_write(b, &ctm, sizeof (ctm));
}
@@ -423,7 +420,7 @@ write_type(void *arg1, void *arg2)
if (target_requires_swap) {
SWAP_32(ctlm.ctlm_name);
SWAP_16(ctlm.ctlm_type);
SWAP_32(ctlm.ctlm_type);
SWAP_32(ctlm.ctlm_offsethi);
SWAP_32(ctlm.ctlm_offsetlo);
}
@@ -437,11 +434,11 @@ write_type(void *arg1, void *arg2)
for (i = 0, ep = tp->t_emem; ep != NULL; ep = ep->el_next)
i++; /* count up enum members */
if (i > CTF_MAX_VLEN) {
i = CTF_MAX_VLEN;
if (i > CTF_V3_MAX_VLEN) {
i = CTF_V3_MAX_VLEN;
}
ctt.ctt_info = CTF_TYPE_INFO(CTF_K_ENUM, isroot, i);
ctt.ctt_info = CTF_V3_TYPE_INFO(CTF_K_ENUM, isroot, i);
write_sized_type_rec(b, &ctt, tp->t_size);
for (ep = tp->t_emem; ep != NULL && i > 0; ep = ep->el_next) {
@@ -460,25 +457,25 @@ write_type(void *arg1, void *arg2)
break;
case FORWARD:
ctt.ctt_info = CTF_TYPE_INFO(CTF_K_FORWARD, isroot, 0);
ctt.ctt_info = CTF_V3_TYPE_INFO(CTF_K_FORWARD, isroot, 0);
ctt.ctt_type = 0;
write_unsized_type_rec(b, &ctt);
break;
case TYPEDEF:
ctt.ctt_info = CTF_TYPE_INFO(CTF_K_TYPEDEF, isroot, 0);
ctt.ctt_info = CTF_V3_TYPE_INFO(CTF_K_TYPEDEF, isroot, 0);
ctt.ctt_type = tp->t_tdesc->t_id;
write_unsized_type_rec(b, &ctt);
break;
case VOLATILE:
ctt.ctt_info = CTF_TYPE_INFO(CTF_K_VOLATILE, isroot, 0);
ctt.ctt_info = CTF_V3_TYPE_INFO(CTF_K_VOLATILE, isroot, 0);
ctt.ctt_type = tp->t_tdesc->t_id;
write_unsized_type_rec(b, &ctt);
break;
case CONST:
ctt.ctt_info = CTF_TYPE_INFO(CTF_K_CONST, isroot, 0);
ctt.ctt_info = CTF_V3_TYPE_INFO(CTF_K_CONST, isroot, 0);
ctt.ctt_type = tp->t_tdesc->t_id;
write_unsized_type_rec(b, &ctt);
break;
@@ -486,12 +483,12 @@ write_type(void *arg1, void *arg2)
case FUNCTION:
i = tp->t_fndef->fn_nargs + tp->t_fndef->fn_vargs;
if (i > CTF_MAX_VLEN) {
if (i > CTF_V3_MAX_VLEN) {
terminate("function %s has too many args: %d > %d\n",
tdesc_name(tp), i, CTF_MAX_VLEN);
tdesc_name(tp), i, CTF_V3_MAX_VLEN);
}
ctt.ctt_info = CTF_TYPE_INFO(CTF_K_FUNCTION, isroot, i);
ctt.ctt_info = CTF_V3_TYPE_INFO(CTF_K_FUNCTION, isroot, i);
ctt.ctt_type = tp->t_fndef->fn_ret->t_id;
write_unsized_type_rec(b, &ctt);
@@ -499,7 +496,7 @@ write_type(void *arg1, void *arg2)
id = tp->t_fndef->fn_args[i]->t_id;
if (target_requires_swap) {
SWAP_16(id);
SWAP_32(id);
}
ctf_buf_write(b, &id, sizeof (id));
@@ -511,14 +508,10 @@ write_type(void *arg1, void *arg2)
i++;
}
if (i & 1) {
id = 0;
ctf_buf_write(b, &id, sizeof (id));
}
break;
case RESTRICT:
ctt.ctt_info = CTF_TYPE_INFO(CTF_K_RESTRICT, isroot, 0);
ctt.ctt_info = CTF_V3_TYPE_INFO(CTF_K_RESTRICT, isroot, 0);
ctt.ctt_type = tp->t_tdesc->t_id;
write_unsized_type_rec(b, &ctt);
break;
@@ -704,7 +697,7 @@ ctf_gen(iiburst_t *iiburst, size_t *resszp, int do_compress)
* integers; we pad these out to the next 4-byte boundary if needed.
*/
h.cth_magic = CTF_MAGIC;
h.cth_version = CTF_VERSION;
h.cth_version = CTF_VERSION_3;
h.cth_flags = do_compress ? CTF_F_COMPRESS : 0;
h.cth_parlabel = strtab_insert(&buf->ctb_strtab,
iiburst->iib_td->td_parlabel);
@@ -761,14 +754,46 @@ ctf_gen(iiburst_t *iiburst, size_t *resszp, int do_compress)
}
static void
get_ctt_size(ctf_type_t *ctt, size_t *sizep, size_t *incrementp)
get_ctt_info(ctf_header_t *h, void *v, uint_t *kind, uint_t *vlen, int *isroot)
{
if (ctt->ctt_size == CTF_LSIZE_SENT) {
*sizep = (size_t)CTF_TYPE_LSIZE(ctt);
*incrementp = sizeof (ctf_type_t);
if (h->cth_version == CTF_VERSION_2) {
struct ctf_type_v2 *ctt = v;
*kind = CTF_V2_INFO_KIND(ctt->ctt_info);
*vlen = CTF_V2_INFO_VLEN(ctt->ctt_info);
*isroot = CTF_V2_INFO_ISROOT(ctt->ctt_info);
} else {
*sizep = ctt->ctt_size;
*incrementp = sizeof (ctf_stype_t);
struct ctf_type_v3 *ctt = v;
*kind = CTF_V3_INFO_KIND(ctt->ctt_info);
*vlen = CTF_V3_INFO_VLEN(ctt->ctt_info);
*isroot = CTF_V3_INFO_ISROOT(ctt->ctt_info);
}
}
static void
get_ctt_size(ctf_header_t *h, void *v, size_t *sizep, size_t *incrementp)
{
if (h->cth_version == CTF_VERSION_2) {
struct ctf_type_v2 *ctt = v;
if (ctt->ctt_size == CTF_V2_LSIZE_SENT) {
*sizep = (size_t)CTF_TYPE_LSIZE(ctt);
*incrementp = sizeof (struct ctf_type_v2);
} else {
*sizep = ctt->ctt_size;
*incrementp = sizeof (struct ctf_stype_v2);
}
} else {
struct ctf_type_v3 *ctt = v;
if (ctt->ctt_size == CTF_V3_LSIZE_SENT) {
*sizep = (size_t)CTF_TYPE_LSIZE(ctt);
*incrementp = sizeof (struct ctf_type_v3);
} else {
*sizep = ctt->ctt_size;
*incrementp = sizeof (struct ctf_stype_v3);
}
}
}
@@ -776,18 +801,22 @@ static int
count_types(ctf_header_t *h, caddr_t data)
{
caddr_t dptr = data + h->cth_typeoff;
uint_t version = h->cth_version;
size_t idwidth;
int count = 0;
idwidth = version == CTF_VERSION_2 ? 2 : 4;
dptr = data + h->cth_typeoff;
while (dptr < data + h->cth_stroff) {
void *v = (void *) dptr;
ctf_type_t *ctt = v;
size_t vlen = CTF_INFO_VLEN(ctt->ctt_info);
size_t size, increment;
uint_t vlen, kind;
int isroot;
get_ctt_size(ctt, &size, &increment);
get_ctt_info(h, v, &kind, &vlen, &isroot);
get_ctt_size(h, v, &size, &increment);
switch (CTF_INFO_KIND(ctt->ctt_info)) {
switch (kind) {
case CTF_K_INTEGER:
case CTF_K_FLOAT:
dptr += 4;
@@ -799,17 +828,31 @@ count_types(ctf_header_t *h, caddr_t data)
case CTF_K_CONST:
case CTF_K_RESTRICT:
case CTF_K_FUNCTION:
dptr += sizeof (ushort_t) * (vlen + (vlen & 1));
dptr += idwidth * vlen;
break;
case CTF_K_ARRAY:
dptr += sizeof (ctf_array_t);
if (version == CTF_VERSION_2)
dptr += sizeof (struct ctf_array_v2);
else
dptr += sizeof (struct ctf_array_v3);
break;
case CTF_K_STRUCT:
case CTF_K_UNION:
if (size < CTF_LSTRUCT_THRESH)
dptr += sizeof (ctf_member_t) * vlen;
else
dptr += sizeof (ctf_lmember_t) * vlen;
if (version == CTF_VERSION_2) {
if (size < CTF_V2_LSTRUCT_THRESH)
dptr += sizeof (struct ctf_member_v2) *
vlen;
else
dptr += sizeof (struct ctf_lmember_v2) *
vlen;
} else {
if (size < CTF_V3_LSTRUCT_THRESH)
dptr += sizeof (struct ctf_member_v3) *
vlen;
else
dptr += sizeof (struct ctf_lmember_v3) *
vlen;
}
break;
case CTF_K_ENUM:
dptr += sizeof (ctf_enum_t) * vlen;
@@ -818,7 +861,7 @@ count_types(ctf_header_t *h, caddr_t data)
break;
default:
parseterminate("Unknown CTF type %d (#%d) at %#x",
CTF_INFO_KIND(ctt->ctt_info), count, dptr - data);
kind, count, dptr - data);
}
dptr += increment;
@@ -895,11 +938,15 @@ resurrect_objects(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
caddr_t buf = ctfdata + h->cth_objtoff;
size_t bufsz = h->cth_funcoff - h->cth_objtoff;
caddr_t dptr;
size_t idwidth;
idwidth = h->cth_version == CTF_VERSION_2 ? 2 : 4;
symit_reset(si);
for (dptr = buf; dptr < buf + bufsz; dptr += 2) {
void *v = (void *) dptr;
ushort_t id = *((ushort_t *)v);
for (dptr = buf; dptr < buf + bufsz; dptr += idwidth) {
uint32_t id = 0;
memcpy(&id, (void *) dptr, idwidth);
iidesc_t *ii;
GElf_Sym *sym;
@@ -912,7 +959,7 @@ resurrect_objects(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
if (id == 0) {
debug(3, "Skipping null object\n");
continue;
} else if (id >= tdsize) {
} else if (id >= (uint_t)tdsize) {
parseterminate("Reference to invalid type %d", id);
}
@@ -937,18 +984,21 @@ resurrect_functions(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
{
caddr_t buf = ctfdata + h->cth_funcoff;
size_t bufsz = h->cth_typeoff - h->cth_funcoff;
size_t idwidth;
caddr_t dptr = buf;
iidesc_t *ii;
ushort_t info;
ushort_t retid;
GElf_Sym *sym;
int i;
idwidth = h->cth_version == CTF_VERSION_2 ? 2 : 4;
symit_reset(si);
while (dptr < buf + bufsz) {
void *v = (void *) dptr;
info = *((ushort_t *)v);
dptr += 2;
uint32_t id, info, retid;
info = 0;
memcpy(&info, (void *) dptr, idwidth);
dptr += idwidth;
if (!(sym = symit_next(si, STT_FUNC)) && info != 0)
parseterminate("Unexpected end of function symbols");
@@ -959,11 +1009,11 @@ resurrect_functions(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
continue;
}
v = (void *) dptr;
retid = *((ushort_t *)v);
dptr += 2;
retid = 0;
memcpy(&retid, (void *) dptr, idwidth);
dptr += idwidth;
if (retid >= tdsize)
if (retid >= (uint_t)tdsize)
parseterminate("Reference to invalid type %d", retid);
ii = iidesc_new(symit_name(si));
@@ -973,15 +1023,18 @@ resurrect_functions(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
ii->ii_owner = xstrdup(symit_curfile(si));
} else
ii->ii_type = II_GFUN;
ii->ii_nargs = CTF_INFO_VLEN(info);
if (h->cth_version == CTF_VERSION_2)
ii->ii_nargs = CTF_V2_INFO_VLEN(info);
else
ii->ii_nargs = CTF_V3_INFO_VLEN(info);
if (ii->ii_nargs)
ii->ii_args =
xmalloc(sizeof (tdesc_t *) * ii->ii_nargs);
for (i = 0; i < ii->ii_nargs; i++, dptr += 2) {
v = (void *) dptr;
ushort_t id = *((ushort_t *)v);
if (id >= tdsize)
for (i = 0; i < ii->ii_nargs; i++, dptr += idwidth) {
id = 0;
memcpy(&id, (void *) dptr, idwidth);
if (id >= (uint_t)tdsize)
parseterminate("Reference to invalid type %d",
id);
ii->ii_args[i] = tdarr[id];
@@ -1011,55 +1064,65 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
tdesc_t *tdp;
uint_t data;
uint_t encoding;
size_t size, increment;
size_t idwidth, size, increment;
int tcnt;
int iicnt = 0;
tid_t tid, argid;
int kind, vlen;
int i;
int isroot, kind, vlen;
int i, version;
elist_t **epp;
mlist_t **mpp;
intr_t *ip;
ctf_type_t *ctt;
ctf_array_t *cta;
ctf_enum_t *cte;
version = h->cth_version;
idwidth = version == CTF_VERSION_2 ? 2 : 4;
/*
* A maxid of zero indicates a request to resurrect all types, so reset
* maxid to the maximum type id.
*/
if (maxid == 0)
maxid = CTF_MAX_TYPE;
if (maxid == 0) {
maxid = version == CTF_VERSION_2 ?
CTF_V2_MAX_TYPE : CTF_V3_MAX_TYPE;
}
for (dptr = buf, tcnt = 0, tid = 1; dptr < buf + bufsz; tcnt++, tid++) {
ctf_enum_t *cte;
uint_t name, type;
void *v;
if (tid > maxid)
break;
if (tid >= tdsize)
parseterminate("Reference to invalid type %d", tid);
void *v = (void *) dptr;
ctt = v;
get_ctt_info(h, dptr, &kind, &vlen, &isroot);
get_ctt_size(h, dptr, &size, &increment);
if (version == CTF_VERSION_2) {
struct ctf_type_v2 *ctt = (void *) dptr;
get_ctt_size(ctt, &size, &increment);
name = ctt->ctt_name;
type = ctt->ctt_type;
} else {
struct ctf_type_v3 *ctt = (void *) dptr;
name = ctt->ctt_name;
type = ctt->ctt_type;
}
dptr += increment;
tdp = tdarr[tid];
if (CTF_NAME_STID(ctt->ctt_name) != CTF_STRTAB_0)
if (CTF_NAME_STID(name) != CTF_STRTAB_0)
parseterminate(
"Unable to cope with non-zero strtab id");
if (CTF_NAME_OFFSET(ctt->ctt_name) != 0) {
tdp->t_name =
xstrdup(sbuf + CTF_NAME_OFFSET(ctt->ctt_name));
if (CTF_NAME_OFFSET(name) != 0) {
tdp->t_name = xstrdup(sbuf + CTF_NAME_OFFSET(name));
} else
tdp->t_name = NULL;
kind = CTF_INFO_KIND(ctt->ctt_info);
vlen = CTF_INFO_VLEN(ctt->ctt_info);
switch (kind) {
case CTF_K_INTEGER:
tdp->t_type = INTRINSIC;
@@ -1106,62 +1169,110 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
case CTF_K_POINTER:
tdp->t_type = POINTER;
tdp->t_tdesc = tdarr[ctt->ctt_type];
tdp->t_tdesc = tdarr[type];
break;
case CTF_K_ARRAY:
case CTF_K_ARRAY: {
uint_t contents, index, nelems;
tdp->t_type = ARRAY;
tdp->t_size = size;
v = (void *) dptr;
cta = v;
dptr += sizeof (ctf_array_t);
if (version == CTF_VERSION_2) {
struct ctf_array_v2 *cta = (void *) dptr;
contents = cta->cta_contents;
index = cta->cta_index;
nelems = cta->cta_nelems;
dptr += sizeof (*cta);
} else {
struct ctf_array_v3 *cta = (void *) dptr;
contents = cta->cta_contents;
index = cta->cta_index;
nelems = cta->cta_nelems;
dptr += sizeof (*cta);
}
tdp->t_ardef = xmalloc(sizeof (ardef_t));
tdp->t_ardef->ad_contents = tdarr[cta->cta_contents];
tdp->t_ardef->ad_idxtype = tdarr[cta->cta_index];
tdp->t_ardef->ad_nelems = cta->cta_nelems;
tdp->t_ardef->ad_contents = tdarr[contents];
tdp->t_ardef->ad_idxtype = tdarr[index];
tdp->t_ardef->ad_nelems = nelems;
break;
}
case CTF_K_STRUCT:
case CTF_K_UNION:
case CTF_K_UNION: {
tdp->t_type = (kind == CTF_K_STRUCT ? STRUCT : UNION);
tdp->t_size = size;
if (size < CTF_LSTRUCT_THRESH) {
for (i = 0, mpp = &tdp->t_members; i < vlen;
i++, mpp = &((*mpp)->ml_next)) {
v = (void *) dptr;
ctf_member_t *ctm = v;
dptr += sizeof (ctf_member_t);
if (version == CTF_VERSION_2) {
if (size < CTF_V2_LSTRUCT_THRESH) {
for (i = 0, mpp = &tdp->t_members; i < vlen;
i++, mpp = &((*mpp)->ml_next)) {
v = (void *) dptr;
struct ctf_member_v2 *ctm = v;
dptr += sizeof (struct ctf_member_v2);
*mpp = xmalloc(sizeof (mlist_t));
(*mpp)->ml_name = xstrdup(sbuf +
ctm->ctm_name);
(*mpp)->ml_type = tdarr[ctm->ctm_type];
(*mpp)->ml_offset = ctm->ctm_offset;
(*mpp)->ml_size = 0;
*mpp = xmalloc(sizeof (mlist_t));
(*mpp)->ml_name = xstrdup(sbuf +
ctm->ctm_name);
(*mpp)->ml_type = tdarr[ctm->ctm_type];
(*mpp)->ml_offset = ctm->ctm_offset;
(*mpp)->ml_size = 0;
}
} else {
for (i = 0, mpp = &tdp->t_members; i < vlen;
i++, mpp = &((*mpp)->ml_next)) {
v = (void *) dptr;
struct ctf_lmember_v2 *ctlm = v;
dptr += sizeof (struct ctf_lmember_v2);
*mpp = xmalloc(sizeof (mlist_t));
(*mpp)->ml_name = xstrdup(sbuf +
ctlm->ctlm_name);
(*mpp)->ml_type =
tdarr[ctlm->ctlm_type];
(*mpp)->ml_offset =
(int)CTF_LMEM_OFFSET(ctlm);
(*mpp)->ml_size = 0;
}
}
} else {
for (i = 0, mpp = &tdp->t_members; i < vlen;
i++, mpp = &((*mpp)->ml_next)) {
v = (void *) dptr;
ctf_lmember_t *ctlm = v;
dptr += sizeof (ctf_lmember_t);
if (size < CTF_V3_LSTRUCT_THRESH) {
for (i = 0, mpp = &tdp->t_members; i < vlen;
i++, mpp = &((*mpp)->ml_next)) {
v = (void *) dptr;
struct ctf_member_v3 *ctm = v;
dptr += sizeof (struct ctf_member_v3);
*mpp = xmalloc(sizeof (mlist_t));
(*mpp)->ml_name = xstrdup(sbuf +
ctlm->ctlm_name);
(*mpp)->ml_type =
tdarr[ctlm->ctlm_type];
(*mpp)->ml_offset =
(int)CTF_LMEM_OFFSET(ctlm);
(*mpp)->ml_size = 0;
*mpp = xmalloc(sizeof (mlist_t));
(*mpp)->ml_name = xstrdup(sbuf +
ctm->ctm_name);
(*mpp)->ml_type = tdarr[ctm->ctm_type];
(*mpp)->ml_offset = ctm->ctm_offset;
(*mpp)->ml_size = 0;
}
} else {
for (i = 0, mpp = &tdp->t_members; i < vlen;
i++, mpp = &((*mpp)->ml_next)) {
v = (void *) dptr;
struct ctf_lmember_v3 *ctlm = v;
dptr += sizeof (struct ctf_lmember_v3);
*mpp = xmalloc(sizeof (mlist_t));
(*mpp)->ml_name = xstrdup(sbuf +
ctlm->ctlm_name);
(*mpp)->ml_type =
tdarr[ctlm->ctlm_type];
(*mpp)->ml_offset =
(int)CTF_LMEM_OFFSET(ctlm);
(*mpp)->ml_size = 0;
}
}
}
*mpp = NULL;
break;
}
case CTF_K_ENUM:
tdp->t_type = ENUM;
@@ -1187,26 +1298,26 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
case CTF_K_TYPEDEF:
tdp->t_type = TYPEDEF;
tdp->t_tdesc = tdarr[ctt->ctt_type];
tdp->t_tdesc = tdarr[type];
break;
case CTF_K_VOLATILE:
tdp->t_type = VOLATILE;
tdp->t_tdesc = tdarr[ctt->ctt_type];
tdp->t_tdesc = tdarr[type];
break;
case CTF_K_CONST:
tdp->t_type = CONST;
tdp->t_tdesc = tdarr[ctt->ctt_type];
tdp->t_tdesc = tdarr[type];
break;
case CTF_K_FUNCTION:
tdp->t_type = FUNCTION;
tdp->t_fndef = xcalloc(sizeof (fndef_t));
tdp->t_fndef->fn_ret = tdarr[ctt->ctt_type];
tdp->t_fndef->fn_ret = tdarr[type];
v = (void *) (dptr + (sizeof (ushort_t) * (vlen - 1)));
if (vlen > 0 && *(ushort_t *)v == 0)
v = (void *) (dptr + (idwidth * (vlen - 1)));
if (vlen > 0 && *(uint_t *)v == 0)
tdp->t_fndef->fn_vargs = 1;
tdp->t_fndef->fn_nargs = vlen - tdp->t_fndef->fn_vargs;
@@ -1215,20 +1326,19 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
for (i = 0; i < vlen; i++) {
v = (void *) dptr;
argid = *(ushort_t *)v;
dptr += sizeof (ushort_t);
memcpy(&argid, v, idwidth);
dptr += idwidth;
if (argid != 0)
tdp->t_fndef->fn_args[i] = tdarr[argid];
}
if (vlen & 1)
dptr += sizeof (ushort_t);
dptr = (caddr_t) roundup2((uintptr_t) dptr, 4);
break;
case CTF_K_RESTRICT:
tdp->t_type = RESTRICT;
tdp->t_tdesc = tdarr[ctt->ctt_type];
tdp->t_tdesc = tdarr[type];
break;
case CTF_K_UNKNOWN:
@@ -1238,7 +1348,7 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
warning("Can't parse unknown CTF type %d\n", kind);
}
if (CTF_INFO_ISROOT(ctt->ctt_info)) {
if (isroot) {
iidesc_t *ii = iidesc_new(tdp->t_name);
if (tdp->t_type == STRUCT || tdp->t_type == UNION ||
tdp->t_type == ENUM)
@@ -1252,8 +1362,7 @@ resurrect_types(ctf_header_t *h, tdata_t *td, tdesc_t **tdarr, int tdsize,
}
debug(3, "Resurrected %d %stype %s (%d)\n", tdp->t_type,
(CTF_INFO_ISROOT(ctt->ctt_info) ? "root " : ""),
tdesc_name(tdp), tdp->t_id);
(isroot ? "root " : ""), tdesc_name(tdp), tdp->t_id);
}
debug(3, "Resurrected %d types (%d were roots)\n", tcnt, iicnt);
@@ -1353,7 +1462,7 @@ ctf_load(char *file, caddr_t buf, size_t bufsz, symit_data_t *si, char *label)
if (h->cth_magic != CTF_MAGIC)
parseterminate("Corrupt CTF - bad magic 0x%x", h->cth_magic);
if (h->cth_version != CTF_VERSION)
if (h->cth_version != CTF_VERSION_2 && h->cth_version != CTF_VERSION_3)
parseterminate("Unknown CTF version %d", h->cth_version);
ctfdatasz = h->cth_stroff + h->cth_strlen;
@@ -972,11 +972,11 @@ main(int argc, char **argv)
savetd = tdata_new();
if (CTF_TYPE_ISCHILD(reftd->td_nextid))
if (CTF_V3_TYPE_ISCHILD(reftd->td_nextid))
terminate("No room for additional types in master\n");
savetd->td_nextid = withfile ? reftd->td_nextid :
CTF_INDEX_TO_TYPE(1, TRUE);
CTF_V3_INDEX_TO_TYPE(1, TRUE);
merge_into_master(mstrtd, reftd, savetd, 0);
tdata_label_add(savetd, label, CTF_LABEL_LASTIDX);
@@ -467,7 +467,6 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
int keep_stabs = (flags & CTF_KEEP_STABS);
int *secxlate;
int srcidx, dstidx;
int curnmoff = 0;
int changing = 0;
int pad;
int i;
@@ -529,7 +528,6 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname,
secxlate[srcidx] = -1;
} else {
secxlate[srcidx] = dstidx++;
curnmoff += strlen(sname) + 1;
}
new_offset = (off_t)dehdr.e_phoff;
+188 -96
View File
@@ -97,6 +97,8 @@ typedef struct ctf_data {
caddr_t cd_ctfdata; /* Pointer to the CTF data */
size_t cd_ctflen; /* Length of CTF data */
size_t cd_idwidth; /* Size of a type ID, in bytes */
/*
* cd_symdata will be non-NULL if the CTF data is being retrieved from
* an ELF file with a symbol table. cd_strdata and cd_nsyms should be
@@ -266,9 +268,8 @@ next_sym(const ctf_data_t *cd, const int symidx, const uchar_t matchtype,
static int
read_data(const ctf_header_t *hp, const ctf_data_t *cd)
{
void *v = (void *) (cd->cd_ctfdata + hp->cth_objtoff);
const ushort_t *idp = v;
ulong_t n = (hp->cth_funcoff - hp->cth_objtoff) / sizeof (ushort_t);
const char *v = (void *) (cd->cd_ctfdata + hp->cth_objtoff);
ulong_t n = (hp->cth_funcoff - hp->cth_objtoff) / cd->cd_idwidth;
if (flags != F_STATS)
print_line("- Data Objects ");
@@ -287,6 +288,7 @@ read_data(const ctf_header_t *hp, const ctf_data_t *cd)
char *name = NULL;
for (symidx = -1, i = 0; i < (int) n; i++) {
uint32_t id = 0;
int nextsym;
if (cd->cd_symdata == NULL || (nextsym = next_sym(cd,
@@ -295,7 +297,9 @@ read_data(const ctf_header_t *hp, const ctf_data_t *cd)
else
symidx = nextsym;
len = printf(" [%u] %u", i, *idp++);
memcpy(&id, v, cd->cd_idwidth);
v += cd->cd_idwidth;
len = printf(" [%u] %u", i, id);
if (name != NULL)
(void) printf("%*s%s (%u)", (15 - len), "",
name, symidx);
@@ -310,11 +314,10 @@ read_data(const ctf_header_t *hp, const ctf_data_t *cd)
static int
read_funcs(const ctf_header_t *hp, const ctf_data_t *cd)
{
void *v = (void *) (cd->cd_ctfdata + hp->cth_funcoff);
const ushort_t *fp = v;
const char *v = (void *) (cd->cd_ctfdata + hp->cth_funcoff);
uint_t f = 0, info;
v = (void *) (cd->cd_ctfdata + hp->cth_typeoff);
const ushort_t *end = v;
const char *end = (void *) (cd->cd_ctfdata + hp->cth_typeoff);
ulong_t id;
int symidx;
@@ -331,10 +334,14 @@ read_funcs(const ctf_header_t *hp, const ctf_data_t *cd)
if (hp->cth_funcoff > hp->cth_typeoff)
WARN("file is corrupt -- cth_funcoff > cth_typeoff\n");
for (symidx = -1, id = 0; fp < end; id++) {
ushort_t info = *fp++;
ushort_t kind = CTF_INFO_KIND(info);
ushort_t n = CTF_INFO_VLEN(info);
for (symidx = -1, id = 0; v < end; id++) {
info = 0;
memcpy(&info, v, cd->cd_idwidth);
v += cd->cd_idwidth;
ushort_t kind = hp->cth_version == CTF_VERSION_2 ?
CTF_V2_INFO_KIND(info) : CTF_V3_INFO_KIND(info);
ushort_t n = hp->cth_version == CTF_VERSION_2 ?
CTF_V2_INFO_VLEN(info) : CTF_V3_INFO_VLEN(info);
ushort_t i;
int nextsym;
char *name;
@@ -354,7 +361,7 @@ read_funcs(const ctf_header_t *hp, const ctf_data_t *cd)
return (E_ERROR);
}
if (fp + n > end) {
if (v + n * cd->cd_idwidth > end) {
(void) printf(" [%lu] vlen %u extends past section "
"boundary\n", id, n);
return (E_ERROR);
@@ -364,17 +371,24 @@ read_funcs(const ctf_header_t *hp, const ctf_data_t *cd)
(void) printf(" [%lu] FUNC ", id);
if (name != NULL)
(void) printf("(%s) ", name);
(void) printf("returns: %u args: (", *fp++);
memcpy(&f, v, cd->cd_idwidth);
v += cd->cd_idwidth;
(void) printf("returns: %u args: (", f);
if (n != 0) {
(void) printf("%u", *fp++);
for (i = 1; i < n; i++)
(void) printf(", %u", *fp++);
memcpy(&f, v, cd->cd_idwidth);
v += cd->cd_idwidth;
(void) printf("%u", f);
for (i = 1; i < n; i++) {
memcpy(&f, v, cd->cd_idwidth);
v += cd->cd_idwidth;
(void) printf(", %u", f);
}
}
(void) printf(")\n");
} else
fp += n + 1; /* skip to next function definition */
v += n * cd->cd_idwidth + 1; /* skip to next function definition */
stats.s_nfunc++;
stats.s_nargs += n;
@@ -387,13 +401,10 @@ read_funcs(const ctf_header_t *hp, const ctf_data_t *cd)
static int
read_types(const ctf_header_t *hp, const ctf_data_t *cd)
{
void *v = (void *) (cd->cd_ctfdata + hp->cth_typeoff);
const ctf_type_t *tp = v;
v = (void *) (cd->cd_ctfdata + hp->cth_stroff);
const ctf_type_t *end = v;
const char *v = (void *) (cd->cd_ctfdata + hp->cth_typeoff);
const char *end = (void *) (cd->cd_ctfdata + hp->cth_stroff);
ulong_t id;
uint_t version;
if (flags != F_STATS)
print_line("- Types ");
@@ -407,103 +418,158 @@ read_types(const ctf_header_t *hp, const ctf_data_t *cd)
if (hp->cth_typeoff > hp->cth_stroff)
WARN("file is corrupt -- cth_typeoff > cth_stroff\n");
version = hp->cth_version;
id = 1;
if (hp->cth_parlabel || hp->cth_parname)
id += 1 << CTF_PARENT_SHIFT;
id += 1ul << (hp->cth_version == CTF_VERSION_2 ?
CTF_V2_PARENT_SHIFT : CTF_V3_PARENT_SHIFT);
for (/* */; tp < end; id++) {
ulong_t i, n = CTF_INFO_VLEN(tp->ctt_info);
for (/* */; v < end; id++) {
struct ctf_type_v2 t2;
struct ctf_type_v3 t3;
ulong_t i, n;
size_t size, increment, vlen = 0;
int kind = CTF_INFO_KIND(tp->ctt_info);
uint_t isroot, name, type;
int kind;
if (version == CTF_VERSION_2) {
memcpy(&t2, v, sizeof(t2));
name = t2.ctt_name;
n = CTF_V2_INFO_VLEN(t2.ctt_info);
isroot = CTF_V2_INFO_ISROOT(t2.ctt_info);
kind = CTF_V2_INFO_KIND(t2.ctt_info);
type = t2.ctt_type;
if (t2.ctt_size == CTF_V2_LSIZE_SENT) {
increment = sizeof (struct ctf_type_v2);
size = (size_t)CTF_TYPE_LSIZE(&t2);
} else {
increment = sizeof (struct ctf_stype_v2);
size = t2.ctt_size;
}
} else {
memcpy(&t3, v, sizeof(t3));
name = t3.ctt_name;
n = CTF_V3_INFO_VLEN(t3.ctt_info);
isroot = CTF_V3_INFO_ISROOT(t3.ctt_info);
kind = CTF_V3_INFO_KIND(t3.ctt_info);
type = t3.ctt_type;
if (t3.ctt_size == CTF_V3_LSIZE_SENT) {
increment = sizeof (struct ctf_type_v3);
size = (size_t)CTF_TYPE_LSIZE(&t3);
} else {
increment = sizeof (struct ctf_stype_v3);
size = t3.ctt_size;
}
}
union {
const void *ptr;
ctf_array_t *ap;
const ctf_member_t *mp;
const ctf_lmember_t *lmp;
const char *ptr;
struct ctf_array_v2 *ap2;
struct ctf_array_v3 *ap3;
const struct ctf_member_v2 *mp2;
const struct ctf_member_v3 *mp3;
const struct ctf_lmember_v2 *lmp2;
const struct ctf_lmember_v3 *lmp3;
const ctf_enum_t *ep;
const ushort_t *argp;
} u;
u.ptr = v + increment;
if (flags != F_STATS) {
(void) printf(" %c%lu%c ",
"[<"[CTF_INFO_ISROOT(tp->ctt_info)], id,
"]>"[CTF_INFO_ISROOT(tp->ctt_info)]);
"[<"[isroot], id, "]>"[isroot]);
}
if (tp->ctt_size == CTF_LSIZE_SENT) {
increment = sizeof (ctf_type_t);
size = (size_t)CTF_TYPE_LSIZE(tp);
} else {
increment = sizeof (ctf_stype_t);
size = tp->ctt_size;
}
u.ptr = (const char *)tp + increment;
switch (kind) {
case CTF_K_INTEGER:
if (flags != F_STATS) {
uint_t encoding = *((const uint_t *)u.ptr);
uint_t encoding =
*((const uint_t *)(const void *)u.ptr);
(void) printf("INTEGER %s encoding=%s offset=%u"
" bits=%u", ref_to_str(tp->ctt_name, hp,
cd), int_encoding_to_str(
" bits=%u", ref_to_str(name, hp, cd),
int_encoding_to_str(
CTF_INT_ENCODING(encoding)),
CTF_INT_OFFSET(encoding),
CTF_INT_BITS(encoding));
}
vlen = sizeof (uint_t);
vlen = sizeof (uint32_t);
break;
case CTF_K_FLOAT:
if (flags != F_STATS) {
uint_t encoding = *((const uint_t *)u.ptr);
uint_t encoding =
*((const uint_t *)(const void *)u.ptr);
(void) printf("FLOAT %s encoding=%s offset=%u "
"bits=%u", ref_to_str(tp->ctt_name, hp,
cd), fp_encoding_to_str(
"bits=%u", ref_to_str(name, hp, cd),
fp_encoding_to_str(
CTF_FP_ENCODING(encoding)),
CTF_FP_OFFSET(encoding),
CTF_FP_BITS(encoding));
}
vlen = sizeof (uint_t);
vlen = sizeof (uint32_t);
break;
case CTF_K_POINTER:
if (flags != F_STATS) {
(void) printf("POINTER %s refers to %u",
ref_to_str(tp->ctt_name, hp, cd),
tp->ctt_type);
ref_to_str(name, hp, cd), type);
}
break;
case CTF_K_ARRAY:
case CTF_K_ARRAY: {
uint_t contents, index, nelems;
if (version == CTF_VERSION_2) {
contents = u.ap2->cta_contents;
index = u.ap2->cta_index;
nelems = u.ap2->cta_nelems;
} else {
contents = u.ap3->cta_contents;
index = u.ap3->cta_index;
nelems = u.ap3->cta_nelems;
}
if (flags != F_STATS) {
(void) printf("ARRAY %s content: %u index: %u "
"nelems: %u\n", ref_to_str(tp->ctt_name,
hp, cd), u.ap->cta_contents,
u.ap->cta_index, u.ap->cta_nelems);
"nelems: %u\n", ref_to_str(name, hp, cd),
contents, index, nelems);
}
vlen = sizeof (ctf_array_t);
if (version == 2)
vlen = sizeof (struct ctf_array_v2);
else
vlen = sizeof (struct ctf_array_v3);
break;
}
case CTF_K_FUNCTION: {
uint_t arg = 0;
case CTF_K_FUNCTION:
if (flags != F_STATS) {
(void) printf("FUNCTION %s returns: %u args: (",
ref_to_str(tp->ctt_name, hp, cd),
tp->ctt_type);
ref_to_str(name, hp, cd), type);
if (n != 0) {
(void) printf("%u", *u.argp++);
for (i = 1; i < n; i++, u.argp++)
(void) printf(", %u", *u.argp);
memcpy(&arg, u.ptr, cd->cd_idwidth);
u.ptr += cd->cd_idwidth;
(void) printf("%u", arg);
for (i = 1; i < n;
i++, u.ptr += cd->cd_idwidth) {
memcpy(&arg, u.ptr,
cd->cd_idwidth);
(void) printf(", %u", arg);
}
}
(void) printf(")");
}
vlen = sizeof (ushort_t) * (n + (n & 1));
vlen = roundup2(cd->cd_idwidth * n, 4);
break;
}
case CTF_K_STRUCT:
case CTF_K_UNION:
@@ -527,36 +593,64 @@ read_types(const ctf_header_t *hp, const ctf_data_t *cd)
if (flags != F_STATS) {
(void) printf(" %s (%zd bytes)\n",
ref_to_str(tp->ctt_name, hp, cd), size);
ref_to_str(name, hp, cd), size);
if (size >= CTF_LSTRUCT_THRESH) {
for (i = 0; i < n; i++, u.lmp++) {
(void) printf(
"\t%s type=%u off=%llu\n",
ref_to_str(u.lmp->ctlm_name,
hp, cd), u.lmp->ctlm_type,
(unsigned long long)
CTF_LMEM_OFFSET(u.lmp));
if (version == CTF_VERSION_2) {
if (size >= CTF_V2_LSTRUCT_THRESH) {
for (i = 0; i < n; i++, u.lmp2++) {
(void) printf(
"\t%s type=%u off=%llu\n",
ref_to_str(u.lmp2->ctlm_name,
hp, cd), u.lmp2->ctlm_type,
(unsigned long long)
CTF_LMEM_OFFSET(u.lmp2));
}
} else {
for (i = 0; i < n; i++, u.mp2++) {
(void) printf(
"\t%s type=%u off=%u\n",
ref_to_str(u.mp2->ctm_name,
hp, cd), u.mp2->ctm_type,
u.mp2->ctm_offset);
}
}
} else {
for (i = 0; i < n; i++, u.mp++) {
(void) printf(
"\t%s type=%u off=%u\n",
ref_to_str(u.mp->ctm_name,
hp, cd), u.mp->ctm_type,
u.mp->ctm_offset);
if (size >= CTF_V3_LSTRUCT_THRESH) {
for (i = 0; i < n; i++, u.lmp3++) {
(void) printf(
"\t%s type=%u off=%llu\n",
ref_to_str(u.lmp3->ctlm_name,
hp, cd), u.lmp3->ctlm_type,
(unsigned long long)
CTF_LMEM_OFFSET(u.lmp3));
}
} else {
for (i = 0; i < n; i++, u.mp3++) {
(void) printf(
"\t%s type=%u off=%u\n",
ref_to_str(u.mp3->ctm_name,
hp, cd), u.mp3->ctm_type,
u.mp3->ctm_offset);
}
}
}
}
vlen = n * (size >= CTF_LSTRUCT_THRESH ?
sizeof (ctf_lmember_t) : sizeof (ctf_member_t));
if (version == CTF_VERSION_2) {
vlen = n * (size >= CTF_V2_LSTRUCT_THRESH ?
sizeof (struct ctf_lmember_v2) :
sizeof (struct ctf_member_v2));
} else {
vlen = n * (size >= CTF_V3_LSTRUCT_THRESH ?
sizeof (struct ctf_lmember_v3) :
sizeof (struct ctf_member_v3));
}
break;
case CTF_K_ENUM:
if (flags != F_STATS) {
(void) printf("ENUM %s\n",
ref_to_str(tp->ctt_name, hp, cd));
ref_to_str(name, hp, cd));
for (i = 0; i < n; i++, u.ep++) {
(void) printf("\t%s = %d\n",
@@ -574,39 +668,35 @@ read_types(const ctf_header_t *hp, const ctf_data_t *cd)
case CTF_K_FORWARD:
if (flags != F_STATS) {
(void) printf("FORWARD %s",
ref_to_str(tp->ctt_name, hp, cd));
ref_to_str(name, hp, cd));
}
break;
case CTF_K_TYPEDEF:
if (flags != F_STATS) {
(void) printf("TYPEDEF %s refers to %u",
ref_to_str(tp->ctt_name, hp, cd),
tp->ctt_type);
ref_to_str(name, hp, cd), type);
}
break;
case CTF_K_VOLATILE:
if (flags != F_STATS) {
(void) printf("VOLATILE %s refers to %u",
ref_to_str(tp->ctt_name, hp, cd),
tp->ctt_type);
ref_to_str(name, hp, cd), type);
}
break;
case CTF_K_CONST:
if (flags != F_STATS) {
(void) printf("CONST %s refers to %u",
ref_to_str(tp->ctt_name, hp, cd),
tp->ctt_type);
ref_to_str(name, hp, cd), type);
}
break;
case CTF_K_RESTRICT:
if (flags != F_STATS) {
(void) printf("RESTRICT %s refers to %u",
ref_to_str(tp->ctt_name, hp, cd),
tp->ctt_type);
ref_to_str(name, hp, cd), type);
}
break;
@@ -624,7 +714,7 @@ read_types(const ctf_header_t *hp, const ctf_data_t *cd)
stats.s_ntypes++;
stats.s_types[kind]++;
tp = (ctf_type_t *)((uintptr_t)tp + increment + vlen);
v += increment + vlen;
}
return (E_SUCCESS);
@@ -935,14 +1025,16 @@ main(int argc, char *argv[])
if (pp->ctp_magic != CTF_MAGIC)
die("%s does not appear to contain CTF data\n", filename);
if (pp->ctp_version == CTF_VERSION) {
if (pp->ctp_version >= CTF_VERSION_2) {
v = (void *) cd.cd_ctfdata;
hp = v;
cd.cd_ctfdata = (caddr_t)cd.cd_ctfdata + sizeof (ctf_header_t);
cd.cd_idwidth = pp->ctp_version == CTF_VERSION_2 ? 2 : 4;
if (cd.cd_ctflen < sizeof (ctf_header_t)) {
die("%s does not contain a v%d CTF header\n", filename,
CTF_VERSION);
pp->ctp_version);
}
} else {
-1
View File
@@ -70,7 +70,6 @@ SYSINCSDIR= ${INCLUDEDIR}/sys
INCS+= ${SRCTOP}/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h
SYSINCS+= ${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/sys/dtrace.h
SYSINCS+= ${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/sys/ctf_api.h
SYSINCS+= ${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/sys/ctf.h
WARNS?= 1
+1 -1
View File
@@ -1,5 +1,5 @@
Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper
Copyright (c) 2001-2017 Expat maintainers
Copyright (c) 2001-2019 Expat maintainers
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
+408 -3
View File
@@ -2,7 +2,412 @@ 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.2.9 Wed Septemper 25 2019
Release 2.4.7 Fri March 4 2022
Bug fixes:
#572 #577 Relax fix to CVE-2022-25236 (introduced with release 2.4.5)
with regard to all valid URI characters (RFC 3986),
i.e. the following set (excluding whitespace):
ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
0123456789 % -._~ :/?#[]@ !$&'()*+,;=
Other changes:
#555 #570 #581 CMake|Windows: Store Expat version in the DLL
#577 Document consequences of namespace separator choices not just
in doc/reference.html but also in header <expat.h>
#577 Document Expat's lack of validation of namespace URIs against
RFC 3986, and that the XML 1.0r4 specification doesn't
require Expat to validate namespace URIs, and that Expat
may do more in that regard in future releases.
If you find need for strict RFC 3986 URI validation on
application level today, https://uriparser.github.io/ may
be of interest.
#579 Fix documentation of XML_EndDoctypeDeclHandler in <expat.h>
#575 Document that a call to XML_FreeContentModel can be done at
a later time from outside the element declaration handler
#574 Make hardcoded namespace URIs easier to find in code
#573 Update documentation on use of XML_POOR_ENTOPY on Solaris
#569 #571 tests: Resolve use of macros NAN and INFINITY for GNU G++
4.8.2 on Solaris.
#578 #580 Version info bumped from 9:6:8 to 9:7:8;
see https://verbump.de/ for what these numbers do
Special thanks to:
Jeffrey Walton
Johnny Jazeix
Thijs Schreijer
Release 2.4.6 Sun February 20 2022
Bug fixes:
#566 Fix a regression introduced by the fix for CVE-2022-25313
in release 2.4.5 that affects applications that (1)
call function XML_SetElementDeclHandler and (2) are
parsing XML that contains nested element declarations
(e.g. "<!ELEMENT junk ((bar|foo|xyz+), zebra*)>").
Other changes:
#567 #568 Version info bumped from 9:5:8 to 9:6:8;
see https://verbump.de/ for what these numbers do
Special thanks to:
Matt Sergeant
Samanta Navarro
Sergei Trofimovich
and
NixOS
Perl XML::Parser
Release 2.4.5 Fri February 18 2022
Security fixes:
#562 CVE-2022-25235 -- Passing malformed 2- and 3-byte UTF-8
sequences (e.g. from start tag names) to the XML
processing application on top of Expat can cause
arbitrary damage (e.g. code execution) depending
on how invalid UTF-8 is handled inside the XML
processor; validation was not their job but Expat's.
Exploits with code execution are known to exist.
#561 CVE-2022-25236 -- Passing (one or more) namespace separator
characters in "xmlns[:prefix]" attribute values
made Expat send malformed tag names to the XML
processor on top of Expat which can cause
arbitrary damage (e.g. code execution) depending
on such unexpectable cases are handled inside the XML
processor; validation was not their job but Expat's.
Exploits with code execution are known to exist.
#558 CVE-2022-25313 -- Fix stack exhaustion in doctype parsing
that could be triggered by e.g. a 2 megabytes
file with a large number of opening braces.
Expected impact is denial of service or potentially
arbitrary code execution.
#560 CVE-2022-25314 -- Fix integer overflow in function copyString;
only affects the encoding name parameter at parser creation
time which is often hardcoded (rather than user input),
takes a value in the gigabytes to trigger, and a 64-bit
machine. Expected impact is denial of service.
#559 CVE-2022-25315 -- Fix integer overflow in function storeRawNames;
needs input in the gigabytes and a 64-bit machine.
Expected impact is denial of service or potentially
arbitrary code execution.
Other changes:
#557 #564 Version info bumped from 9:4:8 to 9:5:8;
see https://verbump.de/ for what these numbers do
Special thanks to:
Ivan Fratric
Samanta Navarro
and
Google Project Zero
JetBrains
Release 2.4.4 Sun January 30 2022
Security fixes:
#550 CVE-2022-23852 -- Fix signed integer overflow
(undefined behavior) in function XML_GetBuffer
(that is also called by function XML_Parse internally)
for when XML_CONTEXT_BYTES is defined to >0 (which is both
common and default).
Impact is denial of service or more.
#551 CVE-2022-23990 -- Fix unsigned integer overflow in function
doProlog triggered by large content in element type
declarations when there is an element declaration handler
present (from a prior call to XML_SetElementDeclHandler).
Impact is denial of service or more.
Bug fixes:
#544 #545 xmlwf: Fix a memory leak on output file opening error
Other changes:
#546 Autotools: Fix broken CMake support under Cygwin
#554 Windows: Add missing files to the installer to fix
compilation with CMake from installed sources
#552 #554 Version info bumped from 9:3:8 to 9:4:8;
see https://verbump.de/ for what these numbers do
Special thanks to:
Carlo Bramini
hwt0415
Roland Illig
Samanta Navarro
and
Clang LeakSan and the Clang team
Release 2.4.3 Sun January 16 2022
Security fixes:
#531 #534 CVE-2021-45960 -- Fix issues with left shifts by >=29 places
resulting in
a) realloc acting as free
b) realloc allocating too few bytes
c) undefined behavior
depending on architecture and precise value
for XML documents with >=2^27+1 prefixed attributes
on a single XML tag a la
"<r xmlns:a='[..]' a:a123='[..]' [..] />"
where XML_ParserCreateNS is used to create the parser
(which needs argument "-n" when running xmlwf).
Impact is denial of service, or more.
#532 #538 CVE-2021-46143 (ZDI-CAN-16157) -- Fix integer overflow
on variable m_groupSize in function doProlog leading
to realloc acting as free.
Impact is denial of service or more.
#539 CVE-2022-22822 to CVE-2022-22827 -- Prevent integer overflows
near memory allocation at multiple places. Mitre assigned
a dedicated CVE for each involved internal C function:
- CVE-2022-22822 for function addBinding
- CVE-2022-22823 for function build_model
- CVE-2022-22824 for function defineAttribute
- CVE-2022-22825 for function lookup
- CVE-2022-22826 for function nextScaffoldPart
- CVE-2022-22827 for function storeAtts
Impact is denial of service or more.
Other changes:
#535 CMake: Make call to file(GENERATE [..]) work for CMake <3.19
#541 Autotools|CMake: MinGW: Make run.sh(.in) work for Cygwin
and MSYS2 by not going through Wine on these platforms
#527 #528 Address compiler warnings
#533 #543 Version info bumped from 9:2:8 to 9:3:8;
see https://verbump.de/ for what these numbers do
Infrastructure:
#536 CI: Check for realistic minimum CMake version
#529 #539 CI: Cover compilation with -m32
#529 CI: Store coverage reports as artifacts for download
#528 CI: Upgrade Clang from 11 to 13
Special thanks to:
An anonymous whitehat
Christopher Degawa
J. Peter Mugaas
Tyson Smith
and
GCC Farm Project
Trend Micro Zero Day Initiative
Release 2.4.2 Sun December 19 2021
Other changes:
#509 #510 Link againgst libm for function "isnan"
#513 #514 Include expat_config.h as early as possible
#498 Autotools: Include files with release archives:
- buildconf.sh
- fuzz/*.c
#507 #519 Autotools: Sync CMake templates
#495 #524 CMake: MinGW: Fix pkg-config section "Libs" for
- non-release build types (e.g. -DCMAKE_BUILD_TYPE=Debug)
- multi-config CMake generators (e.g. Ninja Multi-Config)
#502 #503 docs: Document that function XML_GetBuffer may return NULL
when asking for a buffer of 0 (zero) bytes size
#522 #523 docs: Fix return value docs for both
XML_SetBillionLaughsAttackProtection* functions
#525 #526 Version info bumped from 9:1:8 to 9:2:8;
see https://verbump.de/ for what these numbers do
Special thanks to:
Dong-hee Na
Joergen Ibsen
Kai Pastor
Release 2.4.1 Sun May 23 2021
Bug fixes:
#488 #490 Autotools: Fix installed header expat_config.h for multilib
systems; regression introduced in 2.4.0 by pull request #486
Other changes:
#491 #492 Version info bumped from 9:0:8 to 9:1:8;
see https://verbump.de/ for what these numbers do
Special thanks to:
Gentoo's QA check "multilib_check_headers"
Release 2.4.0 Sun May 23 2021
Security fixes:
#34 #466 #484 CVE-2013-0340/CWE-776 -- Protect against billion laughs attacks
(denial-of-service; flavors targeting CPU time or RAM or both,
leveraging general entities or parameter entities or both)
by tracking and limiting the input amplification factor
(<amplification> := (<direct> + <indirect>) / <direct>).
By conservative default, amplification up to a factor of 100.0
is tolerated and rejection only starts after 8 MiB of output bytes
(=<direct> + <indirect>) have been processed.
The fix adds the following to the API:
- A new error code XML_ERROR_AMPLIFICATION_LIMIT_BREACH to
signals this specific condition.
- Two new API functions ..
- XML_SetBillionLaughsAttackProtectionMaximumAmplification and
- XML_SetBillionLaughsAttackProtectionActivationThreshold
.. to further tighten billion laughs protection parameters
when desired. Please see file "doc/reference.html" for details.
If you ever need to increase the defaults for non-attack XML
payload, please file a bug report with libexpat.
- Two new XML_FEATURE_* constants ..
- that can be queried using the XML_GetFeatureList function, and
- that are shown in "xmlwf -v" output.
- Two new environment variable switches ..
- EXPAT_ACCOUNTING_DEBUG=(0|1|2|3) and
- EXPAT_ENTITY_DEBUG=(0|1)
.. for runtime debugging of accounting and entity processing.
Specific behavior of these values may change in the future.
- Two new command line arguments "-a FACTOR" and "-b BYTES"
for xmlwf to further tighten billion laughs protection
parameters when desired.
If you ever need to increase the defaults for non-attack XML
payload, please file a bug report with libexpat.
Bug fixes:
#332 #470 For (non-default) compilation with -DEXPAT_MIN_SIZE=ON (CMake)
or CPPFLAGS=-DXML_MIN_SIZE (GNU Autotools): Fix segfault
for UTF-16 payloads containing CDATA sections.
#485 #486 Autotools: Fix generated CMake files for non-64bit and
non-Linux platforms (e.g. macOS and MinGW in particular)
that were introduced with release 2.3.0
Other changes:
#468 #469 xmlwf: Improve help output and the xmlwf man page
#463 xmlwf: Improve maintainability through some refactoring
#477 xmlwf: Fix man page DocBook validity
#458 #459 CMake: Support absolute paths for both CMAKE_INSTALL_LIBDIR
and CMAKE_INSTALL_INCLUDEDIR
#471 #481 CMake: Add support for standard variable BUILD_SHARED_LIBS
#457 Unexpose symbol _INTERNAL_trim_to_complete_utf8_characters
#467 Resolve macro HAVE_EXPAT_CONFIG_H
#472 Delete unused legacy helper file "conftools/PrintPath"
#473 #483 Improve attribution
#464 #465 #477 doc/reference.html: Fix XHTML validity
#475 #478 doc/reference.html: Replace the 90s look by OK.css
#479 Version info bumped from 8:0:7 to 9:0:8
due to addition of new symbols and error codes;
see https://verbump.de/ for what these numbers do
Infrastructure:
#456 CI: Enable periodic runs
#457 CI: Start covering the list of exported symbols
#474 CI: Isolate coverage task
#476 #482 CI: Adapt to breaking changes in image "ubuntu-18.04"
#477 CI: Cover well-formedness and DocBook/XHTML validity
of doc/reference.html and doc/xmlwf.xml
Special thanks to:
Dimitry Andric
Eero Helenius
Nick Wellnhofer
Rhodri James
Tomas Korbar
Yury Gribov
and
Clang LeakSan
JetBrains
OSS-Fuzz
Release 2.3.0 Thu March 25 2021
Bug fixes:
#438 When calling XML_ParseBuffer without a prior successful call to
XML_GetBuffer as a user, no longer trigger undefined behavior
(by adding an integer to a NULL pointer) but rather return
XML_STATUS_ERROR and set the error code to (new) code
XML_ERROR_NO_BUFFER. Found by UBSan (UndefinedBehaviorSanitizer)
of Clang 11 (but not Clang 9).
#444 xmlwf: Exit status 2 was used for both:
- malformed input files (documented) and
- invalid command-line arguments (undocumented).
The case of invalid command-line arguments now
has its own exit status 4, resolving the ambiguity.
Other changes:
#439 xmlwf: Add argument -k to allow continuing after
non-fatal errors
#439 xmlwf: Add section about exit status to the -h help output
#422 #426 #447 Windows: Drop support for Visual Studio <=14.0/2015
#434 Windows: CMake: Detect unsupported Visual Studio at
configure time (rather than at compile time)
#382 #428 testrunner: Make verbose mode (argument "-v") report
about passed tests, and make default mode report about
failures, as well.
#442 CMake: Call "enable_language(CXX)" prior to tinkering
with CMAKE_CXX_* variables
#448 Document use of libexpat from a CMake-based project
#451 Autotools: Install CMake files as generated by CMake 3.19.6
so that users with "find_package(expat [..] CONFIG [..])"
are served on distributions that are *not* using the CMake
build system inside for libexpat packaging
#436 #437 Autotools: Drop obsolescent macro AC_HEADER_STDC
#450 #452 Autotools: Resolve use of obsolete macro AC_CONFIG_HEADER
#441 Address compiler warnings
#443 Version info bumped from 7:12:6 to 8:0:7
due to addition of error code XML_ERROR_NO_BUFFER
(see https://verbump.de/ for what these numbers do)
Infrastructure:
#435 #446 Replace Travis CI by GitHub Actions
Special thanks to:
Alexander Richardson
Oleksandr Popovych
Thomas Beutlich
Tim Bray
and
Clang LeakSan, Clang 11 UBSan and the Clang team
Release 2.2.10 Sat October 3 2020
Bug fixes:
#390 #395 #398 Fix undefined behavior during parsing caused by
pointer arithmetic with NULL pointers
#404 #405 Fix reading uninitialized variable during parsing
#406 xmlwf: Add missing check for malloc NULL return
Other changes:
#396 Windows: Drop support for Visual Studio <=8.0/2005
#409 Windows: Add missing file "Changes" to the installer
to fix compilation with CMake from installed sources
#403 xmlwf: Document exit codes in xmlwf manpage and
exit with code 3 (rather than code 1) for output errors
when used with "-d DIRECTORY"
#356 #359 MinGW: Provide declaration of rand_s for mingwrt <5.3.0
#383 #392 Autotools: Use -Werror while configure tests the compiler
for supported compile flags to avoid false positives
#383 #393 #394 Autotools: Improve handling of user (C|CPP|CXX|LD)FLAGS,
e.g. ensure that they have the last word over flags added
while running ./configure
#360 CMake: Create libexpatw.{dll,so} and expatw.pc (with emphasis
on suffix "w") with -DEXPAT_CHAR_TYPE=(ushort|wchar_t)
#360 CMake: Detect and deny unsupported build combinations
involving -DEXPAT_CHAR_TYPE=(ushort|wchar_t)
#360 CMake: Install pre-compiled shipped xmlwf.1 manpage in case
of -DEXPAT_BUILD_DOCS=OFF
#375 #380 #419 CMake: Fix use of Expat by means of add_subdirectory
#407 #408 CMake: Keep expat target name constant at "expat"
(i.e. refrain from using the target name to control
build artifact filenames)
#385 CMake: Fix compilation with -DEXPAT_SHARED_LIBS=OFF for
Windows
CMake: Expose man page compilation as target "xmlwf-manpage"
#413 #414 CMake: Introduce option EXPAT_BUILD_PKGCONFIG
to control generation of pkg-config file "expat.pc"
#424 CMake: Add minimalistic support for building binary packages
with CMake target "package"; based on CPack
#366 CMake: Add option -DEXPAT_OSSFUZZ_BUILD=(ON|OFF) with
default OFF to build fuzzer code against OSS-Fuzz and
related environment variable LIB_FUZZING_ENGINE
#354 Fix testsuite for -DEXPAT_DTD=OFF and -DEXPAT_NS=OFF, each
#354 #355 ..
#356 #412 Address compiler warnings
#368 #369 Address pngcheck warnings with doc/*.png images
#425 Version info bumped from 7:11:6 to 7:12:6
Special thanks to:
asavah
Ben Wagner
Bhargava Shastry
Frank Landgraf
Jeffrey Walton
Joe Orton
Kleber Tarcísio
Ma Lin
Maciej Sroczyński
Mohammed Khajapasha
Vadim Zeitlin
and
Cppcheck 2.0 and the Cppcheck team
Release 2.2.9 Wed September 25 2019
Other changes:
examples: Drop executable bits from elements.c
#349 Windows: Change the name of the Windows DLLs from expat*.dll
@@ -17,7 +422,7 @@ Release 2.2.9 Wed Septemper 25 2019
Special thanks to:
Ben Wagner
Release 2.2.8 Fri Septemper 13 2019
Release 2.2.8 Fri September 13 2019
Security fixes:
#317 #318 CVE-2019-15903 -- Fix heap overflow triggered by
XML_GetCurrentLineNumber (or XML_GetCurrentColumnNumber),
@@ -115,10 +520,10 @@ Release 2.2.8 Fri Septemper 13 2019
Special thanks to:
David Loffredo
Joonun Jang
Khajapasha Mohammed
Kishore Kunche
Marco Maggi
Mitch Phillips
Mohammed Khajapasha
Rolf Ade
xantares
Zhongyuan Zhou
+25 -4
View File
@@ -6,7 +6,9 @@
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2017 Expat development team
# Copyright (c) 2017-2021 Sebastian Pipping <[email protected]>
# Copyright (c) 2018 KangLin <[email protected]>
# Copyright (c) 2022 Johnny Jazeix <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
@@ -53,20 +55,36 @@ pkgconfig_DATA = expat.pc
pkgconfigdir = $(libdir)/pkgconfig
dist_cmake_DATA = \
cmake/autotools/expat.cmake
nodist_cmake_DATA = \
cmake/autotools/expat-config-version.cmake \
cmake/autotools/expat-noconfig.cmake \
cmake/expat-config.cmake
cmakedir = $(libdir)/cmake/expat-@PACKAGE_VERSION@
_EXTRA_DIST_CMAKE = \
cmake/expat-config.cmake.in \
cmake/autotools/expat-noconfig__linux.cmake.in \
cmake/autotools/expat-noconfig__macos.cmake.in \
cmake/autotools/expat-noconfig__windows.cmake.in \
cmake/autotools/expat-package-init.cmake \
cmake/mingw-toolchain.cmake \
\
CMakeLists.txt \
CMake.README \
ConfigureChecks.cmake \
expat.pc.cmake \
expat_config.h.cmake
_EXTRA_DIST_WINDOWS = \
win32/build_expat_iss.bat \
win32/expat.iss \
win32/MANIFEST.txt \
win32/README.txt
win32/README.txt \
win32/version.rc
EXTRA_DIST = \
$(_EXTRA_DIST_CMAKE) \
@@ -74,11 +92,14 @@ EXTRA_DIST = \
\
conftools/expat.m4 \
conftools/get-version.sh \
conftools/PrintPath \
\
fuzz/xml_parsebuffer_fuzzer.c \
fuzz/xml_parse_fuzzer.c \
\
xmlwf/xmlwf_helpgen.py \
xmlwf/xmlwf_helpgen.sh \
\
buildconf.sh \
Changes \
README.md \
\
+134 -32
View File
@@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.16.1 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -22,7 +22,9 @@
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2017 Expat development team
# Copyright (c) 2017-2021 Sebastian Pipping <[email protected]>
# Copyright (c) 2018 KangLin <[email protected]>
# Copyright (c) 2022 Johnny Jazeix <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
@@ -138,12 +140,14 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
$(am__configure_deps) $(am__DIST_COMMON)
$(am__configure_deps) $(dist_cmake_DATA) $(am__DIST_COMMON)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = expat_config.h
CONFIG_CLEAN_FILES = expat.pc run.sh
CONFIG_CLEAN_FILES = expat.pc cmake/expat-config.cmake \
cmake/autotools/expat-config-version.cmake \
cmake/autotools/expat-noconfig.cmake run.sh
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@@ -199,8 +203,9 @@ am__uninstall_files_from_dir = { \
|| { echo " ( cd '$$dir' && rm -f" $$files ")"; \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(pkgconfigdir)"
DATA = $(pkgconfig_DATA)
am__installdirs = "$(DESTDIR)$(cmakedir)" "$(DESTDIR)$(cmakedir)" \
"$(DESTDIR)$(pkgconfigdir)"
DATA = $(dist_cmake_DATA) $(nodist_cmake_DATA) $(pkgconfig_DATA)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
@@ -209,8 +214,8 @@ am__recursive_targets = \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
cscope distdir distdir-am dist dist-all distcheck
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
$(LISP)expat_config.h.in
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \
expat_config.h.in
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
@@ -227,18 +232,17 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
CSCOPE = cscope
DIST_SUBDIRS = lib examples tests xmlwf doc
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/expat.pc.in \
$(srcdir)/expat_config.h.in $(srcdir)/run.sh.in \
$(top_srcdir)/cmake/autotools/expat-config-version.cmake.in \
$(top_srcdir)/cmake/expat-config.cmake.in \
$(top_srcdir)/conftools/ar-lib $(top_srcdir)/conftools/compile \
$(top_srcdir)/conftools/config.guess \
$(top_srcdir)/conftools/config.sub \
$(top_srcdir)/conftools/install-sh \
$(top_srcdir)/conftools/ltmain.sh \
$(top_srcdir)/conftools/missing AUTHORS COPYING \
$(top_srcdir)/conftools/missing AUTHORS COPYING README.md \
conftools/ar-lib conftools/compile conftools/config.guess \
conftools/config.sub conftools/depcomp conftools/install-sh \
conftools/ltmain.sh conftools/missing
@@ -281,13 +285,19 @@ DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.bz2 $(distdir).tar.lz \
$(distdir).tar.xz
GZIP_ENV = --best
DIST_TARGETS = dist-lzip dist-xz dist-bzip2 dist-gzip
# Exists only to be overridden by the user if desired.
AM_DISTCHECK_DVI_TARGET = dvi
distuninstallcheck_listfiles = find . -type f -print
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_CFLAGS = @AM_CFLAGS@
AM_CPPFLAGS = @AM_CPPFLAGS@
AM_CXXFLAGS = @AM_CXXFLAGS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AM_LDFLAGS = @AM_LDFLAGS@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
@@ -297,8 +307,10 @@ AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CMAKE_SHARED_LIBRARY_PREFIX = @CMAKE_SHARED_LIBRARY_PREFIX@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
@@ -314,7 +326,15 @@ ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
EXPAT_ATTR_INFO = @EXPAT_ATTR_INFO@
EXPAT_CHAR_TYPE = @EXPAT_CHAR_TYPE@
EXPAT_CONTEXT_BYTES = @EXPAT_CONTEXT_BYTES@
EXPAT_DTD = @EXPAT_DTD@
EXPAT_LARGE_SIZE = @EXPAT_LARGE_SIZE@
EXPAT_MIN_SIZE = @EXPAT_MIN_SIZE@
EXPAT_NS = @EXPAT_NS@
FGREP = @FGREP@
FILEMAP = @FILEMAP@
GREP = @GREP@
@@ -327,6 +347,8 @@ LD = @LD@
LDFLAGS = @LDFLAGS@
LIBAGE = @LIBAGE@
LIBCURRENT = @LIBCURRENT@
LIBDIR_BASENAME = @LIBDIR_BASENAME@
LIBM = @LIBM@
LIBOBJS = @LIBOBJS@
LIBREVISION = @LIBREVISION@
LIBS = @LIBS@
@@ -356,6 +378,9 @@ RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SO_MAJOR = @SO_MAJOR@
SO_MINOR = @SO_MINOR@
SO_PATCH = @SO_PATCH@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
@@ -366,6 +391,7 @@ ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
ac_cv_sizeof_void_p = @ac_cv_sizeof_void_p@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -403,6 +429,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -423,20 +450,34 @@ LIBTOOLFLAGS = --verbose
SUBDIRS = lib $(am__append_1) $(am__append_2) $(am__append_3)
pkgconfig_DATA = expat.pc
pkgconfigdir = $(libdir)/pkgconfig
dist_cmake_DATA = \
cmake/autotools/expat.cmake
nodist_cmake_DATA = \
cmake/autotools/expat-config-version.cmake \
cmake/autotools/expat-noconfig.cmake \
cmake/expat-config.cmake
cmakedir = $(libdir)/cmake/expat-@PACKAGE_VERSION@
_EXTRA_DIST_CMAKE = \
cmake/expat-config.cmake.in \
cmake/autotools/expat-noconfig__linux.cmake.in \
cmake/autotools/expat-noconfig__macos.cmake.in \
cmake/autotools/expat-noconfig__windows.cmake.in \
cmake/autotools/expat-package-init.cmake \
cmake/mingw-toolchain.cmake \
\
CMakeLists.txt \
CMake.README \
ConfigureChecks.cmake \
expat.pc.cmake \
expat_config.h.cmake
_EXTRA_DIST_WINDOWS = \
win32/build_expat_iss.bat \
win32/expat.iss \
win32/MANIFEST.txt \
win32/README.txt
win32/README.txt \
win32/version.rc
EXTRA_DIST = \
$(_EXTRA_DIST_CMAKE) \
@@ -444,11 +485,14 @@ EXTRA_DIST = \
\
conftools/expat.m4 \
conftools/get-version.sh \
conftools/PrintPath \
\
fuzz/xml_parsebuffer_fuzzer.c \
fuzz/xml_parse_fuzzer.c \
\
xmlwf/xmlwf_helpgen.py \
xmlwf/xmlwf_helpgen.sh \
\
buildconf.sh \
Changes \
README.md \
\
@@ -509,6 +553,12 @@ distclean-hdr:
-rm -f expat_config.h stamp-h1
expat.pc: $(top_builddir)/config.status $(srcdir)/expat.pc.in
cd $(top_builddir) && $(SHELL) ./config.status $@
cmake/expat-config.cmake: $(top_builddir)/config.status $(top_srcdir)/cmake/expat-config.cmake.in
cd $(top_builddir) && $(SHELL) ./config.status $@
cmake/autotools/expat-config-version.cmake: $(top_builddir)/config.status $(top_srcdir)/cmake/autotools/expat-config-version.cmake.in
cd $(top_builddir) && $(SHELL) ./config.status $@
cmake/autotools/expat-noconfig.cmake: $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status $@
run.sh: $(top_builddir)/config.status $(srcdir)/run.sh.in
cd $(top_builddir) && $(SHELL) ./config.status $@
@@ -520,6 +570,48 @@ clean-libtool:
distclean-libtool:
-rm -f libtool config.lt
install-dist_cmakeDATA: $(dist_cmake_DATA)
@$(NORMAL_INSTALL)
@list='$(dist_cmake_DATA)'; test -n "$(cmakedir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(cmakedir)'"; \
$(MKDIR_P) "$(DESTDIR)$(cmakedir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(cmakedir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(cmakedir)" || exit $$?; \
done
uninstall-dist_cmakeDATA:
@$(NORMAL_UNINSTALL)
@list='$(dist_cmake_DATA)'; test -n "$(cmakedir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(cmakedir)'; $(am__uninstall_files_from_dir)
install-nodist_cmakeDATA: $(nodist_cmake_DATA)
@$(NORMAL_INSTALL)
@list='$(nodist_cmake_DATA)'; test -n "$(cmakedir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(cmakedir)'"; \
$(MKDIR_P) "$(DESTDIR)$(cmakedir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
echo "$$d$$p"; \
done | $(am__base_list) | \
while read files; do \
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(cmakedir)'"; \
$(INSTALL_DATA) $$files "$(DESTDIR)$(cmakedir)" || exit $$?; \
done
uninstall-nodist_cmakeDATA:
@$(NORMAL_UNINSTALL)
@list='$(nodist_cmake_DATA)'; test -n "$(cmakedir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(cmakedir)'; $(am__uninstall_files_from_dir)
install-pkgconfigDATA: $(pkgconfig_DATA)
@$(NORMAL_INSTALL)
@list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
@@ -647,7 +739,6 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
@@ -728,6 +819,10 @@ dist-xz: distdir
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
$(am__post_remove_distdir)
dist-zstd: distdir
tardir=$(distdir) && $(am__tar) | zstd -c $${ZSTD_CLEVEL-$${ZSTD_OPT--19}} >$(distdir).tar.zst
$(am__post_remove_distdir)
dist-tarZ: distdir
@echo WARNING: "Support for distribution archives compressed with" \
"legacy program 'compress' is deprecated." >&2
@@ -770,6 +865,8 @@ distcheck: dist
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
*.tar.zst*) \
zstd -dc $(distdir).tar.zst | $(am__untar) ;;\
esac
chmod -R a-w $(distdir)
chmod u+w $(distdir)
@@ -785,7 +882,7 @@ distcheck: dist
$(DISTCHECK_CONFIGURE_FLAGS) \
--srcdir=../.. --prefix="$$dc_install_base" \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) $(AM_DISTCHECK_DVI_TARGET) \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
@@ -841,7 +938,7 @@ check: check-recursive
all-am: Makefile $(DATA) expat_config.h
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(pkgconfigdir)"; do \
for dir in "$(DESTDIR)$(cmakedir)" "$(DESTDIR)$(cmakedir)" "$(DESTDIR)$(pkgconfigdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-recursive
@@ -896,7 +993,8 @@ info: info-recursive
info-am:
install-data-am: install-pkgconfigDATA
install-data-am: install-dist_cmakeDATA install-nodist_cmakeDATA \
install-pkgconfigDATA
install-dvi: install-dvi-recursive
@@ -942,7 +1040,8 @@ ps: ps-recursive
ps-am:
uninstall-am: uninstall-pkgconfigDATA
uninstall-am: uninstall-dist_cmakeDATA uninstall-nodist_cmakeDATA \
uninstall-pkgconfigDATA
.MAKE: $(am__recursive_targets) all install-am install-strip
@@ -950,18 +1049,21 @@ uninstall-am: uninstall-pkgconfigDATA
am--refresh check check-am clean clean-cscope clean-generic \
clean-libtool cscope cscopelist-am ctags ctags-am dist \
dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \
dist-xz dist-zip distcheck distclean distclean-generic \
distclean-hdr distclean-libtool distclean-tags distcleancheck \
distdir distuninstallcheck dvi dvi-am html html-am info \
info-am install install-am install-data install-data-am \
dist-xz dist-zip dist-zstd distcheck distclean \
distclean-generic distclean-hdr distclean-libtool \
distclean-tags distcleancheck distdir distuninstallcheck dvi \
dvi-am html html-am info info-am install install-am \
install-data install-data-am install-dist_cmakeDATA \
install-dvi install-dvi-am install-exec install-exec-am \
install-html install-html-am install-info install-info-am \
install-man install-pdf install-pdf-am install-pkgconfigDATA \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic \
mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \
uninstall-am uninstall-pkgconfigDATA
install-man install-nodist_cmakeDATA install-pdf \
install-pdf-am install-pkgconfigDATA install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
installdirs-am maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
ps ps-am tags tags-am uninstall uninstall-am \
uninstall-dist_cmakeDATA uninstall-nodist_cmakeDATA \
uninstall-pkgconfigDATA
.PRECIOUS: Makefile
+89 -8
View File
@@ -1,12 +1,14 @@
[![Travis CI Build Status](https://travis-ci.org/libexpat/libexpat.svg?branch=master)](https://travis-ci.org/libexpat/libexpat)
[![Run Linux Travis CI tasks](https://github.com/libexpat/libexpat/actions/workflows/linux.yml/badge.svg)](https://github.com/libexpat/libexpat/actions/workflows/linux.yml)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/libexpat/libexpat?svg=true)](https://ci.appveyor.com/project/libexpat/libexpat)
[![Packaging status](https://repology.org/badge/tiny-repos/expat.svg)](https://repology.org/metapackage/expat/versions)
[![Downloads SourceForge](https://img.shields.io/sourceforge/dt/expat?label=Downloads%20SourceForge)](https://sourceforge.net/projects/expat/files/)
[![Downloads GitHub](https://img.shields.io/github/downloads/libexpat/libexpat/total?label=Downloads%20GitHub)](https://github.com/libexpat/libexpat/releases)
# Expat, Release 2.2.9
# Expat, Release 2.4.7
This is Expat, a C library for parsing XML, started by
[James Clark](https://en.wikipedia.org/wiki/James_Clark_(programmer)) in 1997.
[James Clark](https://en.wikipedia.org/wiki/James_Clark_%28programmer%29) in 1997.
Expat is a stream-oriented XML parser. This means that you register
handlers with the parser before starting the parse. These handlers
are called when the parser discovers the associated structures in the
@@ -14,13 +16,14 @@ document being parsed. A start tag is an example of the kind of
structures for which you may register handlers.
Expat supports the following compilers:
- GNU GCC >=4.5
- LLVM Clang >=3.5
- Microsoft Visual Studio >=8.0/2005
- Microsoft Visual Studio >=15.0/2017 (rolling `${today} minus 5 years`)
Windows users should use the
[`expat_win32` package](https://sourceforge.net/projects/expat/files/expat_win32/),
which includes both precompiled libraries and executables, and source code for
Windows users can use the
[`expat-win32bin-*.*.*.{exe,zip}` download](https://github.com/libexpat/libexpat/releases),
which includes both pre-compiled libraries and executables, and source code for
developers.
Expat is [free software](https://www.gnu.org/philosophy/free-sw.en.html).
@@ -30,6 +33,67 @@ contained in the file
distributed with this package.
This license is the same as the MIT/X Consortium license.
## Using libexpat in your CMake-Based Project
There are two ways of using libexpat with CMake:
### a) Module Mode
This approach leverages CMake's own [module `FindEXPAT`](https://cmake.org/cmake/help/latest/module/FindEXPAT.html).
Notice the *uppercase* `EXPAT` in the following example:
```cmake
cmake_minimum_required(VERSION 3.0) # or 3.10, see below
project(hello VERSION 1.0.0)
find_package(EXPAT 2.2.8 MODULE REQUIRED)
add_executable(hello
hello.c
)
# a) for CMake >=3.10 (see CMake's FindEXPAT docs)
target_link_libraries(hello PUBLIC EXPAT::EXPAT)
# b) for CMake >=3.0
target_include_directories(hello PRIVATE ${EXPAT_INCLUDE_DIRS})
target_link_libraries(hello PUBLIC ${EXPAT_LIBRARIES})
```
### b) Config Mode
This approach requires files from…
- libexpat >=2.2.8 where packaging uses the CMake build system
or
- libexpat >=2.3.0 where packaging uses the GNU Autotools build system
on Linux
or
- libexpat >=2.4.0 where packaging uses the GNU Autotools build system
on macOS or MinGW.
Notice the *lowercase* `expat` in the following example:
```cmake
cmake_minimum_required(VERSION 3.0)
project(hello VERSION 1.0.0)
find_package(expat 2.2.8 CONFIG REQUIRED char dtd ns)
add_executable(hello
hello.c
)
target_link_libraries(hello PUBLIC expat::expat)
```
## Building from a Git Clone
If you are building Expat from a check-out from the
[Git repository](https://github.com/libexpat/libexpat/),
you need to run a script that generates the configure script using the
@@ -43,6 +107,11 @@ autoconf 2.58 or newer. Run the script like this:
Once this has been done, follow the same instructions as for building
from a source distribution.
## Building from a Source Distribution
### a) Building with the configure script (i.e. GNU Autotools)
To build Expat from a source distribution, you first run the
configuration shell script in the top level distribution directory:
@@ -132,8 +201,14 @@ A reference manual is available in the file `doc/reference.html` in this
distribution.
The CMake build system is still *experimental* and will replace the primary
### b) Building with CMake
The CMake build system is still *experimental* and may replace the primary
build system based on GNU Autotools at some point when it is ready.
#### Available Options
For an idea of the available (non-advanced) options for building with CMake:
```console
@@ -156,6 +231,9 @@ EXPAT_BUILD_EXAMPLES:BOOL=ON
// build fuzzers for the expat library
EXPAT_BUILD_FUZZERS:BOOL=OFF
// build pkg-config file
EXPAT_BUILD_PKGCONFIG:BOOL=ON
// build the tests for expat library
EXPAT_BUILD_TESTS:BOOL=ON
@@ -171,6 +249,9 @@ EXPAT_ENABLE_INSTALL:BOOL=ON
// Use /MT flag (static CRT) when compiling in MSVC
EXPAT_MSVC_STATIC_CRT:BOOL=OFF
// build fuzzers via ossfuzz for the expat library
EXPAT_OSSFUZZ_BUILD:BOOL=OFF
// build a shared expat library
EXPAT_SHARED_LIBS:BOOL=ON
+55
View File
@@ -0,0 +1,55 @@
#! /usr/bin/env bash
# __ __ _
# ___\ \/ /_ __ __ _| |_
# / _ \\ /| '_ \ / _` | __|
# | __// \| |_) | (_| | |_
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2017-2021 Sebastian Pipping <[email protected]>
# Copyright (c) 2018 Marco Maggi <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the
# following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
# NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
# USE OR OTHER DEALINGS IN THE SOFTWARE.
set -e
# File expat_config.h.in (as generated by autoheader by autoreconf) contains
# macro SIZEOF_VOID_P which is (1) not really needed by Expat as of today and
# (2) a problem to "multilib" systems with one shared installed
# /usr/include/expat_config.h for two Expats with different "void *" sizes
# installed in e.g. /usr/lib32 and /usr/lib64. Hence we patch macro
# SIZEOF_VOID_P out of template expat_config.h.in so that configure will
# not put SIZEOF_VOID_P in the eventual expat_config.h.
patch_expat_config_h_in() {
local filename="$1"
local sizeof_void_p_line_number="$(fgrep -n SIZEOF_VOID_P "${filename}" | awk -F: '{print $1}')"
[[ ${sizeof_void_p_line_number} =~ ^[0-9]+$ ]] # cheap assert
local first_line_to_delete=$(( sizeof_void_p_line_number - 1 ))
local last_line_to_delete=$(( sizeof_void_p_line_number + 1 ))
# Note: Avoiding "sed -i" only for macOS portability.
local tempfile="$(mktemp)"
sed "${first_line_to_delete},${last_line_to_delete}d" "${filename}" > "${tempfile}"
mv "${tempfile}" "${filename}"
}
autoreconf --warnings=all --install --verbose "$@"
patch_expat_config_h_in expat_config.h.in
+146 -28
View File
@@ -1,21 +1,54 @@
dnl configuration script for expat
dnl Process this file with autoconf to produce a configure script.
dnl __ __ _
dnl ___\ \/ /_ __ __ _| |_
dnl / _ \\ /| '_ \ / _` | __|
dnl | __// \| |_) | (_| | |_
dnl \___/_/\_\ .__/ \__,_|\__|
dnl |_| XML parser
dnl
dnl Copyright 2000 Clark Cooper
dnl Copyright (c) 2000 Clark Cooper <[email protected]>
dnl Copyright (c) 2000-2005 Fred L. Drake, Jr. <[email protected]>
dnl Copyright (c) 2001-2003 Greg Stein <[email protected]>
dnl Copyright (c) 2006-2012 Karl Waclawek <[email protected]>
dnl Copyright (c) 2016-2022 Sebastian Pipping <[email protected]>
dnl Copyright (c) 2017 S. P. Zeidler <[email protected]>
dnl Copyright (c) 2017 Stephen Groat <[email protected]>
dnl Copyright (c) 2017-2020 Joe Orton <[email protected]>
dnl Copyright (c) 2018 Yury Gribov <[email protected]>
dnl Copyright (c) 2018 Benjamin Peterson <[email protected]>
dnl Copyright (c) 2018 Marco Maggi <[email protected]>
dnl Copyright (c) 2018 KangLin <[email protected]>
dnl Copyright (c) 2019 Mohammed Khajapasha <[email protected]>
dnl Copyright (c) 2019 Kishore Kunche <[email protected]>
dnl Copyright (c) 2020 Jeffrey Walton <[email protected]>
dnl Licensed under the MIT license:
dnl
dnl This file is part of EXPAT.
dnl Permission is hereby granted, free of charge, to any person obtaining
dnl a copy of this software and associated documentation files (the
dnl "Software"), to deal in the Software without restriction, including
dnl without limitation the rights to use, copy, modify, merge, publish,
dnl distribute, sublicense, and/or sell copies of the Software, and to permit
dnl persons to whom the Software is furnished to do so, subject to the
dnl following conditions:
dnl
dnl EXPAT is free software; you can redistribute it and/or modify it
dnl under the terms of the License (based on the MIT/X license) contained
dnl in the file COPYING that comes with this distribution.
dnl The above copyright notice and this permission notice shall be included
dnl in all copies or substantial portions of the Software.
dnl
dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
dnl EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
dnl NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
dnl USE OR OTHER DEALINGS IN THE SOFTWARE.
dnl Ensure that Expat is configured with autoconf 2.69 or newer.
AC_PREREQ(2.69)
AC_PREREQ([2.69])
dnl Get the version number of Expat, using m4's esyscmd() command to run
dnl the command at m4-generation time. This allows us to create an m4
dnl symbol holding the correct version number. AC_INIT() requires the
dnl symbol holding the correct version number. AC_INIT requires the
dnl version number at m4-time, rather than when ./configure is run, so
dnl all this must happen as part of m4, not as part of the shell code
dnl contained in ./configure.
@@ -27,7 +60,7 @@ m4_define([expat_version],
m4_ifdef([__gnu__],
[esyscmd(conftools/get-version.sh lib/expat.h)],
[2.2.x]))
AC_INIT(expat, expat_version, [email protected])
AC_INIT([expat], expat_version, [[email protected]])
m4_undefine([expat_version])
AC_CONFIG_SRCDIR([Makefile.in])
@@ -48,12 +81,11 @@ dnl
dnl If the API changes incompatibly set LIBAGE back to 0
dnl
LIBCURRENT=7 # sync
LIBREVISION=11 # with
LIBAGE=6 # CMakeLists.txt!
LIBCURRENT=9 # sync
LIBREVISION=7 # with
LIBAGE=8 # CMakeLists.txt!
AX_APPEND_FLAG([-DHAVE_EXPAT_CONFIG_H], [CPPFLAGS])
AC_CONFIG_HEADER([expat_config.h])
AC_CONFIG_HEADERS([expat_config.h])
AM_PROG_AR
AC_PROG_INSTALL
@@ -69,30 +101,32 @@ AC_SUBST(LIBAGE)
AC_LANG([C])
AC_PROG_CC_C99
AS_IF([test "$GCC" = yes],
[AX_APPEND_COMPILE_FLAGS([-Wall -Wextra], [CFLAGS])
[AX_APPEND_COMPILE_FLAGS([-Wall -Wextra], [AM_CFLAGS])
dnl Be careful about adding the -fexceptions option; some versions of
dnl GCC don't support it and it causes extra warnings that are only
dnl distracting; avoid.
AX_APPEND_COMPILE_FLAGS([-fexceptions], [CFLAGS])
AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing -Wmissing-prototypes -Wstrict-prototypes], [CFLAGS])
AX_APPEND_COMPILE_FLAGS([-pedantic -Wduplicated-cond -Wduplicated-branches -Wlogical-op], [CFLAGS])
AX_APPEND_COMPILE_FLAGS([-Wrestrict -Wnull-dereference -Wjump-misses-init -Wdouble-promotion], [CFLAGS])
AX_APPEND_COMPILE_FLAGS([-Wshadow -Wformat=2 -Wmisleading-indentation], [CFLAGS])])
AX_APPEND_COMPILE_FLAGS([-fexceptions], [AM_CFLAGS])
AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing -Wmissing-prototypes -Wstrict-prototypes], [AM_CFLAGS])
AX_APPEND_COMPILE_FLAGS([-pedantic -Wduplicated-cond -Wduplicated-branches -Wlogical-op], [AM_CFLAGS])
AX_APPEND_COMPILE_FLAGS([-Wrestrict -Wnull-dereference -Wjump-misses-init -Wdouble-promotion], [AM_CFLAGS])
AX_APPEND_COMPILE_FLAGS([-Wshadow -Wformat=2 -Wno-pedantic-ms-format -Wmisleading-indentation], [AM_CFLAGS])])
AC_LANG_PUSH([C++])
AC_PROG_CXX
AS_IF([test "$GCC" = yes],
[AX_APPEND_COMPILE_FLAGS([-Wall -Wextra], [CXXFLAGS])
[AX_APPEND_COMPILE_FLAGS([-Wall -Wextra], [AM_CXXFLAGS])
dnl Be careful about adding the -fexceptions option; some versions of
dnl GCC don't support it and it causes extra warnings that are only
dnl distracting; avoid.
AX_APPEND_COMPILE_FLAGS([-fexceptions], [CXXFLAGS])
AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing], [CXXFLAGS])])
AX_APPEND_COMPILE_FLAGS([-fexceptions], [AM_CXXFLAGS])
AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing], [AM_CXXFLAGS])])
AC_LANG_POP([C++])
AS_IF([test "$GCC" = yes],
[AX_APPEND_LINK_FLAGS([-fno-strict-aliasing],[LDFLAGS])])
[AX_APPEND_LINK_FLAGS([-fno-strict-aliasing],[AM_LDFLAGS])])
dnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang (issue #312)
AS_CASE(["$LD"],[*clang*],
@@ -100,11 +134,8 @@ AS_CASE(["$LD"],[*clang*],
[*linux*],[archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'])])
EXPATCFG_COMPILER_SUPPORTS_VISIBILITY([
AX_APPEND_FLAG([-fvisibility=hidden], [CFLAGS])
AX_APPEND_FLAG([-DXML_ENABLE_VISIBILITY=1], [CFLAGS])])
dnl Checks for header files.
AC_HEADER_STDC
AX_APPEND_FLAG([-fvisibility=hidden], [AM_CFLAGS])
AX_APPEND_FLAG([-DXML_ENABLE_VISIBILITY=1], [AM_CPPFLAGS])])
dnl Checks for typedefs, structures, and compiler characteristics.
@@ -149,8 +180,13 @@ AS_CASE("${host_os}",
AC_MSG_NOTICE([detected OS: MinGW])])
AM_CONDITIONAL([MINGW], [test x${EXPATCFG_ON_MINGW} = xyes])
dnl Note: Prefix "_INTERNAL_" here means exclusive use inside of file configure.ac
AM_CONDITIONAL([UNICODE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_UNICODE >/dev/null])
AM_CONDITIONAL([_INTERNAL_UNICODE_WCHAR_T], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_UNICODE_WCHAR_T >/dev/null])
AM_CONDITIONAL([_INTERNAL_MIN_SIZE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_MIN_SIZE >/dev/null])
AM_CONDITIONAL([_INTERNAL_LARGE_SIZE], [echo -- "${CPPFLAGS}${CFLAGS}" | ${FGREP} XML_LARGE_SIZE >/dev/null])
LT_LIB_M
AC_ARG_WITH([libbsd],
[AS_HELP_STRING([--with-libbsd], [utilize libbsd (for arc4random_buf)])],
@@ -307,8 +343,75 @@ AS_IF([test "x${DOCBOOK_TO_MAN}" != x -a "x$with_docbook" != xno],
AM_CONDITIONAL(WITH_DOCBOOK, [test "x${DOCBOOK_TO_MAN}" != x])
dnl Configure CMake file templates
dnl NOTE: The *_TRUE variables read here are Automake conditionals
dnl that are either set to "" when enabled or to "#" when disabled
dnl (because they are used to dynamically comment out certain things)
AS_IF([test "x${enable_xml_attr_info}" = xyes],
[EXPAT_ATTR_INFO=ON],
[EXPAT_ATTR_INFO=OFF])
EXPAT_DTD=ON
AS_IF([test "x${_INTERNAL_LARGE_SIZE_TRUE}" = x],
[EXPAT_LARGE_SIZE=ON],
[EXPAT_LARGE_SIZE=OFF])
AS_IF([test "x${_INTERNAL_MIN_SIZE_TRUE}" = x],
[EXPAT_MIN_SIZE=ON],
[EXPAT_MIN_SIZE=OFF])
EXPAT_NS=ON
AS_IF([test "x${enable_xml_context}" != xno],
[EXPAT_CONTEXT_BYTES=${enable_xml_context}],
[EXPAT_CONTEXT_BYTES=OFF])
AS_IF([test "x${UNICODE_TRUE}" = x],
[AS_IF(
[test "x${_INTERNAL_UNICODE_WCHAR_T_TRUE}" = x],
[EXPAT_CHAR_TYPE=wchar_t],
[EXPAT_CHAR_TYPE=ushort])],
[EXPAT_CHAR_TYPE=char])
PACKAGE_INIT="${srcdir}"/cmake/autotools/expat-package-init.cmake
LIBDIR_BASENAME="$(basename "${libdir}")"
SO_MAJOR="$(expr "${LIBCURRENT}" - "${LIBAGE}")"
SO_MINOR="${LIBAGE}"
SO_PATCH="${LIBREVISION}"
AC_CHECK_SIZEOF([void *]) # sets ac_cv_sizeof_void_p
AC_SUBST([EXPAT_ATTR_INFO])
AC_SUBST([EXPAT_DTD])
AC_SUBST([EXPAT_LARGE_SIZE])
AC_SUBST([EXPAT_MIN_SIZE])
AC_SUBST([EXPAT_NS])
AC_SUBST([EXPAT_CONTEXT_BYTES])
AC_SUBST([EXPAT_CHAR_TYPE])
AC_SUBST_FILE([PACKAGE_INIT])
AC_SUBST([LIBDIR_BASENAME])
AC_SUBST([SO_MAJOR])
AC_SUBST([SO_MINOR])
AC_SUBST([SO_PATCH])
AC_SUBST([ac_cv_sizeof_void_p])
dnl write the Automake flags we set
AC_SUBST([AM_CPPFLAGS])
AC_SUBST([AM_CFLAGS])
AC_SUBST([AM_CXXFLAGS])
AC_SUBST([AM_LDFLAGS])
dnl Emulate the use of CMAKE_SHARED_LIBRARY_PREFIX under CMake
AC_MSG_CHECKING([for shared library name prefix])
AS_CASE("${host_os}",
[cygwin*], [CMAKE_SHARED_LIBRARY_PREFIX=cyg],
[CMAKE_SHARED_LIBRARY_PREFIX=lib])
AC_MSG_RESULT([${CMAKE_SHARED_LIBRARY_PREFIX}])
AC_SUBST([CMAKE_SHARED_LIBRARY_PREFIX])
AS_CASE("${host_os}",
[darwin*], [CMAKE_NOCONFIG_SOURCE=cmake/autotools/expat-noconfig__macos.cmake.in],
[mingw*|cygwin*], [CMAKE_NOCONFIG_SOURCE=cmake/autotools/expat-noconfig__windows.cmake.in],
[CMAKE_NOCONFIG_SOURCE=cmake/autotools/expat-noconfig__linux.cmake.in])
AC_CONFIG_FILES([Makefile]
[expat.pc]
[cmake/expat-config.cmake]
[cmake/autotools/expat-config-version.cmake]
[cmake/autotools/expat-noconfig.cmake:${CMAKE_NOCONFIG_SOURCE}]
[doc/Makefile]
[examples/Makefile]
[lib/Makefile]
@@ -317,3 +420,18 @@ AC_CONFIG_FILES([Makefile]
[xmlwf/Makefile])
AC_CONFIG_FILES([run.sh], [chmod +x run.sh])
AC_OUTPUT
AC_MSG_NOTICE([
Automake flags (can be overridden by user flags):
[AM_CPPFLAGS]: ${AM_CPPFLAGS}
[AM_CFLAGS]: ${AM_CFLAGS}
[AM_CXXFLAGS]: ${AM_CXXFLAGS}
[AM_LDFLAGS]: ${AM_LDFLAGS}
User flags (override Automake flags on conflict):
CPPFLAGS: ${CPPFLAGS}
CFLAGS: ${CFLAGS}
CXXFLAGS: ${CXXFLAGS}
LDFLAGS: ${LDFLAGS}])
+4 -3
View File
@@ -6,7 +6,9 @@
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2017 Expat development team
# Copyright (c) 2017-2022 Sebastian Pipping <[email protected]>
# Copyright (c) 2017 Stephen Groat <[email protected]>
# Copyright (c) 2017 Joe Orton <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
@@ -52,8 +54,7 @@ clean-local-check:
$(RM) xmlwf.1
EXTRA_DIST = \
expat.png \
ok.min.css \
reference.html \
style.css \
valid-xhtml10.png \
xmlwf.xml
+28 -7
View File
@@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.16.1 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -22,7 +22,9 @@
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2017 Expat development team
# Copyright (c) 2017-2022 Sebastian Pipping <[email protected]>
# Copyright (c) 2017 Stephen Groat <[email protected]>
# Copyright (c) 2017 Joe Orton <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
@@ -193,7 +195,11 @@ am__DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.in
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_CFLAGS = @AM_CFLAGS@
AM_CPPFLAGS = @AM_CPPFLAGS@
AM_CXXFLAGS = @AM_CXXFLAGS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AM_LDFLAGS = @AM_LDFLAGS@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
@@ -203,8 +209,10 @@ AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CMAKE_SHARED_LIBRARY_PREFIX = @CMAKE_SHARED_LIBRARY_PREFIX@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
@@ -220,7 +228,15 @@ ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
EXPAT_ATTR_INFO = @EXPAT_ATTR_INFO@
EXPAT_CHAR_TYPE = @EXPAT_CHAR_TYPE@
EXPAT_CONTEXT_BYTES = @EXPAT_CONTEXT_BYTES@
EXPAT_DTD = @EXPAT_DTD@
EXPAT_LARGE_SIZE = @EXPAT_LARGE_SIZE@
EXPAT_MIN_SIZE = @EXPAT_MIN_SIZE@
EXPAT_NS = @EXPAT_NS@
FGREP = @FGREP@
FILEMAP = @FILEMAP@
GREP = @GREP@
@@ -233,6 +249,8 @@ LD = @LD@
LDFLAGS = @LDFLAGS@
LIBAGE = @LIBAGE@
LIBCURRENT = @LIBCURRENT@
LIBDIR_BASENAME = @LIBDIR_BASENAME@
LIBM = @LIBM@
LIBOBJS = @LIBOBJS@
LIBREVISION = @LIBREVISION@
LIBS = @LIBS@
@@ -262,6 +280,9 @@ RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SO_MAJOR = @SO_MAJOR@
SO_MINOR = @SO_MINOR@
SO_PATCH = @SO_PATCH@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
@@ -272,6 +293,7 @@ ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
ac_cv_sizeof_void_p = @ac_cv_sizeof_void_p@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -309,6 +331,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -319,10 +342,9 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
@WITH_DOCBOOK_TRUE@dist_man_MANS = xmlwf.1
EXTRA_DIST = \
expat.png \
ok.min.css \
reference.html \
style.css \
valid-xhtml10.png \
xmlwf.xml
all: all-am
@@ -413,7 +435,6 @@ ctags CTAGS:
cscope cscopelist:
@WITH_DOCBOOK_TRUE@dist-hook:
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

+2
View File
@@ -0,0 +1,2 @@
/*! OK.css v1.0.3 | MIT License | github.com/andrewh0/okcss */@import url("https://rsms.me/inter/inter.css");
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15}body{margin:0}main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:.35em .75em .625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details{display:block}summary{display:list-item}[hidden],template{display:none}:root{--ok-sans:"Inter",system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue","Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--ok-mono:SFMono-Regular,Menlo,Monaco,Consolas,"Ubuntu Mono","Liberation Mono","Courier New",Courier,monospace;--ok-fw-0:400;--ok-fw-1:600;--ok-fw-2:700;--ok-fw-3:700;--ok-fs-0:2.5rem;--ok-fs-1:2rem;--ok-fs-2:1.5rem;--ok-fs-3:1.25rem;--ok-fs-4:1rem;--ok-fs-5:0.75rem;--ok-br:0.25rem;--ok-s-0:0;--ok-s-1:0.25rem;--ok-s-2:0.5rem;--ok-s-3:1rem;--ok-s-4:1.5rem;--ok-s-5:2rem;--ok-s-6:2.5rem;--ok-lh-body:1.5;--ok-lh-heading:1.25;--ok-t-hl:#ffcf30;--ok-accent-0:#3e67fa;--ok-accent-1:#4788ff;--ok-tc-accent:#3173de;--ok-tc-code:#c23a30;--ok-tc-0:#000;--ok-tc-1:#747474;--ok-tc-2:#848484;--ok-bg-0:#fff;--ok-bg-1:#f0f0f0;--ok-bg-2:#ccc;--ok-b-0:1px solid #cbcbcb;--ok-b-1:1px solid #848484;--ok-down-0:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' height='8' viewBox='0 0 12 8' width='24' fill='none'%3E%3Cpath d='M6 6l4-4h1v1-1L6 7 1 2h1l4 4z' fill='%23747474'/%3E%3C/svg%3E");--ok-down-1:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' height='8' viewBox='0 0 12 8' width='24' fill='none'%3E%3Cpath d='M6 6l4-4h1v1-1L6 7 1 2h1l4 4z' fill='%23848484'/%3E%3C/svg%3E")}@media (prefers-color-scheme:dark){:root{--ok-tc-accent:#5c9aff;--ok-tc-code:#ed5853;--ok-tc-0:#fff;--ok-tc-1:#ababab;--ok-tc-2:#929292;--ok-bg-0:#000;--ok-bg-1:#212121;--ok-bg-2:#3e3e3e;--ok-b-0:1px solid #747474;--ok-b-1:1px solid #929292;--ok-down-0:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' height='8' viewBox='0 0 12 8' width='24' fill='none'%3E%3Cpath d='M6 6l4-4h1v1-1L6 7 1 2h1l4 4z' fill='%23ababab'/%3E%3C/svg%3E");--ok-down-1:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' height='8' viewBox='0 0 12 8' width='24' fill='none'%3E%3Cpath d='M6 6l4-4h1v1-1L6 7 1 2h1l4 4z' fill='%23929292'/%3E%3C/svg%3E")}}*,:after,:before{box-sizing:border-box}*{margin:0;padding:0}html{font-family:var(--ok-sans);line-sizing:normal;line-height:var(--ok-lh-body);font-weight:var(--ok-fw-0);color:var(--ok-tc-0);background-color:var(--ok-bg-0);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-text-size-adjust:100%;-moz-text-size-adjust:100%;-ms-text-size-adjust:100%;text-size-adjust:100%;text-rendering:optimizeLegibility}@supports (font-variation-settings:normal){html{font-family:Inter var,var(--ok-sans)}}button,input,optgroup,select,textarea{font-family:inherit;line-height:var(--ok-lh-body)}[role=button],button{cursor:pointer}audio,canvas,embed,iframe,img,input,object,select,svg,textarea,video{display:block}img,video{max-width:100%;height:auto}body{padding:var(--ok-s-3);max-width:80ch;margin:auto}h1{font-size:var(--ok-fs-0);margin:0}h2{font-size:var(--ok-fs-1)}h3{font-size:var(--ok-fs-2)}h4{font-size:var(--ok-fs-3)}h5{font-size:var(--ok-fs-4)}h6{font-size:var(--ok-fs-5);text-transform:uppercase;font-weight:var(--ok-fw-1)}h1,h2,h3,h4,h5,h6{line-height:var(--ok-lh-heading);font-weight:var(--ok-fw-3)}p{font-size:var(--ok-fs-4)}small{fontLine truncated
+309 -99
View File
@@ -3,26 +3,56 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<!-- Copyright 1999,2000 Clark Cooper <[email protected]>
All rights reserved.
This is free software. You may distribute or modify according to
the terms of the MIT/X License -->
<!--
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 2000 Clark Cooper <[email protected]>
Copyright (c) 2000-2004 Fred L. Drake, Jr. <[email protected]>
Copyright (c) 2002-2012 Karl Waclawek <[email protected]>
Copyright (c) 2017-2022 Sebastian Pipping <[email protected]>
Copyright (c) 2017 Jakub Wilk <[email protected]>
Copyright (c) 2021 Tomas Korbar <[email protected]>
Copyright (c) 2021 Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
Copyright (c) 2022 Thijs Schreijer <[email protected]>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<title>Expat XML Parser</title>
<meta name="author" content="Clark Cooper, [email protected]" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link href="ok.min.css" rel="stylesheet" type="text/css" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table cellspacing="0" cellpadding="0" width="100%">
<tr>
<td class="corner"><img src="expat.png" alt="(Expat logo)" /></td>
<td class="banner"><h1>The Expat XML Parser</h1></td>
</tr>
<tr>
<td class="releaseno">Release 2.0.1</td>
<td></td>
</tr>
</table>
<div>
<h1>
The Expat XML Parser
<small>Release 2.4.7</small>
</h1>
</div>
<div class="content">
<p>Expat is a library, written in C, for parsing XML documents. It's
@@ -120,6 +150,13 @@ interface.</p>
<li><a href="#XML_GetInputContext">XML_GetInputContext</a></li>
</ul>
</li>
<li>
<a href="#billion-laughs">Billion Laughs Attack Protection</a>
<ul>
<li><a href="#XML_SetBillionLaughsAttackProtectionMaximumAmplification">XML_SetBillionLaughsAttackProtectionMaximumAmplification</a></li>
<li><a href="#XML_SetBillionLaughsAttackProtectionActivationThreshold">XML_SetBillionLaughsAttackProtectionActivationThreshold</a></li>
</ul>
</li>
<li><a href="#miscellaneous">Miscellaneous Functions</a>
<ul>
<li><a href="#XML_SetUserData">XML_SetUserData</a></li>
@@ -900,7 +937,8 @@ whether the parse can be resumed in the future.</p>
<h3><a name="creation">Parser Creation</a></h3>
<pre class="fcndec" id="XML_ParserCreate">
<h4 id="XML_ParserCreate">XML_ParserCreate</h4>
<pre class="fcndec">
XML_Parser XMLCALL
XML_ParserCreate(const XML_Char *encoding);
</pre>
@@ -917,7 +955,8 @@ encoding declaration. There are four built-in encodings:
Any other value will invoke a call to the UnknownEncodingHandler.
</div>
<pre class="fcndec" id="XML_ParserCreateNS">
<h4 id="XML_ParserCreateNS">XML_ParserCreateNS</h4>
<pre class="fcndec">
XML_Parser XMLCALL
XML_ParserCreateNS(const XML_Char *encoding,
XML_Char sep);
@@ -936,7 +975,16 @@ the local part will be concatenated without any separator - this is intended
to support RDF processors. It is a programming error to use the null separator
with <a href= "#XML_SetReturnNSTriplet">namespace triplets</a>.</div>
<pre class="fcndec" id="XML_ParserCreate_MM">
<p><strong>Note:</strong>
Expat does not validate namespace URIs (beyond encoding)
against RFC 3986 today (and is not required to do so with regard to
the XML 1.0 namespaces specification) but it may start doing that
in future releases. Before that, an application using Expat must
be ready to receive namespace URIs containing non-URI characters.
</p>
<h4 id="XML_ParserCreate_MM">XML_ParserCreate_MM</h4>
<pre class="fcndec">
XML_Parser XMLCALL
XML_ParserCreate_MM(const XML_Char *encoding,
const XML_Memory_Handling_Suite *ms,
@@ -958,7 +1006,8 @@ and the character pointed at by sep is used as the separator between
the namespace URI and the local part of the name.</p>
</div>
<pre class="fcndec" id="XML_ExternalEntityParserCreate">
<h4 id="XML_ExternalEntityParserCreate">XML_ExternalEntityParserCreate</h4>
<pre class="fcndec">
XML_Parser XMLCALL
XML_ExternalEntityParserCreate(XML_Parser p,
const XML_Char *context,
@@ -974,7 +1023,8 @@ changing functions on this parser (unless you want it to act
differently than the parent parser).
</div>
<pre class="fcndec" id="XML_ParserFree">
<h4 id="XML_ParserFree">XML_ParserFree</h4>
<pre class="fcndec">
void XMLCALL
XML_ParserFree(XML_Parser p);
</pre>
@@ -983,7 +1033,8 @@ Free memory used by the parser. Your application is responsible for
freeing any memory associated with <a href="#userdata">user data</a>.
</div>
<pre class="fcndec" id="XML_ParserReset">
<h4 id="XML_ParserReset">XML_ParserReset</h4>
<pre class="fcndec">
XML_Bool XMLCALL
XML_ParserReset(XML_Parser p,
const XML_Char *encoding);
@@ -1014,7 +1065,7 @@ if they apply to the parser created by
<code><a href= "#XML_ExternalEntityParserCreate"
>XML_ExternalEntityParserCreate</a></code>.</p>
<p>Note: the <code>len</code> argument passed to these functions
<p>Note: The <code>len</code> argument passed to these functions
should be considerably less than the maximum value for an integer,
as it could create an integer overflow situation if the added
lengths of a buffer and the unprocessed portion of the previous buffer
@@ -1022,7 +1073,8 @@ exceed the maximum integer value. Input data at the end of a buffer
will remain unprocessed if it is part of an XML token for which the
end is not part of that buffer.</p>
<pre class="fcndec" id="XML_Parse">
<h4 id="XML_Parse">XML_Parse</h4>
<pre class="fcndec">
enum XML_Status XMLCALL
XML_Parse(XML_Parser p,
const char *s,
@@ -1049,7 +1101,8 @@ If a parse error occurred, it returns <code>XML_STATUS_ERROR</code>.
Otherwise it returns <code>XML_STATUS_OK</code> value.
</div>
<pre class="fcndec" id="XML_ParseBuffer">
<h4 id="XML_ParseBuffer">XML_ParseBuffer</h4>
<pre class="fcndec">
enum XML_Status XMLCALL
XML_ParseBuffer(XML_Parser p,
int len,
@@ -1063,7 +1116,8 @@ buffer from Expat with the <code><a href= "#XML_GetBuffer"
copying of the input.
</div>
<pre class="fcndec" id="XML_GetBuffer">
<h4 id="XML_GetBuffer">XML_GetBuffer</h4>
<pre class="fcndec">
void * XMLCALL
XML_GetBuffer(XML_Parser p,
int len);
@@ -1071,7 +1125,8 @@ XML_GetBuffer(XML_Parser p,
<div class="fcndef">
Obtain a buffer of size <code>len</code> to read a piece of the document
into. A NULL value is returned if Expat can't allocate enough memory for
this buffer. This has to be called prior to every call to
this buffer. A NULL value may also be returned if <code>len</code> is zero.
This has to be called prior to every call to
<code><a href= "#XML_ParseBuffer" >XML_ParseBuffer</a></code>. A
typical use would look like this:
@@ -1098,7 +1153,8 @@ for (;;) {
</pre>
</div>
<pre class="fcndec" id="XML_StopParser">
<h4 id="XML_StopParser">XML_StopParser</h4>
<pre class="fcndec">
enum XML_Status XMLCALL
XML_StopParser(XML_Parser p,
XML_Bool resumable);
@@ -1111,7 +1167,7 @@ XML_StopParser(XML_Parser p,
call-back handler, except when aborting (when <code>resumable</code>
is <code>XML_FALSE</code>) an already suspended parser. Some
call-backs may still follow because they would otherwise get
lost, including
lost, including</p>
<ul>
<li> the end element handler for empty elements when stopped in the
start element handler,</li>
@@ -1120,7 +1176,7 @@ lost, including
<li> the character data handler when stopped in the character data handler
while making multiple call-backs on a contiguous chunk of characters,</li>
</ul>
and possibly others.</p>
<p>and possibly others.</p>
<p>This can be called from most handlers, including DTD related
call-backs, except when parsing an external parameter entity and
@@ -1166,7 +1222,8 @@ implementation of that handler to call <code><a href=
<p>New in Expat 1.95.8.</p>
</div>
<pre class="fcndec" id="XML_ResumeParser">
<h4 id="XML_ResumeParser">XML_ResumeParser</h4>
<pre class="fcndec">
enum XML_Status XMLCALL
XML_ResumeParser(XML_Parser p);
</pre>
@@ -1191,7 +1248,8 @@ appropriate moment.</p>
<p>New in Expat 1.95.8.</p>
</div>
<pre class="fcndec" id="XML_GetParsingStatus">
<h4 id="XML_GetParsingStatus">XML_GetParsingStatus</h4>
<pre class="fcndec">
void XMLCALL
XML_GetParsingStatus(XML_Parser p,
XML_ParsingStatus *status);
@@ -1240,7 +1298,8 @@ Note that you'll receive them in this form independent of the original
encoding of the document.</p>
<div class="handler">
<pre class="setter" id="XML_SetStartElementHandler">
<h4 id="XML_SetStartElementHandler">XML_SetStartElementHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetStartElementHandler(XML_Parser p,
XML_StartElementHandler start);
@@ -1261,7 +1320,8 @@ by a null pointer.</p>
</div>
<div class="handler">
<pre class="setter" id="XML_SetEndElementHandler">
<h4 id="XML_SetEndElementHandler">XML_SetEndElementHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetEndElementHandler(XML_Parser p,
XML_EndElementHandler);
@@ -1276,7 +1336,8 @@ generates a call to both start and end handlers.</p>
</div>
<div class="handler">
<pre class="setter" id="XML_SetElementHandler">
<h4 id="XML_SetElementHandler">XML_SetElementHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetElementHandler(XML_Parser p,
XML_StartElementHandler start,
@@ -1286,7 +1347,8 @@ XML_SetElementHandler(XML_Parser p,
</div>
<div class="handler">
<pre class="setter" id="XML_SetCharacterDataHandler">
<h4 id="XML_SetCharacterDataHandler">XML_SetCharacterDataHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetCharacterDataHandler(XML_Parser p,
XML_CharacterDataHandler charhndl)
@@ -1298,7 +1360,7 @@ typedef void
int len);
</pre>
<p>Set a text handler. The string your handler receives
is <em>NOT nul-terminated</em>. You have to use the length argument
is <em>NOT null-terminated</em>. You have to use the length argument
to deal with the end of the string. A single block of contiguous text
free of markup may still result in a sequence of calls to this handler.
In other words, if you're searching for a pattern in the text, it may
@@ -1309,7 +1371,8 @@ will continue calling back until the end of the block is reached.</p>
</div>
<div class="handler">
<pre class="setter" id="XML_SetProcessingInstructionHandler">
<h4 id="XML_SetProcessingInstructionHandler">XML_SetProcessingInstructionHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetProcessingInstructionHandler(XML_Parser p,
XML_ProcessingInstructionHandler proc)
@@ -1327,7 +1390,8 @@ it after skipping all whitespace after the initial word.</p>
</div>
<div class="handler">
<pre class="setter" id="XML_SetCommentHandler">
<h4 id="XML_SetCommentHandler">XML_SetCommentHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetCommentHandler(XML_Parser p,
XML_CommentHandler cmnt)
@@ -1342,7 +1406,8 @@ delimiters.</p>
</div>
<div class="handler">
<pre class="setter" id="XML_SetStartCdataSectionHandler">
<h4 id="XML_SetStartCdataSectionHandler">XML_SetStartCdataSectionHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetStartCdataSectionHandler(XML_Parser p,
XML_StartCdataSectionHandler start);
@@ -1355,7 +1420,8 @@ typedef void
</div>
<div class="handler">
<pre class="setter" id="XML_SetEndCdataSectionHandler">
<h4 id="XML_SetEndCdataSectionHandler">XML_SetEndCdataSectionHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetEndCdataSectionHandler(XML_Parser p,
XML_EndCdataSectionHandler end);
@@ -1368,7 +1434,8 @@ typedef void
</div>
<div class="handler">
<pre class="setter" id="XML_SetCdataSectionHandler">
<h4 id="XML_SetCdataSectionHandler">XML_SetCdataSectionHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetCdataSectionHandler(XML_Parser p,
XML_StartCdataSectionHandler start,
@@ -1378,7 +1445,8 @@ XML_SetCdataSectionHandler(XML_Parser p,
</div>
<div class="handler">
<pre class="setter" id="XML_SetDefaultHandler">
<h4 id="XML_SetDefaultHandler">XML_SetDefaultHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetDefaultHandler(XML_Parser p,
XML_DefaultHandler hndl)
@@ -1409,7 +1477,8 @@ href="#XML_DefaultCurrent">XML_DefaultCurrent</a></code>.</p>
</div>
<div class="handler">
<pre class="setter" id="XML_SetDefaultHandlerExpand">
<h4 id="XML_SetDefaultHandlerExpand">XML_SetDefaultHandlerExpand</h4>
<pre class="setter">
void XMLCALL
XML_SetDefaultHandlerExpand(XML_Parser p,
XML_DefaultHandler hndl)
@@ -1429,7 +1498,8 @@ href="#XML_DefaultCurrent">XML_DefaultCurrent</a></code>.</p>
</div>
<div class="handler">
<pre class="setter" id="XML_SetExternalEntityRefHandler">
<h4 id="XML_SetExternalEntityRefHandler">XML_SetExternalEntityRefHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetExternalEntityRefHandler(XML_Parser p,
XML_ExternalEntityRefHandler hndl)
@@ -1482,7 +1552,8 @@ parser, the body of the external entity can be recursively parsed.</p>
information into global or static variables.</p>
</div>
<pre class="fcndec" id="XML_SetExternalEntityRefHandlerArg">
<h4 id="XML_SetExternalEntityRefHandlerArg">XML_SetExternalEntityRefHandlerArg</h4>
<pre class="fcndec">
void XMLCALL
XML_SetExternalEntityRefHandlerArg(XML_Parser p,
void *arg)
@@ -1508,7 +1579,8 @@ properly.</p>
</div>
<div class="handler">
<pre class="setter" id="XML_SetSkippedEntityHandler">
<h4 id="XML_SetSkippedEntityHandler">XML_SetSkippedEntityHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetSkippedEntityHandler(XML_Parser p,
XML_SkippedEntityHandler handler)
@@ -1528,14 +1600,15 @@ typedef void
has been called.</li>
</ol>
<p>The <code>is_parameter_entity</code> argument will be non-zero for
a parameter entity and zero for a general entity.</p> <p>Note: skipped
a parameter entity and zero for a general entity.</p> <p>Note: Skipped
parameter entities in declarations and skipped general entities in
attribute values cannot be reported, because the event would be out of
sync with the reporting of the declarations or attribute values</p>
</div>
<div class="handler">
<pre class="setter" id="XML_SetUnknownEncodingHandler">
<h4 id="XML_SetUnknownEncodingHandler">XML_SetUnknownEncodingHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetUnknownEncodingHandler(XML_Parser p,
XML_UnknownEncodingHandler enchandler,
@@ -1576,7 +1649,7 @@ call to the function pointed at by convert. This function may return -1
if the sequence itself is invalid. The convert pointer may be null if
there are only single byte codes. The data parameter passed to the convert
function is the data pointer from <code>XML_Encoding</code>. The
string s is <em>NOT</em> nul-terminated and points at the sequence of
string s is <em>NOT</em> null-terminated and points at the sequence of
bytes to be converted.</p>
<p>The function pointed at by <code>release</code> is called by the
@@ -1584,7 +1657,8 @@ parser when it is finished with the encoding. It may be NULL.</p>
</div>
<div class="handler">
<pre class="setter" id="XML_SetStartNamespaceDeclHandler">
<h4 id="XML_SetStartNamespaceDeclHandler">XML_SetStartNamespaceDeclHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetStartNamespaceDeclHandler(XML_Parser p,
XML_StartNamespaceDeclHandler start);
@@ -1602,7 +1676,8 @@ in that start tag.</p>
</div>
<div class="handler">
<pre class="setter" id="XML_SetEndNamespaceDeclHandler">
<h4 id="XML_SetEndNamespaceDeclHandler">XML_SetEndNamespaceDeclHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetEndNamespaceDeclHandler(XML_Parser p,
XML_EndNamespaceDeclHandler end);
@@ -1619,7 +1694,8 @@ namespace was declared.</p>
</div>
<div class="handler">
<pre class="setter" id="XML_SetNamespaceDeclHandler">
<h4 id="XML_SetNamespaceDeclHandler">XML_SetNamespaceDeclHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetNamespaceDeclHandler(XML_Parser p,
XML_StartNamespaceDeclHandler start,
@@ -1629,7 +1705,8 @@ XML_SetNamespaceDeclHandler(XML_Parser p,
</div>
<div class="handler">
<pre class="setter" id="XML_SetXmlDeclHandler">
<h4 id="XML_SetXmlDeclHandler">XML_SetXmlDeclHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetXmlDeclHandler(XML_Parser p,
XML_XmlDeclHandler xmldecl);
@@ -1652,7 +1729,8 @@ that it was given as yes.</p>
</div>
<div class="handler">
<pre class="setter" id="XML_SetStartDoctypeDeclHandler">
<h4 id="XML_SetStartDoctypeDeclHandler">XML_SetStartDoctypeDeclHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetStartDoctypeDeclHandler(XML_Parser p,
XML_StartDoctypeDeclHandler start);
@@ -1672,7 +1750,8 @@ will be non-zero if the DOCTYPE declaration has an internal subset.</p>
</div>
<div class="handler">
<pre class="setter" id="XML_SetEndDoctypeDeclHandler">
<h4 id="XML_SetEndDoctypeDeclHandler">XML_SetEndDoctypeDeclHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetEndDoctypeDeclHandler(XML_Parser p,
XML_EndDoctypeDeclHandler end);
@@ -1686,7 +1765,8 @@ after parsing any external subset.</p>
</div>
<div class="handler">
<pre class="setter" id="XML_SetDoctypeDeclHandler">
<h4 id="XML_SetDoctypeDeclHandler">XML_SetDoctypeDeclHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetDoctypeDeclHandler(XML_Parser p,
XML_StartDoctypeDeclHandler start,
@@ -1696,7 +1776,8 @@ XML_SetDoctypeDeclHandler(XML_Parser p,
</div>
<div class="handler">
<pre class="setter" id="XML_SetElementDeclHandler">
<h4 id="XML_SetElementDeclHandler">XML_SetElementDeclHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetElementDeclHandler(XML_Parser p,
XML_ElementDeclHandler eldecl);
@@ -1736,10 +1817,11 @@ struct XML_cp {
</pre>
<p>Sets a handler for element declarations in a DTD. The handler gets
called with the name of the element in the declaration and a pointer
to a structure that contains the element model. It is the
application's responsibility to free this data structure using
<code><a href="#XML_FreeContentModel"
>XML_FreeContentModel</a></code>.</p>
to a structure that contains the element model. It's the user code's
responsibility to free model when finished with it. See <code>
<a href="#XML_FreeContentModel">XML_FreeContentModel</a></code>.
There is no need to free the model from the handler, it can be kept
around and freed at a later stage.</p>
<p>The <code>model</code> argument is the root of a tree of
<code>XML_Content</code> nodes. If <code>type</code> equals
@@ -1768,7 +1850,8 @@ or sequence and <code>children</code> points to the nodes.</p>
</div>
<div class="handler">
<pre class="setter" id="XML_SetAttlistDeclHandler">
<h4 id="XML_SetAttlistDeclHandler">XML_SetAttlistDeclHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetAttlistDeclHandler(XML_Parser p,
XML_AttlistDeclHandler attdecl);
@@ -1801,7 +1884,8 @@ in the <code>dflt</code> parameter.</p>
</div>
<div class="handler">
<pre class="setter" id="XML_SetEntityDeclHandler">
<h4 id="XML_SetEntityDeclHandler">XML_SetEntityDeclHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetEntityDeclHandler(XML_Parser p,
XML_EntityDeclHandler handler);
@@ -1835,7 +1919,8 @@ declarations.</p>
</div>
<div class="handler">
<pre class="setter" id="XML_SetUnparsedEntityDeclHandler">
<h4 id="XML_SetUnparsedEntityDeclHandler">XML_SetUnparsedEntityDeclHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetUnparsedEntityDeclHandler(XML_Parser p,
XML_UnparsedEntityDeclHandler h)
@@ -1861,7 +1946,8 @@ compatibility. Use instead <a href= "#XML_SetEntityDeclHandler"
</div>
<div class="handler">
<pre class="setter" id="XML_SetNotationDeclHandler">
<h4 id="XML_SetNotationDeclHandler">XML_SetNotationDeclHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetNotationDeclHandler(XML_Parser p,
XML_NotationDeclHandler h)
@@ -1878,7 +1964,8 @@ typedef void
</div>
<div class="handler">
<pre class="setter" id="XML_SetNotStandaloneHandler">
<h4 id="XML_SetNotStandaloneHandler">XML_SetNotStandaloneHandler</h4>
<pre class="setter">
void XMLCALL
XML_SetNotStandaloneHandler(XML_Parser p,
XML_NotStandaloneHandler h)
@@ -1904,7 +1991,7 @@ of errors. The position reported is the byte position (in the original
document or entity encoding) of the first of the sequence of
characters that generated the current event (or the error that caused
the parse functions to return <code>XML_STATUS_ERROR</code>.) The
exceptions are callbacks trigged by declarations in the document
exceptions are callbacks triggered by declarations in the document
prologue, in which case they exact position reported is somewhere in the
relevant markup, but not necessarily as meaningful as for other
events.</p>
@@ -1913,7 +2000,8 @@ events.</p>
DTD. In other words, they usually return bogus information when
called from within a DTD declaration handler.</p>
<pre class="fcndec" id="XML_GetErrorCode">
<h4 id="XML_GetErrorCode">XML_GetErrorCode</h4>
<pre class="fcndec">
enum XML_Error XMLCALL
XML_GetErrorCode(XML_Parser p);
</pre>
@@ -1921,7 +2009,8 @@ XML_GetErrorCode(XML_Parser p);
Return what type of error has occurred.
</div>
<pre class="fcndec" id="XML_ErrorString">
<h4 id="XML_ErrorString">XML_ErrorString</h4>
<pre class="fcndec">
const XML_LChar * XMLCALL
XML_ErrorString(enum XML_Error code);
</pre>
@@ -1931,7 +2020,8 @@ The code should be one of the enums that can be returned from
<code><a href= "#XML_GetErrorCode" >XML_GetErrorCode</a></code>.
</div>
<pre class="fcndec" id="XML_GetCurrentByteIndex">
<h4 id="XML_GetCurrentByteIndex">XML_GetCurrentByteIndex</h4>
<pre class="fcndec">
XML_Index XMLCALL
XML_GetCurrentByteIndex(XML_Parser p);
</pre>
@@ -1942,7 +2032,8 @@ the values returned by <code><a href= "#XML_GetCurrentLineNumber"
"#XML_GetCurrentColumnNumber" >XML_GetCurrentColumnNumber</a></code>.
</div>
<pre class="fcndec" id="XML_GetCurrentLineNumber">
<h4 id="XML_GetCurrentLineNumber">XML_GetCurrentLineNumber</h4>
<pre class="fcndec">
XML_Size XMLCALL
XML_GetCurrentLineNumber(XML_Parser p);
</pre>
@@ -1951,7 +2042,8 @@ Return the line number of the position. The first line is reported as
<code>1</code>.
</div>
<pre class="fcndec" id="XML_GetCurrentColumnNumber">
<h4 id="XML_GetCurrentColumnNumber">XML_GetCurrentColumnNumber</h4>
<pre class="fcndec">
XML_Size XMLCALL
XML_GetCurrentColumnNumber(XML_Parser p);
</pre>
@@ -1960,7 +2052,8 @@ Return the offset, from the beginning of the current line, of
the position.
</div>
<pre class="fcndec" id="XML_GetCurrentByteCount">
<h4 id="XML_GetCurrentByteCount">XML_GetCurrentByteCount</h4>
<pre class="fcndec">
int XMLCALL
XML_GetCurrentByteCount(XML_Parser p);
</pre>
@@ -1972,7 +2065,8 @@ be used to distinguish empty-element tags from empty elements using
separate start and end tags).
</div>
<pre class="fcndec" id="XML_GetInputContext">
<h4 id="XML_GetInputContext">XML_GetInputContext</h4>
<pre class="fcndec">
const char * XMLCALL
XML_GetInputContext(XML_Parser p,
int *offset,
@@ -1998,12 +2092,105 @@ parse position may be before the beginning of the buffer.</p>
return NULL.</p>
</div>
<h3><a name="billion-laughs">Billion Laughs Attack Protection</a></h3>
<p>The functions in this section configure the built-in
protection against various forms of
<a href="https://en.wikipedia.org/wiki/Billion_laughs_attack">billion laughs attacks</a>.</p>
<h4 id="XML_SetBillionLaughsAttackProtectionMaximumAmplification">XML_SetBillionLaughsAttackProtectionMaximumAmplification</h4>
<pre class="fcndec">
/* Added in Expat 2.4.0. */
XML_Bool XMLCALL
XML_SetBillionLaughsAttackProtectionMaximumAmplification(XML_Parser p,
float maximumAmplificationFactor);
</pre>
<div class="fcndef">
<p>
Sets the maximum tolerated amplification factor
for protection against
<a href="https://en.wikipedia.org/wiki/Billion_laughs_attack">billion laughs attacks</a>
(default: <code>100.0</code>)
of parser <code>p</code> to <code>maximumAmplificationFactor</code>, and
returns <code>XML_TRUE</code> upon success and <code>XML_FALSE</code> upon error.
</p>
The amplification factor is calculated as ..
<pre>
amplification := (direct + indirect) / direct
</pre>
.. while parsing, whereas
<code>direct</code> is the number of bytes read from the primary document in parsing and
<code>indirect</code> is the number of bytes added by expanding entities and reading of external DTD files, combined.
<p>For a call to <code>XML_SetBillionLaughsAttackProtectionMaximumAmplification</code> to succeed:</p>
<ul>
<li>parser <code>p</code> must be a non-<code>NULL</code> root parser (without any parent parsers) and</li>
<li><code>maximumAmplificationFactor</code> must be non-<code>NaN</code> and greater than or equal to <code>1.0</code>.</li>
</ul>
<p>
<strong>Note:</strong>
If you ever need to increase this value for non-attack payload,
please <a href="https://github.com/libexpat/libexpat/issues">file a bug report</a>.
</p>
<p>
<strong>Note:</strong>
Peak amplifications
of factor 15,000 for the entire payload and
of factor 30,000 in the middle of parsing
have been observed with small benign files in practice.
So if you do reduce the maximum allowed amplification,
please make sure that the activation threshold is still big enough
to not end up with undesired false positives (i.e. benign files being rejected).
</p>
</div>
<h4 id="XML_SetBillionLaughsAttackProtectionActivationThreshold">XML_SetBillionLaughsAttackProtectionActivationThreshold</h4>
<pre class="fcndec">
/* Added in Expat 2.4.0. */
XML_Bool XMLCALL
XML_SetBillionLaughsAttackProtectionActivationThreshold(XML_Parser p,
unsigned long long activationThresholdBytes);
</pre>
<div class="fcndef">
<p>
Sets number of output bytes (including amplification from entity expansion and reading DTD files)
needed to activate protection against
<a href="https://en.wikipedia.org/wiki/Billion_laughs_attack">billion laughs attacks</a>
(default: <code>8 MiB</code>)
of parser <code>p</code> to <code>activationThresholdBytes</code>, and
returns <code>XML_TRUE</code> upon success and <code>XML_FALSE</code> upon error.
</p>
<p>For a call to <code>XML_SetBillionLaughsAttackProtectionActivationThreshold</code> to succeed:</p>
<ul>
<li>parser <code>p</code> must be a non-<code>NULL</code> root parser (without any parent parsers).</li>
</ul>
<p>
<strong>Note:</strong>
If you ever need to increase this value for non-attack payload,
please <a href="https://github.com/libexpat/libexpat/issues">file a bug report</a>.
</p>
<p>
<strong>Note:</strong>
Activation thresholds below 4 MiB are known to break support for
<a href="https://en.wikipedia.org/wiki/Darwin_Information_Typing_Architecture">DITA</a> 1.3 payload
and are hence not recommended.
</p>
</div>
<h3><a name="miscellaneous">Miscellaneous functions</a></h3>
<p>The functions in this section either obtain state information from
the parser or can be used to dynamically set parser options.</p>
<pre class="fcndec" id="XML_SetUserData">
<h4 id="XML_SetUserData">XML_SetUserData</h4>
<pre class="fcndec">
void XMLCALL
XML_SetUserData(XML_Parser p,
void *userData);
@@ -2018,7 +2205,8 @@ the memory associated with it, then you've probably just leaked
memory.
</div>
<pre class="fcndec" id="XML_GetUserData">
<h4 id="XML_GetUserData">XML_GetUserData</h4>
<pre class="fcndec">
void * XMLCALL
XML_GetUserData(XML_Parser p);
</pre>
@@ -2027,7 +2215,8 @@ This returns the user data pointer that gets passed to handlers.
It is actually implemented as a macro.
</div>
<pre class="fcndec" id="XML_UseParserAsHandlerArg">
<h4 id="XML_UseParserAsHandlerArg">XML_UseParserAsHandlerArg</h4>
<pre class="fcndec">
void XMLCALL
XML_UseParserAsHandlerArg(XML_Parser p);
</pre>
@@ -2038,7 +2227,8 @@ using the <code><a href= "#XML_GetUserData"
>XML_GetUserData</a></code> function.
</div>
<pre class="fcndec" id="XML_SetBase">
<h4 id="XML_SetBase">XML_SetBase</h4>
<pre class="fcndec">
enum XML_Status XMLCALL
XML_SetBase(XML_Parser p,
const XML_Char *base);
@@ -2050,7 +2240,8 @@ there's no memory to store base, otherwise it's
<code>XML_STATUS_OK</code>.
</div>
<pre class="fcndec" id="XML_GetBase">
<h4 id="XML_GetBase">XML_GetBase</h4>
<pre class="fcndec">
const XML_Char * XMLCALL
XML_GetBase(XML_Parser p);
</pre>
@@ -2058,7 +2249,8 @@ XML_GetBase(XML_Parser p);
Return the base for resolving relative URIs.
</div>
<pre class="fcndec" id="XML_GetSpecifiedAttributeCount">
<h4 id="XML_GetSpecifiedAttributeCount">XML_GetSpecifiedAttributeCount</h4>
<pre class="fcndec">
int XMLCALL
XML_GetSpecifiedAttributeCount(XML_Parser p);
</pre>
@@ -2074,7 +2266,8 @@ call to a start handler. If called inside a start handler, then that
means the current call.
</div>
<pre class="fcndec" id="XML_GetIdAttributeIndex">
<h4 id="XML_GetIdAttributeIndex">XML_GetIdAttributeIndex</h4>
<pre class="fcndec">
int XMLCALL
XML_GetIdAttributeIndex(XML_Parser p);
</pre>
@@ -2086,7 +2279,8 @@ attribute. If called inside a start handler, then that means the
current call.
</div>
<pre class="fcndec" id="XML_GetAttributeInfo">
<h4 id="XML_GetAttributeInfo">XML_GetAttributeInfo</h4>
<pre class="fcndec">
const XML_AttrInfo * XMLCALL
XML_GetAttributeInfo(XML_Parser parser);
</pre>
@@ -2107,7 +2301,8 @@ as 1; thus the number of entries in the array is
<code>XML_GetSpecifiedAttributeCount(parser) / 2</code>.
</div>
<pre class="fcndec" id="XML_SetEncoding">
<h4 id="XML_SetEncoding">XML_SetEncoding</h4>
<pre class="fcndec">
enum XML_Status XMLCALL
XML_SetEncoding(XML_Parser p,
const XML_Char *encoding);
@@ -2122,7 +2317,8 @@ Returns <code>XML_STATUS_OK</code> on success or
<code>XML_STATUS_ERROR</code> on error.
</div>
<pre class="fcndec" id="XML_SetParamEntityParsing">
<h4 id="XML_SetParamEntityParsing">XML_SetParamEntityParsing</h4>
<pre class="fcndec">
int XMLCALL
XML_SetParamEntityParsing(XML_Parser p,
enum XML_ParamEntityParsing code);
@@ -2142,7 +2338,8 @@ The choices for <code>code</code> are:
no effect and will always return 0.
</div>
<pre class="fcndec" id="XML_SetHashSalt">
<h4 id="XML_SetHashSalt">XML_SetHashSalt</h4>
<pre class="fcndec">
int XMLCALL
XML_SetHashSalt(XML_Parser p,
unsigned long hash_salt);
@@ -2153,15 +2350,16 @@ Helps in preventing DoS attacks based on predicting hash
function behavior. In order to have an effect this must be called
before parsing has started. Returns 1 if successful, 0 when called
after <code>XML_Parse</code> or <code>XML_ParseBuffer</code>.
<p><b>Note:</b>This call is optional, as the parser will auto-generate
<p><b>Note:</b> This call is optional, as the parser will auto-generate
a new random salt value if no value has been set at the start of parsing.</p>
<p><b>Note:</b>One should not call <code>XML_SetHashSalt</code> with a
<p><b>Note:</b> One should not call <code>XML_SetHashSalt</code> with a
hash salt value of 0, as this value is used as sentinel value to indicate
that <code>XML_SetHashSalt</code> has <b>not</b> been called. Consequently
such a call will have no effect, even if it returns 1.</p>
</div>
<pre class="fcndec" id="XML_UseForeignDTD">
<h4 id="XML_UseForeignDTD">XML_UseForeignDTD</h4>
<pre class="fcndec">
enum XML_Error XMLCALL
XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
</pre>
@@ -2198,7 +2396,8 @@ the document had a DTD with an external subset. This holds true even if
the external entity reference handler returns without action.</p>
</div>
<pre class="fcndec" id="XML_SetReturnNSTriplet">
<h4 id="XML_SetReturnNSTriplet">XML_SetReturnNSTriplet</h4>
<pre class="fcndec">
void XMLCALL
XML_SetReturnNSTriplet(XML_Parser parser,
int do_nst);
@@ -2220,7 +2419,8 @@ default manner, URI then local_name separated by the namespace
separator.</p>
</div>
<pre class="fcndec" id="XML_DefaultCurrent">
<h4 id="XML_DefaultCurrent">XML_DefaultCurrent</h4>
<pre class="fcndec">
void XMLCALL
XML_DefaultCurrent(XML_Parser parser);
</pre>
@@ -2234,7 +2434,8 @@ href="#XML_SetDefaultHandler" >XML_SetDefaultHandler</a></code> or
not a default handler.
</div>
<pre class="fcndec" id="XML_ExpatVersion">
<h4 id="XML_ExpatVersion">XML_ExpatVersion</h4>
<pre class="fcndec">
XML_LChar * XMLCALL
XML_ExpatVersion();
</pre>
@@ -2242,7 +2443,8 @@ XML_ExpatVersion();
Return the library version as a string (e.g. <code>"expat_1.95.1"</code>).
</div>
<pre class="fcndec" id="XML_ExpatVersionInfo">
<h4 id="XML_ExpatVersionInfo">XML_ExpatVersionInfo</h4>
<pre class="fcndec">
struct XML_Expat_Version XMLCALL
XML_ExpatVersionInfo();
</pre>
@@ -2266,7 +2468,8 @@ Testing these constants is currently the best way to determine if
particular parts of the Expat API are available.
</div>
<pre class="fcndec" id="XML_GetFeatureList">
<h4 id="XML_GetFeatureList">XML_GetFeatureList</h4>
<pre class="fcndec">
const XML_Feature * XMLCALL
XML_GetFeatureList();
</pre>
@@ -2327,7 +2530,8 @@ time, the following features have been defined to have values:</p>
</dl>
</div>
<pre class="fcndec" id="XML_FreeContentModel">
<h4 id="XML_FreeContentModel">XML_FreeContentModel</h4>
<pre class="fcndec">
void XMLCALL
XML_FreeContentModel(XML_Parser parser, XML_Content *model);
</pre>
@@ -2346,7 +2550,8 @@ applications. This can be essential when using dynamically loaded
libraries which use different C standard libraries (this can happen on
Windows, at least).</p>
<pre class="fcndec" id="XML_MemMalloc">
<h4 id="XML_MemMalloc">XML_MemMalloc</h4>
<pre class="fcndec">
void * XMLCALL
XML_MemMalloc(XML_Parser parser, size_t size);
</pre>
@@ -2358,7 +2563,8 @@ way must be freed using <code><a href="#XML_MemFree"
>XML_MemFree</a></code>.
</div>
<pre class="fcndec" id="XML_MemRealloc">
<h4 id="XML_MemRealloc">XML_MemRealloc</h4>
<pre class="fcndec">
void * XMLCALL
XML_MemRealloc(XML_Parser parser, void *ptr, size_t size);
</pre>
@@ -2377,7 +2583,8 @@ original block. Memory allocated in this way must be freed using
>XML_MemFree</a></code>.
</div>
<pre class="fcndec" id="XML_MemFree">
<h4 id="XML_MemFree">XML_MemFree</h4>
<pre class="fcndec">
void XMLCALL
XML_MemFree(XML_Parser parser, void *ptr);
</pre>
@@ -2388,9 +2595,12 @@ have been allocated by <code><a href="#XML_MemMalloc"
</div>
<hr />
<p><a href="http://validator.w3.org/check/referer"><img
src="valid-xhtml10.png" alt="Valid XHTML 1.0!"
height="31" width="88" class="noborder" /></a></p>
<div class="footer">
Found a bug in the documentation?
<a href="https://github.com/libexpat/libexpat/issues">Please file a bug report.</a>
</div>
</div>
</body>
</html>
+40 -94
View File
@@ -1,101 +1,47 @@
/*
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2000-2004 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2021 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* Stop not using half the screen */
body {
background-color: white;
border: 0px;
margin: 0px;
padding: 0px;
}
.corner {
width: 200px;
height: 80px;
text-align: center;
}
.banner {
background-color: rgb(110,139,61);
color: rgb(255,236,176);
padding-left: 2em;
}
.banner h1 {
font-size: 200%;
}
.content {
padding: 0em 2em 1em 2em;
}
.releaseno {
background-color: rgb(110,139,61);
color: rgb(255,236,176);
padding-bottom: 0.3em;
padding-top: 0.5em;
text-align: center;
font-weight: bold;
}
.noborder {
border-width: 0px;
}
.eg {
padding-left: 1em;
padding-top: .5em;
padding-bottom: .5em;
border: solid thin;
margin: 1em 0;
background-color: tan;
margin-left: 2em;
margin-right: 10%;
}
.pseudocode {
padding-left: 1em;
padding-top: .5em;
padding-bottom: .5em;
border: solid thin;
margin: 1em 0;
background-color: rgb(250,220,180);
margin-left: 2em;
margin-right: 10%;
}
.handler {
width: 100%;
border-top-width: thin;
margin-bottom: 1em;
}
.handler p {
margin-left: 2em;
}
.setter {
font-weight: bold;
}
.signature {
color: navy;
}
.fcndec {
width: 100%;
border-top-width: thin;
font-weight: bold;
}
.fcndef {
margin-left: 2em;
margin-bottom: 2em;
}
dd {
margin-bottom: 2em;
max-width: none; /* was: 80ch */
}
.cpp-symbols dt {
font-family: monospace;
}
.cpp-symbols dd {
margin-bottom: 1em;
/* Resemble style of <footer> which is not part of xhtml1-strict */
.footer {
font-size: var(--ok-fs-5);
color: var(--ok-tc-1);
}
+101 -33
View File
@@ -5,7 +5,7 @@
\\$2 \(la\\$1\(ra\\$3
..
.if \n(.g .mso www.tmac
.TH XMLWF 1 "March 11, 2016" "" ""
.TH XMLWF 1 "March 4, 2022" "" ""
.SH NAME
xmlwf \- Determines if an XML document is well-formed
.SH SYNOPSIS
@@ -15,7 +15,27 @@ xmlwf \- Determines if an XML document is well-formed
\fBxmlwf\fR \kx
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
'in \n(.iu+\nxu
[\fB-s\fR] [\fB-n\fR] [\fB-p\fR] [\fB-x\fR] [\fB-e \fIencoding\fB\fR] [\fB-w\fR] [\fB-d \fIoutput-dir\fB\fR] [\fB-c\fR] [\fB-m\fR] [\fB-r\fR] [\fB-t\fR] [\fB-N\fR] [\fB-v\fR] [file ...]
[\fIOPTIONS\fR] [\fIFILE\fR ...]
'in \n(.iu-\nxu
.ad b
'hy
'nh
.fi
.ad l
\fBxmlwf\fR \kx
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
'in \n(.iu+\nxu
\fB-h\fR
'in \n(.iu-\nxu
.ad b
'hy
'nh
.fi
.ad l
\fBxmlwf\fR \kx
.if (\nx>(\n(.l/2)) .nr x (\n(.l/5)
'in \n(.iu+\nxu
\fB-v\fR
'in \n(.iu-\nxu
.ad b
'hy
@@ -34,7 +54,7 @@ following rules:
\(bu
The file begins with an XML declaration. For instance,
\*(T<<?xml version="1.0" standalone="yes"?>\*(T>.
\fINOTE:\fR
\fINOTE\fR:
\fBxmlwf\fR does not currently
check for a valid XML declaration.
.TP 0.2i
@@ -62,10 +82,42 @@ it does not check the DTD. However, it does support
external entities (see the \*(T<\fB\-x\fR\*(T> option).
.SH OPTIONS
When an option includes an argument, you may specify the argument either
separately ("\*(T<\fB\-d\fR\*(T> output") or concatenated with the
option ("\*(T<\fB\-d\fR\*(T>output"). \fBxmlwf\fR
separately ("\*(T<\fB\-d\fR\*(T> \fIoutput\fR") or concatenated with the
option ("\*(T<\fB\-d\fR\*(T>\fIoutput\fR"). \fBxmlwf\fR
supports both.
.TP
\*(T<\fB\-a\fR\*(T> \fIfactor\fR
Sets the maximum tolerated amplification factor
for protection against billion laughs attacks (default: 100.0).
The amplification factor is calculated as ..
.nf
amplification := (direct + indirect) / direct
.fi
\&.. while parsing, whereas
<direct> is the number of bytes read
from the primary document in parsing and
<indirect> is the number of bytes
added by expanding entities and reading of external DTD files,
combined.
\fINOTE\fR:
If you ever need to increase this value for non-attack payload,
please file a bug report.
.TP
\*(T<\fB\-b\fR\*(T> \fIbytes\fR
Sets the number of output bytes (including amplification)
needed to activate protection against billion laughs attacks
(default: 8 MiB).
This can be thought of as an "activation threshold".
\fINOTE\fR:
If you ever need to increase this value for non-attack payload,
please file a bug report.
.TP
\*(T<\fB\-c\fR\*(T>
If the input file is well-formed and \fBxmlwf\fR
doesn't encounter any errors, the input file is simply copied to
@@ -73,7 +125,7 @@ the output directory unchanged.
This implies no namespaces (turns off \*(T<\fB\-n\fR\*(T>) and
requires \*(T<\fB\-d\fR\*(T> to specify an output directory.
.TP
\*(T<\fB\-d output\-dir\fR\*(T>
\*(T<\fB\-d\fR\*(T> \fIoutput-dir\fR
Specifies a directory to contain transformed
representations of the input files.
By default, \*(T<\fB\-d\fR\*(T> outputs a canonical representation
@@ -96,7 +148,7 @@ is treated equivalently to data.
More on canonical XML can be found at
http://www.jclark.com/xml/canonxml.html .
.TP
\*(T<\fB\-e encoding\fR\*(T>
\*(T<\fB\-e\fR\*(T> \fIencoding\fR
Specifies the character encoding for the document, overriding
any document encoding declaration. \fBxmlwf\fR
supports four built-in encodings:
@@ -106,6 +158,15 @@ supports four built-in encodings:
\*(T<ISO\-8859\-1\*(T>.
Also see the \*(T<\fB\-w\fR\*(T> option.
.TP
\*(T<\fB\-k\fR\*(T>
When processing multiple files, \fBxmlwf\fR
by default halts after the the first file with an error.
This tells \fBxmlwf\fR to report the error
but to keep processing.
This can be useful, for example, when testing a filter that converts
many files to XML and you want to quickly find out which conversions
failed.
.TP
\*(T<\fB\-m\fR\*(T>
Outputs some strange sort of XML file that completely
describes the input file, including character positions.
@@ -121,7 +182,7 @@ This matches the example output used by the formal XML test cases.
Requires \*(T<\fB\-d\fR\*(T> to specify an output file.
.TP
\*(T<\fB\-p\fR\*(T>
Tells xmlwf to process external DTDs and parameter
Tells \fBxmlwf\fR to process external DTDs and parameter
entities.
Normally \fBxmlwf\fR never parses parameter
@@ -165,7 +226,7 @@ then exits.
Enables support for Windows code pages.
Normally, \fBxmlwf\fR will throw an error if it
runs across an encoding that it is not equipped to handle itself. With
\*(T<\fB\-w\fR\*(T>, xmlwf will try to use a Windows code
\*(T<\fB\-w\fR\*(T>, \fBxmlwf\fR will try to use a Windows code
page. See also \*(T<\fB\-e\fR\*(T>.
.TP
\*(T<\fB\-x\fR\*(T>
@@ -210,18 +271,33 @@ will run \fBxmlwf\fR on the file
Older versions of \fBxmlwf\fR do not support
reading from standard input.
.SH OUTPUT
If an input file is not well-formed,
\fBxmlwf\fR prints a single line describing
the problem to standard output. If a file is well formed,
\fBxmlwf\fR outputs nothing.
Note that the result code is \fInot\fR set.
.SH BUGS
\fBxmlwf\fR returns a 0 - noerr result,
even if the file is not well-formed. There is no good way for
a program to use \fBxmlwf\fR to quickly
check a file -- it must parse \fBxmlwf\fR's
standard output.
\fBxmlwf\fR outputs nothing for files which are problem-free.
If any input file is not well-formed, or if the output for any
input file cannot be opened, \fBxmlwf\fR prints a single
line describing the problem to standard output.
.PP
If the \*(T<\fB\-k\fR\*(T> option is not provided, \fBxmlwf\fR
halts upon encountering a well-formedness or output-file error.
If \*(T<\fB\-k\fR\*(T> is provided, \fBxmlwf\fR continues
processing the remaining input files, describing problems found with any of them.
.SH "EXIT STATUS"
For option \*(T<\fB\-v\fR\*(T> or \*(T<\fB\-h\fR\*(T>, \fBxmlwf\fR always exits with status code 0. For other cases, the following exit status codes are returned:
.TP
\*(T<\fB0\fR\*(T>
The input files are well-formed and the output (if requested) was written successfully.
.TP
\*(T<\fB1\fR\*(T>
An internal error occurred.
.TP
\*(T<\fB2\fR\*(T>
One or more input files were not well-formed or could not be parsed.
.TP
\*(T<\fB3\fR\*(T>
If using the \*(T<\fB\-d\fR\*(T> option, an error occurred opening an output file.
.TP
\*(T<\fB4\fR\*(T>
There was a command-line argument error in how \fBxmlwf\fR was invoked.
.SH BUGS
The errors should go to standard error, not standard output.
.PP
There should be a way to get \*(T<\fB\-d\fR\*(T> to send its
@@ -232,24 +308,16 @@ I have no idea why anyone would want to use the
\*(T<\fB\-d\fR\*(T>, \*(T<\fB\-c\fR\*(T>, and
\*(T<\fB\-m\fR\*(T> options. If someone could explain it to
me, I'd like to add this information to this manpage.
.SH ALTERNATIVES
Here are some XML validators on the web:
.nf
http://www.hcrc.ed.ac.uk/~richard/xml\-check.html
http://www.stg.brown.edu/service/xmlvalid/
http://www.scripting.com/frontier5/xml/code/xmlValidator.html
http://www.xml.com/pub/a/tools/ruwf/check.html
.fi
.SH "SEE ALSO"
.nf
The Expat home page: http://www.libexpat.org/
The W3 XML specification: http://www.w3.org/TR/REC\-xml
The Expat home page: https://libexpat.github.io/
The W3 XML 1.0 specification (fourth edition): https://www.w3.org/TR/2006/REC\-xml\-20060816/
Billion laughs attack: https://en.wikipedia.org/wiki/Billion_laughs_attack
.fi
.SH AUTHOR
This manual page was written by Scott Bronson <\*(T<[email protected]\*(T>> for
This manual page was originally written by Scott Bronson <\*(T<[email protected]\*(T>>
in December 2001 for
the Debian GNU/Linux system (but may be used by others). Permission is
granted to copy, distribute and/or modify this document under
the terms of the GNU Free Documentation
+149 -63
View File
@@ -1,11 +1,28 @@
<!DOCTYPE refentry [
<!-- Fill in your name for FIRSTNAME and SURNAME. -->
<!--
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 2001 Scott Bronson <bronson@rinspin.com>
Copyright (c) 2002-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2009 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2016 Ardo van Rangelrooij <ardo@debian.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2020 Joe Orton <jorton@redhat.com>
Copyright (c) 2021 Tim Bray <tbray@textuality.com>
Unlike most of Expat,
this file is copyrighted under the GNU Free Documentation License 1.1.
-->
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
<!ENTITY dhfirstname "<firstname>Scott</firstname>">
<!ENTITY dhsurname "<surname>Bronson</surname>">
<!-- Please adjust the date whenever revising the manpage. -->
<!ENTITY dhdate "<date>March 11, 2016</date>">
<!-- SECTION should be 1-8, maybe w/ subsection other parameters are
allowed: see man(7), man(1). -->
<!ENTITY dhdate "<date>March 4, 2022</date>">
<!-- Please adjust this^^ date whenever cutting a new release. -->
<!ENTITY dhsection "<manvolnum>1</manvolnum>">
<!ENTITY dhemail "<email>[email protected]</email>">
<!ENTITY dhusername "Scott Bronson">
@@ -44,25 +61,16 @@
<refsynopsisdiv>
<cmdsynopsis>
<command>&dhpackage;</command>
<arg><option>-s</option></arg>
<arg><option>-n</option></arg>
<arg><option>-p</option></arg>
<arg><option>-x</option></arg>
<arg><option>-e <replaceable>encoding</replaceable></option></arg>
<arg><option>-w</option></arg>
<arg><option>-d <replaceable>output-dir</replaceable></option></arg>
<arg><option>-c</option></arg>
<arg><option>-m</option></arg>
<arg><option>-r</option></arg>
<arg><option>-t</option></arg>
<arg><option>-N</option></arg>
<arg><option>-v</option></arg>
<arg>file ...</arg>
<arg><replaceable>OPTIONS</replaceable></arg>
<arg><replaceable>FILE</replaceable> ...</arg>
</cmdsynopsis>
<cmdsynopsis>
<command>&dhpackage;</command>
<arg choice="plain"><option>-h</option></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>&dhpackage;</command>
<arg choice="plain"><option>-v</option></arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -95,7 +103,7 @@
<listitem><para>
The file begins with an XML declaration. For instance,
<literal>&lt;?xml version="1.0" standalone="yes"?&gt;</literal>.
<emphasis>NOTE:</emphasis>
<emphasis>NOTE</emphasis>:
<command>&dhpackage;</command> does not currently
check for a valid XML declaration.
</para></listitem>
@@ -132,13 +140,57 @@
<para>
When an option includes an argument, you may specify the argument either
separately ("<option>-d</option> output") or concatenated with the
option ("<option>-d</option>output"). <command>&dhpackage;</command>
separately ("<option>-d</option> <replaceable>output</replaceable>") or concatenated with the
option ("<option>-d</option><replaceable>output</replaceable>"). <command>&dhpackage;</command>
supports both.
</para>
<variablelist>
<varlistentry>
<term><option>-a</option> <replaceable>factor</replaceable></term>
<listitem>
<para>
Sets the maximum tolerated amplification factor
for protection against billion laughs attacks (default: 100.0).
The amplification factor is calculated as ..
</para>
<literallayout>
amplification := (direct + indirect) / direct
</literallayout>
<para>
.. while parsing, whereas
&lt;direct&gt; is the number of bytes read
from the primary document in parsing and
&lt;indirect&gt; is the number of bytes
added by expanding entities and reading of external DTD files,
combined.
</para>
<para>
<emphasis>NOTE</emphasis>:
If you ever need to increase this value for non-attack payload,
please file a bug report.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-b</option> <replaceable>bytes</replaceable></term>
<listitem>
<para>
Sets the number of output bytes (including amplification)
needed to activate protection against billion laughs attacks
(default: 8 MiB).
This can be thought of as an &quot;activation threshold&quot;.
</para>
<para>
<emphasis>NOTE</emphasis>:
If you ever need to increase this value for non-attack payload,
please file a bug report.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-c</option></term>
<listitem>
@@ -153,7 +205,7 @@ supports both.
</varlistentry>
<varlistentry>
<term><option>-d output-dir</option></term>
<term><option>-d</option> <replaceable>output-dir</replaceable></term>
<listitem>
<para>
Specifies a directory to contain transformed
@@ -184,7 +236,7 @@ supports both.
</varlistentry>
<varlistentry>
<term><option>-e encoding</option></term>
<term><option>-e</option> <replaceable>encoding</replaceable></term>
<listitem>
<para>
Specifies the character encoding for the document, overriding
@@ -199,6 +251,21 @@ supports both.
</listitem>
</varlistentry>
<varlistentry>
<term><option>-k</option></term>
<listitem>
<para>
When processing multiple files, <command>&dhpackage;</command>
by default halts after the the first file with an error.
This tells <command>&dhpackage;</command> to report the error
but to keep processing.
This can be useful, for example, when testing a filter that converts
many files to XML and you want to quickly find out which conversions
failed.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-m</option></term>
<listitem>
@@ -235,7 +302,7 @@ supports both.
<term><option>-p</option></term>
<listitem>
<para>
Tells xmlwf to process external DTDs and parameter
Tells <command>&dhpackage;</command> to process external DTDs and parameter
entities.
</para>
<para>
@@ -292,7 +359,7 @@ supports both.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option></term>
<listitem>
@@ -311,7 +378,7 @@ supports both.
Enables support for Windows code pages.
Normally, <command>&dhpackage;</command> will throw an error if it
runs across an encoding that it is not equipped to handle itself. With
<option>-w</option>, &dhpackage; will try to use a Windows code
<option>-w</option>, <command>&dhpackage;</command> will try to use a Windows code
page. See also <option>-e</option>.
</para>
</listitem>
@@ -379,23 +446,55 @@ supports both.
<refsect1>
<title>OUTPUT</title>
<para>
If an input file is not well-formed,
<command>&dhpackage;</command> prints a single line describing
the problem to standard output. If a file is well formed,
<command>&dhpackage;</command> outputs nothing.
Note that the result code is <emphasis>not</emphasis> set.
<command>&dhpackage;</command> outputs nothing for files which are problem-free.
If any input file is not well-formed, or if the output for any
input file cannot be opened, <command>&dhpackage;</command> prints a single
line describing the problem to standard output.
</para>
<para>
If the <option>-k</option> option is not provided, <command>&dhpackage;</command>
halts upon encountering a well-formedness or output-file error.
If <option>-k</option> is provided, <command>&dhpackage;</command> continues
processing the remaining input files, describing problems found with any of them.
</para>
</refsect1>
<refsect1>
<title>EXIT STATUS</title>
<para>For option <option>-v</option> or <option>-h</option>, <command>&dhpackage;</command> always exits with status code 0. For other cases, the following exit status codes are returned:
<variablelist>
<varlistentry>
<term><option>0</option></term>
<listitem><para>The input files are well-formed and the output (if requested) was written successfully.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>1</option></term>
<listitem><para>An internal error occurred.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>2</option></term>
<listitem><para>One or more input files were not well-formed or could not be parsed.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>3</option></term>
<listitem><para>If using the <option>-d</option> option, an error occurred opening an output file.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>4</option></term>
<listitem><para>There was a command-line argument error in how <command>&dhpackage;</command> was invoked.</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1>
<title>BUGS</title>
<para>
<command>&dhpackage;</command> returns a 0 - noerr result,
even if the file is not well-formed. There is no good way for
a program to use <command>&dhpackage;</command> to quickly
check a file -- it must parse <command>&dhpackage;</command>'s
standard output.
</para>
<para>
The errors should go to standard error, not standard output.
</para>
@@ -412,28 +511,14 @@ supports both.
</para>
</refsect1>
<refsect1>
<title>ALTERNATIVES</title>
<para>
Here are some XML validators on the web:
<literallayout>
http://www.hcrc.ed.ac.uk/~richard/xml-check.html
http://www.stg.brown.edu/service/xmlvalid/
http://www.scripting.com/frontier5/xml/code/xmlValidator.html
http://www.xml.com/pub/a/tools/ruwf/check.html
</literallayout>
</para>
</refsect1>
<refsect1>
<title>SEE ALSO</title>
<para>
<literallayout>
The Expat home page: http://www.libexpat.org/
The W3 XML specification: http://www.w3.org/TR/REC-xml
The Expat home page: https://libexpat.github.io/
The W3 XML 1.0 specification (fourth edition): https://www.w3.org/TR/2006/REC-xml-20060816/
Billion laughs attack: https://en.wikipedia.org/wiki/Billion_laughs_attack
</literallayout>
</para>
@@ -442,7 +527,8 @@ The W3 XML specification: http://www.w3.org/TR/REC-xml
<refsect1>
<title>AUTHOR</title>
<para>
This manual page was written by &dhusername; &dhemail; for
This manual page was originally written by &dhusername; &dhemail;
in December 2001 for
the &debian; system (but may be used by others). Permission is
granted to copy, distribute and/or modify this document under
the terms of the <acronym>GNU</acronym> Free Documentation
+3 -2
View File
@@ -6,7 +6,8 @@
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2017 Expat development team
# Copyright (c) 2017 Sebastian Pipping <[email protected]>
# Copyright (c) 2020 Jeffrey Walton <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
@@ -28,7 +29,7 @@
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
# USE OR OTHER DEALINGS IN THE SOFTWARE.
AM_CPPFLAGS = -I$(srcdir)/../lib
AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(srcdir)/../lib
noinst_PROGRAMS = elements outline
+26 -8
View File
@@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.16.1 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -22,7 +22,8 @@
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2017 Expat development team
# Copyright (c) 2017 Sebastian Pipping <[email protected]>
# Copyright (c) 2020 Jeffrey Walton <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
@@ -210,14 +211,16 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in \
$(top_srcdir)/conftools/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_CFLAGS = @AM_CFLAGS@
AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(srcdir)/../lib
AM_CXXFLAGS = @AM_CXXFLAGS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AM_LDFLAGS = @AM_LDFLAGS@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
@@ -227,8 +230,10 @@ AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CMAKE_SHARED_LIBRARY_PREFIX = @CMAKE_SHARED_LIBRARY_PREFIX@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
@@ -244,7 +249,15 @@ ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
EXPAT_ATTR_INFO = @EXPAT_ATTR_INFO@
EXPAT_CHAR_TYPE = @EXPAT_CHAR_TYPE@
EXPAT_CONTEXT_BYTES = @EXPAT_CONTEXT_BYTES@
EXPAT_DTD = @EXPAT_DTD@
EXPAT_LARGE_SIZE = @EXPAT_LARGE_SIZE@
EXPAT_MIN_SIZE = @EXPAT_MIN_SIZE@
EXPAT_NS = @EXPAT_NS@
FGREP = @FGREP@
FILEMAP = @FILEMAP@
GREP = @GREP@
@@ -257,6 +270,8 @@ LD = @LD@
LDFLAGS = @LDFLAGS@
LIBAGE = @LIBAGE@
LIBCURRENT = @LIBCURRENT@
LIBDIR_BASENAME = @LIBDIR_BASENAME@
LIBM = @LIBM@
LIBOBJS = @LIBOBJS@
LIBREVISION = @LIBREVISION@
LIBS = @LIBS@
@@ -286,6 +301,9 @@ RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SO_MAJOR = @SO_MAJOR@
SO_MINOR = @SO_MINOR@
SO_PATCH = @SO_PATCH@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
@@ -296,6 +314,7 @@ ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
ac_cv_sizeof_void_p = @ac_cv_sizeof_void_p@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -333,6 +352,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -341,7 +361,6 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CPPFLAGS = -I$(srcdir)/../lib
elements_SOURCES = elements.c
elements_LDADD = ../lib/libexpat.la
outline_SOURCES = outline.c
@@ -490,7 +509,6 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
+6 -1
View File
@@ -11,7 +11,12 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
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-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:
Permission is hereby granted, free of charge, to any person obtaining
+6 -2
View File
@@ -8,8 +8,12 @@
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
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-2019 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+6 -4
View File
@@ -30,15 +30,15 @@
/* Define to 1 if you have the `bsd' library (-lbsd). */
#undef HAVE_LIBBSD
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have a working `mmap' system call. */
#undef HAVE_MMAP
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdio.h> header file. */
#undef HAVE_STDIO_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
@@ -87,7 +87,9 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
/* Define to 1 if all of the C90 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */
#undef STDC_HEADERS
/* Version number of package */
+1 -1
View File
@@ -6,7 +6,7 @@
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2019 Expat development team
# Copyright (c) 2019 Sebastian Pipping <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
+64
View File
@@ -0,0 +1,64 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <assert.h>
#include <stdint.h>
#include "expat.h"
#include "siphash.h"
// Macros to convert preprocessor macros to string literals. See
// https://gcc.gnu.org/onlinedocs/gcc-3.4.3/cpp/Stringification.html
#define xstr(s) str(s)
#define str(s) #s
// The encoder type that we wish to fuzz should come from the compile-time
// definition `ENCODING_FOR_FUZZING`. This allows us to have a separate fuzzer
// binary for
#ifndef ENCODING_FOR_FUZZING
# error "ENCODING_FOR_FUZZING was not provided to this fuzz target."
#endif
// 16-byte deterministic hash key.
static unsigned char hash_key[16] = "FUZZING IS FUN!";
static void XMLCALL
start(void *userData, const XML_Char *name, const XML_Char **atts) {
(void)userData;
(void)name;
(void)atts;
}
static void XMLCALL
end(void *userData, const XML_Char *name) {
(void)userData;
(void)name;
}
int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
XML_Parser p = XML_ParserCreate(xstr(ENCODING_FOR_FUZZING));
assert(p);
// Set the hash salt using siphash to generate a deterministic hash.
struct sipkey *key = sip_keyof(hash_key);
XML_SetHashSalt(p, (unsigned long)siphash24(data, size, key));
XML_SetElementHandler(p, start, end);
XML_Parse(p, (const XML_Char *)data, size, 0);
XML_Parse(p, (const XML_Char *)data, size, 1);
XML_ParserFree(p);
return 0;
}
@@ -0,0 +1,71 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <assert.h>
#include <stdint.h>
#include <string.h>
#include "expat.h"
#include "siphash.h"
// Macros to convert preprocessor macros to string literals. See
// https://gcc.gnu.org/onlinedocs/gcc-3.4.3/cpp/Stringification.html
#define xstr(s) str(s)
#define str(s) #s
// The encoder type that we wish to fuzz should come from the compile-time
// definition `ENCODING_FOR_FUZZING`. This allows us to have a separate fuzzer
// binary for
#ifndef ENCODING_FOR_FUZZING
# error "ENCODING_FOR_FUZZING was not provided to this fuzz target."
#endif
// 16-byte deterministic hash key.
static unsigned char hash_key[16] = "FUZZING IS FUN!";
static void XMLCALL
start(void *userData, const XML_Char *name, const XML_Char **atts) {
(void)userData;
(void)name;
(void)atts;
}
static void XMLCALL
end(void *userData, const XML_Char *name) {
(void)userData;
(void)name;
}
int
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size == 0)
return 0;
XML_Parser p = XML_ParserCreate(xstr(ENCODING_FOR_FUZZING));
assert(p);
XML_SetElementHandler(p, start, end);
// Set the hash salt using siphash to generate a deterministic hash.
struct sipkey *key = sip_keyof(hash_key);
XML_SetHashSalt(p, (unsigned long)siphash24(data, size, key));
void *buf = XML_GetBuffer(p, size);
assert(buf);
memcpy(buf, data, size);
XML_ParseBuffer(p, size, size == 0);
XML_ParserFree(p);
return 0;
}
+14 -2
View File
@@ -6,7 +6,9 @@
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2017 Expat development team
# Copyright (c) 2017-2021 Sebastian Pipping <[email protected]>
# Copyright (c) 2017 Tomasz Kłoczko <[email protected]>
# Copyright (c) 2019 David Loffredo <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
@@ -34,16 +36,26 @@ include_HEADERS = \
expat_external.h
lib_LTLIBRARIES = libexpat.la
noinst_LTLIBRARIES = libexpatinternal.la
libexpat_la_LDFLAGS = \
@AM_LDFLAGS@ \
@LIBM@ \
-no-undefined \
-version-info @LIBCURRENT@:@LIBREVISION@:@LIBAGE@
libexpat_la_SOURCES = \
libexpat_la_SOURCES =
# This layer of indirection allows
# the test suite to access internal symbols
# despite compiling with -fvisibility=hidden
libexpatinternal_la_SOURCES = \
xmlparse.c \
xmltok.c \
xmlrole.c
libexpat_la_LIBADD = libexpatinternal.la
doc_DATA = \
../AUTHORS \
../Changes
+71 -24
View File
@@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.16.1 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -22,7 +22,9 @@
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2017 Expat development team
# Copyright (c) 2017-2021 Sebastian Pipping <[email protected]>
# Copyright (c) 2017 Tomasz Kłoczko <[email protected]>
# Copyright (c) 2019 David Loffredo <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
@@ -171,9 +173,9 @@ am__uninstall_files_from_dir = { \
}
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(docdir)" \
"$(DESTDIR)$(includedir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
libexpat_la_LIBADD =
am_libexpat_la_OBJECTS = xmlparse.lo xmltok.lo xmlrole.lo
LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES)
libexpat_la_DEPENDENCIES = libexpatinternal.la
am_libexpat_la_OBJECTS =
libexpat_la_OBJECTS = $(am_libexpat_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@@ -182,6 +184,9 @@ am__v_lt_1 =
libexpat_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(libexpat_la_LDFLAGS) $(LDFLAGS) -o $@
libexpatinternal_la_LIBADD =
am_libexpatinternal_la_OBJECTS = xmlparse.lo xmltok.lo xmlrole.lo
libexpatinternal_la_OBJECTS = $(am_libexpatinternal_la_OBJECTS)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@@ -218,8 +223,8 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = $(libexpat_la_SOURCES)
DIST_SOURCES = $(libexpat_la_SOURCES)
SOURCES = $(libexpat_la_SOURCES) $(libexpatinternal_la_SOURCES)
DIST_SOURCES = $(libexpat_la_SOURCES) $(libexpatinternal_la_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@@ -244,14 +249,16 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in \
$(top_srcdir)/conftools/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_CFLAGS = @AM_CFLAGS@
AM_CPPFLAGS = @AM_CPPFLAGS@
AM_CXXFLAGS = @AM_CXXFLAGS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AM_LDFLAGS = @AM_LDFLAGS@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
@@ -261,8 +268,10 @@ AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CMAKE_SHARED_LIBRARY_PREFIX = @CMAKE_SHARED_LIBRARY_PREFIX@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
@@ -278,7 +287,15 @@ ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
EXPAT_ATTR_INFO = @EXPAT_ATTR_INFO@
EXPAT_CHAR_TYPE = @EXPAT_CHAR_TYPE@
EXPAT_CONTEXT_BYTES = @EXPAT_CONTEXT_BYTES@
EXPAT_DTD = @EXPAT_DTD@
EXPAT_LARGE_SIZE = @EXPAT_LARGE_SIZE@
EXPAT_MIN_SIZE = @EXPAT_MIN_SIZE@
EXPAT_NS = @EXPAT_NS@
FGREP = @FGREP@
FILEMAP = @FILEMAP@
GREP = @GREP@
@@ -291,6 +308,8 @@ LD = @LD@
LDFLAGS = @LDFLAGS@
LIBAGE = @LIBAGE@
LIBCURRENT = @LIBCURRENT@
LIBDIR_BASENAME = @LIBDIR_BASENAME@
LIBM = @LIBM@
LIBOBJS = @LIBOBJS@
LIBREVISION = @LIBREVISION@
LIBS = @LIBS@
@@ -320,6 +339,9 @@ RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SO_MAJOR = @SO_MAJOR@
SO_MINOR = @SO_MINOR@
SO_PATCH = @SO_PATCH@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
@@ -330,6 +352,7 @@ ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
ac_cv_sizeof_void_p = @ac_cv_sizeof_void_p@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -367,6 +390,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -381,15 +405,24 @@ include_HEADERS = \
expat_external.h
lib_LTLIBRARIES = libexpat.la
noinst_LTLIBRARIES = libexpatinternal.la
libexpat_la_LDFLAGS = \
@AM_LDFLAGS@ \
@LIBM@ \
-no-undefined \
-version-info @LIBCURRENT@:@LIBREVISION@:@LIBAGE@
libexpat_la_SOURCES = \
libexpat_la_SOURCES =
# This layer of indirection allows
# the test suite to access internal symbols
# despite compiling with -fvisibility=hidden
libexpatinternal_la_SOURCES = \
xmlparse.c \
xmltok.c \
xmlrole.c
libexpat_la_LIBADD = libexpatinternal.la
doc_DATA = \
../AUTHORS \
../Changes
@@ -483,9 +516,23 @@ clean-libLTLIBRARIES:
rm -f $${locs}; \
}
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@list='$(noinst_LTLIBRARIES)'; \
locs=`for p in $$list; do echo $$p; done | \
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
sort -u`; \
test -z "$$locs" || { \
echo rm -f $${locs}; \
rm -f $${locs}; \
}
libexpat.la: $(libexpat_la_OBJECTS) $(libexpat_la_DEPENDENCIES) $(EXTRA_libexpat_la_DEPENDENCIES)
$(AM_V_CCLD)$(libexpat_la_LINK) -rpath $(libdir) $(libexpat_la_OBJECTS) $(libexpat_la_LIBADD) $(LIBS)
libexpatinternal.la: $(libexpatinternal_la_OBJECTS) $(libexpatinternal_la_DEPENDENCIES) $(EXTRA_libexpatinternal_la_DEPENDENCIES)
$(AM_V_CCLD)$(LINK) $(libexpatinternal_la_OBJECTS) $(libexpatinternal_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -622,7 +669,6 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
@@ -696,7 +742,7 @@ maintainer-clean-generic:
clean: clean-am
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
mostlyclean-am
clean-noinstLTLIBRARIES mostlyclean-am
distclean: distclean-am
-rm -f ./$(DEPDIR)/xmlparse.Plo
@@ -773,16 +819,17 @@ uninstall-am: uninstall-docDATA uninstall-includeHEADERS \
.MAKE: install-am install-data-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
clean-generic clean-libLTLIBRARIES clean-libtool cscopelist-am \
ctags ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-data-hook install-docDATA install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-includeHEADERS install-info \
install-info-am install-libLTLIBRARIES install-man install-pdf \
install-pdf-am install-ps install-ps-am install-strip \
installcheck installcheck-am installdirs maintainer-clean \
clean-generic clean-libLTLIBRARIES clean-libtool \
clean-noinstLTLIBRARIES cscopelist-am ctags ctags-am distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am \
install-data-hook install-docDATA install-dvi install-dvi-am \
install-exec install-exec-am install-html install-html-am \
install-includeHEADERS install-info install-info-am \
install-libLTLIBRARIES install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-docDATA \
+5 -2
View File
@@ -6,8 +6,11 @@
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 1999-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2007 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+3 -1
View File
@@ -7,7 +7,9 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+52 -12
View File
@@ -7,7 +7,15 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2000-2005 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2001-2002 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2016 Cristian Rodríguez <crrodriguez@opensuse.org>
Copyright (c) 2016 Thomas Beutlich <tc@tbeu.de>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2022 Thijs Schreijer <thijs@thijsschreijer.nl>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@@ -115,7 +123,11 @@ enum XML_Error {
XML_ERROR_RESERVED_PREFIX_XMLNS,
XML_ERROR_RESERVED_NAMESPACE_URI,
/* Added in 2.2.1. */
XML_ERROR_INVALID_ARGUMENT
XML_ERROR_INVALID_ARGUMENT,
/* Added in 2.3.0. */
XML_ERROR_NO_BUFFER,
/* Added in 2.4.0. */
XML_ERROR_AMPLIFICATION_LIMIT_BREACH
};
enum XML_Content_Type {
@@ -163,8 +175,10 @@ struct XML_cp {
};
/* This is called for an element declaration. See above for
description of the model argument. It's the caller's responsibility
to free model when finished with it.
description of the model argument. It's the user code's responsibility
to free model when finished with it. See XML_FreeContentModel.
There is no need to free the model from the handler, it can be kept
around and freed at a later stage.
*/
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData,
const XML_Char *name,
@@ -226,6 +240,17 @@ XML_ParserCreate(const XML_Char *encoding);
and the local part will be concatenated without any separator.
It is a programming error to use the separator '\0' with namespace
triplets (see XML_SetReturnNSTriplet).
If a namespace separator is chosen that can be part of a URI or
part of an XML name, splitting an expanded name back into its
1, 2 or 3 original parts on application level in the element handler
may end up vulnerable, so these are advised against; sane choices for
a namespace separator are e.g. '\n' (line feed) and '|' (pipe).
Note that Expat does not validate namespace URIs (beyond encoding)
against RFC 3986 today (and is not required to do so with regard to
the XML 1.0 namespaces specification) but it may start doing that
in future releases. Before that, an application using Expat must
be ready to receive namespace URIs containing non-URI characters.
*/
XMLPARSEAPI(XML_Parser)
XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
@@ -306,7 +331,7 @@ typedef void(XMLCALL *XML_StartDoctypeDeclHandler)(void *userData,
const XML_Char *pubid,
int has_internal_subset);
/* This is called for the start of the DOCTYPE declaration when the
/* This is called for the end of the DOCTYPE declaration when the
closing > is encountered, but after processing any external
subset.
*/
@@ -318,7 +343,7 @@ typedef void(XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
For internal entities (<!ENTITY foo "bar">), value will
be non-NULL and systemId, publicID, and notationName will be NULL.
The value string is NOT nul-terminated; the length is provided in
The value string is NOT null-terminated; the length is provided in
the value_length argument. Since it is legal to have zero-length
values, do not use this argument to test for internal entities.
@@ -513,7 +538,7 @@ typedef struct {
Otherwise it must return XML_STATUS_ERROR.
If info does not describe a suitable encoding, then the parser will
return an XML_UNKNOWN_ENCODING error.
return an XML_ERROR_UNKNOWN_ENCODING error.
*/
typedef int(XMLCALL *XML_UnknownEncodingHandler)(void *encodingHandlerData,
const XML_Char *name,
@@ -707,7 +732,7 @@ XML_GetBase(XML_Parser parser);
/* Returns the number of the attribute/value pairs passed in last call
to the XML_StartElementHandler that were specified in the start-tag
rather than defaulted. Each attribute/value pair counts as 2; thus
this correspondds to an index into the atts array passed to the
this corresponds to an index into the atts array passed to the
XML_StartElementHandler. Returns -1 if parser == NULL.
*/
XMLPARSEAPI(int)
@@ -716,7 +741,7 @@ XML_GetSpecifiedAttributeCount(XML_Parser parser);
/* Returns the index of the ID attribute passed in the last call to
XML_StartElementHandler, or -1 if there is no ID attribute or
parser == NULL. Each attribute/value pair counts as 2; thus this
correspondds to an index into the atts array passed to the
corresponds to an index into the atts array passed to the
XML_StartElementHandler.
*/
XMLPARSEAPI(int)
@@ -997,7 +1022,10 @@ enum XML_FeatureEnum {
XML_FEATURE_SIZEOF_XML_LCHAR,
XML_FEATURE_NS,
XML_FEATURE_LARGE_SIZE,
XML_FEATURE_ATTR_INFO
XML_FEATURE_ATTR_INFO,
/* Added in Expat 2.4.0. */
XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT,
XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT
/* Additional features must be added to the end of this enum. */
};
@@ -1010,12 +1038,24 @@ typedef struct {
XMLPARSEAPI(const XML_Feature *)
XML_GetFeatureList(void);
#ifdef XML_DTD
/* Added in Expat 2.4.0. */
XMLPARSEAPI(XML_Bool)
XML_SetBillionLaughsAttackProtectionMaximumAmplification(
XML_Parser parser, float maximumAmplificationFactor);
/* Added in Expat 2.4.0. */
XMLPARSEAPI(XML_Bool)
XML_SetBillionLaughsAttackProtectionActivationThreshold(
XML_Parser parser, unsigned long long activationThresholdBytes);
#endif
/* Expat follows the semantic versioning convention.
See http://semver.org.
*/
#define XML_MAJOR_VERSION 2
#define XML_MINOR_VERSION 2
#define XML_MICRO_VERSION 9
#define XML_MINOR_VERSION 4
#define XML_MICRO_VERSION 7
#ifdef __cplusplus
}
+8 -1
View File
@@ -7,7 +7,14 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2000-2004 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2001-2002 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016 Cristian Rodríguez <crrodriguez@opensuse.org>
Copyright (c) 2016-2019 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2018 Yury Gribov <tetra2005@gmail.com>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+3 -1
View File
@@ -7,7 +7,9 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+49 -9
View File
@@ -25,8 +25,12 @@
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2002-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2003 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2016-2021 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2018 Yury Gribov <tetra2005@gmail.com>
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@@ -101,22 +105,58 @@
# endif
#endif
#include <limits.h> // ULONG_MAX
#if defined(_WIN32) && ! defined(__USE_MINGW_ANSI_STDIO)
# define EXPAT_FMT_ULL(midpart) "%" midpart "I64u"
# if defined(_WIN64) // Note: modifiers "td" and "zu" do not work for MinGW
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "I64d"
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "I64u"
# else
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d"
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u"
# endif
#else
# define EXPAT_FMT_ULL(midpart) "%" midpart "llu"
# if ! defined(ULONG_MAX)
# error Compiler did not define ULONG_MAX for us
# elif ULONG_MAX == 18446744073709551615u // 2^64-1
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld"
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "lu"
# else
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d"
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u"
# endif
#endif
#ifndef UNUSED_P
# define UNUSED_P(p) (void)p
#endif
/* NOTE BEGIN If you ever patch these defaults to greater values
for non-attack XML payload in your environment,
please file a bug report with libexpat. Thank you!
*/
#define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT \
100.0f
#define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT \
8388608 // 8 MiB, 2^23
/* NOTE END */
#include "expat.h" // so we can use type XML_Parser below
#ifdef __cplusplus
extern "C" {
#endif
#ifdef XML_ENABLE_VISIBILITY
# if XML_ENABLE_VISIBILITY
__attribute__((visibility("default")))
# endif
void _INTERNAL_trim_to_complete_utf8_characters(const char *from,
const char **fromLimRef);
#if defined(XML_DTD)
unsigned long long testingAccountingGetCountBytesDirect(XML_Parser parser);
unsigned long long testingAccountingGetCountBytesIndirect(XML_Parser parser);
const char *unsignedCharToPrintable(unsigned char c);
#endif
void
_INTERNAL_trim_to_complete_utf8_characters(const char *from,
const char **fromLimRef);
#ifdef __cplusplus
}
+3 -1
View File
@@ -7,7 +7,9 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
-143
View File
@@ -1,143 +0,0 @@
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2016 - 2017, Steve Holme, <steve_holme@hotmail.com>.
* Copyright (C) 2017, Expat development team
*
* All rights reserved.
* Licensed under the MIT license:
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
* THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of a copyright holder shall
* not be used in advertising or otherwise to promote the sale, use or other
* dealings in this Software without prior written authorization of the
* copyright holder.
*
***************************************************************************/
#if defined(_WIN32)
#include <windows.h>
#include <tchar.h>
HMODULE _Expat_LoadLibrary(LPCTSTR filename);
#if !defined(LOAD_WITH_ALTERED_SEARCH_PATH)
#define LOAD_WITH_ALTERED_SEARCH_PATH 0x00000008
#endif
#if !defined(LOAD_LIBRARY_SEARCH_SYSTEM32)
#define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
#endif
/* We use our own typedef here since some headers might lack these */
typedef HMODULE (APIENTRY *LOADLIBRARYEX_FN)(LPCTSTR, HANDLE, DWORD);
/* See function definitions in winbase.h */
#ifdef UNICODE
# ifdef _WIN32_WCE
# define LOADLIBARYEX L"LoadLibraryExW"
# else
# define LOADLIBARYEX "LoadLibraryExW"
# endif
#else
# define LOADLIBARYEX "LoadLibraryExA"
#endif
/*
* _Expat_LoadLibrary()
*
* This is used to dynamically load DLLs using the most secure method available
* for the version of Windows that we are running on.
*
* Parameters:
*
* filename [in] - The filename or full path of the DLL to load. If only the
* filename is passed then the DLL will be loaded from the
* Windows system directory.
*
* Returns the handle of the module on success; otherwise NULL.
*/
HMODULE _Expat_LoadLibrary(LPCTSTR filename)
{
HMODULE hModule = NULL;
LOADLIBRARYEX_FN pLoadLibraryEx = NULL;
/* Get a handle to kernel32 so we can access it's functions at runtime */
HMODULE hKernel32 = GetModuleHandle(TEXT("kernel32"));
if(!hKernel32)
return NULL; /* LCOV_EXCL_LINE */
/* Attempt to find LoadLibraryEx() which is only available on Windows 2000
and above */
pLoadLibraryEx = (LOADLIBRARYEX_FN) GetProcAddress(hKernel32, LOADLIBARYEX);
/* Detect if there's already a path in the filename and load the library if
there is. Note: Both back slashes and forward slashes have been supported
since the earlier days of DOS at an API level although they are not
supported by command prompt */
if(_tcspbrk(filename, TEXT("\\/"))) {
/** !checksrc! disable BANNEDFUNC 1 **/
hModule = pLoadLibraryEx ?
pLoadLibraryEx(filename, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) :
LoadLibrary(filename);
}
/* Detect if KB2533623 is installed, as LOAD_LIBARY_SEARCH_SYSTEM32 is only
supported on Windows Vista, Windows Server 2008, Windows 7 and Windows
Server 2008 R2 with this patch or natively on Windows 8 and above */
else if(pLoadLibraryEx && GetProcAddress(hKernel32, "AddDllDirectory")) {
/* Load the DLL from the Windows system directory */
hModule = pLoadLibraryEx(filename, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
}
else {
/* Attempt to get the Windows system path */
UINT systemdirlen = GetSystemDirectory(NULL, 0);
if(systemdirlen) {
/* Allocate space for the full DLL path (Room for the null terminator
is included in systemdirlen) */
size_t filenamelen = _tcslen(filename);
TCHAR *path = malloc(sizeof(TCHAR) * (systemdirlen + 1 + filenamelen));
if(path && GetSystemDirectory(path, systemdirlen)) {
/* Calculate the full DLL path */
_tcscpy(path + _tcslen(path), TEXT("\\"));
_tcscpy(path + _tcslen(path), filename);
/* Load the DLL from the Windows system directory */
/** !checksrc! disable BANNEDFUNC 1 **/
hModule = pLoadLibraryEx ?
pLoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) :
LoadLibrary(path);
}
free(path);
}
}
return hModule;
}
#else /* defined(_WIN32) */
/* ISO C requires a translation unit to contain at least one declaration
[-Wempty-translation-unit] */
typedef int _TRANSLATION_UNIT_LOAD_LIBRARY_C_NOT_EMTPY;
#endif /* defined(_WIN32) */
+2 -2
View File
@@ -6,8 +6,8 @@
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+4 -9
View File
@@ -11,6 +11,9 @@
* --------------------------------------------------------------------------
* HISTORY:
*
* 2020-10-03 (Sebastian Pipping)
* - Drop support for Visual Studio 9.0/2008 and earlier
*
* 2019-08-03 (Sebastian Pipping)
* - Mark part of sip24_valid as to be excluded from clang-format
* - Re-format code using clang-format 9
@@ -96,15 +99,7 @@
#define SIPHASH_H
#include <stddef.h> /* size_t */
#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1600)
/* For vs2003/7.1 up to vs2008/9.0; _MSC_VER 1600 is vs2010/10.0 */
typedef unsigned __int8 uint8_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
#else
# include <stdint.h> /* uint64_t uint32_t uint8_t */
#endif
#include <stdint.h> /* uint64_t uint32_t uint8_t */
/*
* Workaround to not require a C++11 compiler for using ULL suffix
+3 -1
View File
@@ -7,7 +7,9 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+1634 -147
View File
File diff suppressed because it is too large. Load diff
+14 -6
View File
@@ -7,7 +7,15 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2002-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2005-2009 Steven Solie <steven@solie.ca>
Copyright (c) 2016-2021 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
Copyright (c) 2021 Dong-hee Na <donghee.na@python.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@@ -30,15 +38,13 @@
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <expat_config.h>
#include <stddef.h>
#ifdef _WIN32
# include "winconfig.h"
#else
# ifdef HAVE_EXPAT_CONFIG_H
# include <expat_config.h>
# endif
#endif /* ndef _WIN32 */
#endif
#include "expat_external.h"
#include "internal.h"
@@ -1220,6 +1226,8 @@ common(PROLOG_STATE *state, int tok) {
#ifdef XML_DTD
if (! state->documentEntity && tok == XML_TOK_PARAM_ENTITY_REF)
return XML_ROLE_INNER_PARAM_ENTITY_REF;
#else
UNUSED_P(tok);
#endif
state->handler = error;
return XML_ROLE_ERROR;
+4 -1
View File
@@ -7,7 +7,10 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+28 -24
View File
@@ -7,7 +7,20 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2001-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2002 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2005-2009 Steven Solie <steven@solie.ca>
Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2016 Pascal Cuoq <cuoq@trust-in-soft.com>
Copyright (c) 2016 Don Lewis <truckman@apache.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2017 Alexander Bluhm <alexander.bluhm@gmx.net>
Copyright (c) 2017 Benbuck Nason <bnason@netflix.com>
Copyright (c) 2017 José Gutiérrez de la Concha <jose@zeroc.com>
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
Copyright (c) 2021 Dong-hee Na <donghee.na@python.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@@ -30,25 +43,15 @@
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <expat_config.h>
#include <stddef.h>
#include <string.h> /* memcpy */
#if defined(_MSC_VER) && (_MSC_VER <= 1700)
/* for vs2012/11.0/1700 and earlier Visual Studio compilers */
# define bool int
# define false 0
# define true 1
#else
# include <stdbool.h>
#endif
#include <stdbool.h>
#ifdef _WIN32
# include "winconfig.h"
#else
# ifdef HAVE_EXPAT_CONFIG_H
# include <expat_config.h>
# endif
#endif /* ndef _WIN32 */
#endif
#include "expat_external.h"
#include "internal.h"
@@ -95,11 +98,6 @@
+ ((((byte)[1]) & 3) << 1) + ((((byte)[2]) >> 5) & 1)] \
& (1u << (((byte)[2]) & 0x1F)))
#define UTF8_GET_NAMING(pages, p, n) \
((n) == 2 \
? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \
: ((n) == 3 ? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) : 0))
/* Detection of invalid UTF-8 sequences is based on Table 3.1B
of Unicode 3.2: http://www.unicode.org/unicode/reports/tr28/
with the additional restriction of not allowing the Unicode
@@ -269,8 +267,14 @@ sb_byteToAscii(const ENCODING *enc, const char *p) {
#define IS_NAME_CHAR(enc, p, n) (AS_NORMAL_ENCODING(enc)->isName##n(enc, p))
#define IS_NMSTRT_CHAR(enc, p, n) (AS_NORMAL_ENCODING(enc)->isNmstrt##n(enc, p))
#define IS_INVALID_CHAR(enc, p, n) \
(AS_NORMAL_ENCODING(enc)->isInvalid##n(enc, p))
#ifdef XML_MIN_SIZE
# define IS_INVALID_CHAR(enc, p, n) \
(AS_NORMAL_ENCODING(enc)->isInvalid##n \
&& AS_NORMAL_ENCODING(enc)->isInvalid##n(enc, p))
#else
# define IS_INVALID_CHAR(enc, p, n) \
(AS_NORMAL_ENCODING(enc)->isInvalid##n(enc, p))
#endif
#ifdef XML_MIN_SIZE
# define IS_NAME_CHAR_MINBPC(enc, p) \
@@ -589,13 +593,13 @@ static const struct normal_encoding ascii_encoding
static int PTRFASTCALL
unicode_byte_type(char hi, char lo) {
switch ((unsigned char)hi) {
/* 0xD800–0xDBFF first 16-bit code unit or high surrogate (W1) */
/* 0xD800-0xDBFF first 16-bit code unit or high surrogate (W1) */
case 0xD8:
case 0xD9:
case 0xDA:
case 0xDB:
return BT_LEAD4;
/* 0xDC00–0xDFFF second 16-bit code unit or low surrogate (W2) */
/* 0xDC00-0xDFFF second 16-bit code unit or low surrogate (W2) */
case 0xDC:
case 0xDD:
case 0xDE:
+5 -1
View File
@@ -7,7 +7,11 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2002-2005 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016-2017 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+26 -13
View File
@@ -1,4 +1,4 @@
/* This file is included!
/* This file is included (from xmltok.c, 1-3 times depending on XML_MIN_SIZE)!
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
@@ -7,7 +7,15 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2002-2016 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016-2022 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2018 Benjamin Peterson <benjamin@python.org>
Copyright (c) 2018 Anton Maklakov <antmak.pub@gmail.com>
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
Copyright (c) 2020 Boris Kolpackov <boris@codesynthesis.com>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@@ -32,7 +40,7 @@
#ifdef XML_TOK_IMPL_C
# ifndef IS_INVALID_CHAR
# ifndef IS_INVALID_CHAR // i.e. for UTF-16 and XML_MIN_SIZE not defined
# define IS_INVALID_CHAR(enc, ptr, n) (0)
# endif
@@ -61,7 +69,7 @@
case BT_LEAD##n: \
if (end - ptr < n) \
return XML_TOK_PARTIAL_CHAR; \
if (! IS_NAME_CHAR(enc, ptr, n)) { \
if (IS_INVALID_CHAR(enc, ptr, n) || ! IS_NAME_CHAR(enc, ptr, n)) { \
*nextTokPtr = ptr; \
return XML_TOK_INVALID; \
} \
@@ -90,7 +98,7 @@
case BT_LEAD##n: \
if (end - ptr < n) \
return XML_TOK_PARTIAL_CHAR; \
if (! IS_NMSTRT_CHAR(enc, ptr, n)) { \
if (IS_INVALID_CHAR(enc, ptr, n) || ! IS_NMSTRT_CHAR(enc, ptr, n)) { \
*nextTokPtr = ptr; \
return XML_TOK_INVALID; \
} \
@@ -1134,6 +1142,10 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
case BT_LEAD##n: \
if (end - ptr < n) \
return XML_TOK_PARTIAL_CHAR; \
if (IS_INVALID_CHAR(enc, ptr, n)) { \
*nextTokPtr = ptr; \
return XML_TOK_INVALID; \
} \
if (IS_NMSTRT_CHAR(enc, ptr, n)) { \
ptr += n; \
tok = XML_TOK_NAME; \
@@ -1262,7 +1274,7 @@ PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, const char *end,
switch (BYTE_TYPE(enc, ptr)) {
# define LEAD_CASE(n) \
case BT_LEAD##n: \
ptr += n; \
ptr += n; /* NOTE: The encoding has already been validated. */ \
break;
LEAD_CASE(2)
LEAD_CASE(3)
@@ -1331,7 +1343,7 @@ PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, const char *end,
switch (BYTE_TYPE(enc, ptr)) {
# define LEAD_CASE(n) \
case BT_LEAD##n: \
ptr += n; \
ptr += n; /* NOTE: The encoding has already been validated. */ \
break;
LEAD_CASE(2)
LEAD_CASE(3)
@@ -1510,7 +1522,7 @@ PREFIX(getAtts)(const ENCODING *enc, const char *ptr, int attsMax,
state = inName; \
}
# define LEAD_CASE(n) \
case BT_LEAD##n: \
case BT_LEAD##n: /* NOTE: The encoding has already been validated. */ \
START_NAME ptr += (n - MINBPC(enc)); \
break;
LEAD_CASE(2)
@@ -1722,7 +1734,7 @@ PREFIX(nameLength)(const ENCODING *enc, const char *ptr) {
switch (BYTE_TYPE(enc, ptr)) {
# define LEAD_CASE(n) \
case BT_LEAD##n: \
ptr += n; \
ptr += n; /* NOTE: The encoding has already been validated. */ \
break;
LEAD_CASE(2)
LEAD_CASE(3)
@@ -1767,14 +1779,15 @@ PREFIX(updatePosition)(const ENCODING *enc, const char *ptr, const char *end,
switch (BYTE_TYPE(enc, ptr)) {
# define LEAD_CASE(n) \
case BT_LEAD##n: \
ptr += n; \
ptr += n; /* NOTE: The encoding has already been validated. */ \
pos->columnNumber++; \
break;
LEAD_CASE(2)
LEAD_CASE(3)
LEAD_CASE(4)
# undef LEAD_CASE
case BT_LF:
pos->columnNumber = (XML_Size)-1;
pos->columnNumber = 0;
pos->lineNumber++;
ptr += MINBPC(enc);
break;
@@ -1783,13 +1796,13 @@ PREFIX(updatePosition)(const ENCODING *enc, const char *ptr, const char *end,
ptr += MINBPC(enc);
if (HAS_CHAR(enc, ptr, end) && BYTE_TYPE(enc, ptr) == BT_LF)
ptr += MINBPC(enc);
pos->columnNumber = (XML_Size)-1;
pos->columnNumber = 0;
break;
default:
ptr += MINBPC(enc);
pos->columnNumber++;
break;
}
pos->columnNumber++;
}
}
+2 -1
View File
@@ -7,7 +7,8 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2017-2019 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+6 -2
View File
@@ -7,7 +7,11 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2002-2006 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2017-2021 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@@ -89,7 +93,7 @@ NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr,
static const ENCODING *
NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end) {
# define ENCODING_MAX 128
char buf[ENCODING_MAX];
char buf[ENCODING_MAX] = "";
char *p = buf;
int i;
XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
+38 -3
View File
@@ -1,10 +1,45 @@
#! /usr/bin/env bash
# Copyright (C) 2017 Expat development team
# Licensed under the MIT license
# __ __ _
# ___\ \/ /_ __ __ _| |_
# / _ \\ /| '_ \ / _` | __|
# | __// \| |_) | (_| | |_
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2017-2022 Sebastian Pipping <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the
# following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
# NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
# USE OR OTHER DEALINGS IN THE SOFTWARE.
case "@host@" in
*-mingw*)
exec wine "$@"
case "$(uname -o)" in
Cygwin|Msys)
# Windows binary on Windows host
exec "$@"
;;
*)
# Windows binary on non-Windows host
exec wine "$@"
;;
esac
;;
*)
exec "$@"
+2 -1
View File
@@ -6,7 +6,8 @@
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2017 Expat development team
# Copyright (c) 2017 Sebastian Pipping <[email protected]>
# Copyright (c) 2019 Jeffrey Walton <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
+9 -4
View File
@@ -6,7 +6,9 @@
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2017 Expat development team
# Copyright (c) 2017-2021 Sebastian Pipping <[email protected]>
# Copyright (c) 2017 Rhodri James <[email protected]>
# Copyright (c) 2020 Jeffrey Walton <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
@@ -30,7 +32,7 @@
SUBDIRS = . benchmark
AM_CPPFLAGS = -I$(srcdir)/../lib
AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(srcdir)/../lib
noinst_LIBRARIES = libruntests.a
@@ -52,8 +54,11 @@ runtests_SOURCES = \
runtestspp_SOURCES = \
runtestspp.cpp
runtests_LDADD = libruntests.a ../lib/libexpat.la
runtestspp_LDADD = libruntests.a ../lib/libexpat.la
runtests_LDADD = libruntests.a ../lib/libexpatinternal.la
runtestspp_LDADD = libruntests.a ../lib/libexpatinternal.la
runtests_LDFLAGS = @AM_LDFLAGS@ @LIBM@
runtestspp_LDFLAGS = @AM_LDFLAGS@ @LIBM@
EXTRA_DIST = \
chardata.h \
+43 -15
View File
@@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.16.1 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -22,7 +22,9 @@
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2017 Expat development team
# Copyright (c) 2017-2021 Sebastian Pipping <[email protected]>
# Copyright (c) 2017 Rhodri James <[email protected]>
# Copyright (c) 2020 Jeffrey Walton <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
@@ -154,14 +156,20 @@ am_libruntests_a_OBJECTS = chardata.$(OBJEXT) structdata.$(OBJEXT) \
libruntests_a_OBJECTS = $(am_libruntests_a_OBJECTS)
am_runtests_OBJECTS = runtests.$(OBJEXT)
runtests_OBJECTS = $(am_runtests_OBJECTS)
runtests_DEPENDENCIES = libruntests.a ../lib/libexpat.la
runtests_DEPENDENCIES = libruntests.a ../lib/libexpatinternal.la
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
runtests_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(runtests_LDFLAGS) $(LDFLAGS) -o $@
am_runtestspp_OBJECTS = runtestspp.$(OBJEXT)
runtestspp_OBJECTS = $(am_runtestspp_OBJECTS)
runtestspp_DEPENDENCIES = libruntests.a ../lib/libexpat.la
runtestspp_DEPENDENCIES = libruntests.a ../lib/libexpatinternal.la
runtestspp_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(runtestspp_LDFLAGS) $(LDFLAGS) -o $@
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@@ -259,8 +267,6 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__tty_colors_dummy = \
mgn= red= grn= lgn= blu= brg= std=; \
am__color_tests=no
@@ -443,6 +449,7 @@ am__set_TESTS_bases = \
bases='$(TEST_LOGS)'; \
bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
bases=`echo $$bases`
AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)'
RECHECK_LOGS = $(TEST_LOGS)
TEST_SUITE_LOG = test-suite.log
TEST_EXTENSIONS = @EXEEXT@ .test
@@ -495,7 +502,11 @@ am__relativize = \
reldir="$$dir2"
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_CFLAGS = @AM_CFLAGS@
AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(srcdir)/../lib
AM_CXXFLAGS = @AM_CXXFLAGS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AM_LDFLAGS = @AM_LDFLAGS@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
@@ -505,8 +516,10 @@ AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CMAKE_SHARED_LIBRARY_PREFIX = @CMAKE_SHARED_LIBRARY_PREFIX@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
@@ -522,7 +535,15 @@ ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
EXPAT_ATTR_INFO = @EXPAT_ATTR_INFO@
EXPAT_CHAR_TYPE = @EXPAT_CHAR_TYPE@
EXPAT_CONTEXT_BYTES = @EXPAT_CONTEXT_BYTES@
EXPAT_DTD = @EXPAT_DTD@
EXPAT_LARGE_SIZE = @EXPAT_LARGE_SIZE@
EXPAT_MIN_SIZE = @EXPAT_MIN_SIZE@
EXPAT_NS = @EXPAT_NS@
FGREP = @FGREP@
FILEMAP = @FILEMAP@
GREP = @GREP@
@@ -535,6 +556,8 @@ LD = @LD@
LDFLAGS = @LDFLAGS@
LIBAGE = @LIBAGE@
LIBCURRENT = @LIBCURRENT@
LIBDIR_BASENAME = @LIBDIR_BASENAME@
LIBM = @LIBM@
LIBOBJS = @LIBOBJS@
LIBREVISION = @LIBREVISION@
LIBS = @LIBS@
@@ -564,6 +587,9 @@ RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SO_MAJOR = @SO_MAJOR@
SO_MINOR = @SO_MINOR@
SO_PATCH = @SO_PATCH@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
@@ -574,6 +600,7 @@ ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
ac_cv_sizeof_void_p = @ac_cv_sizeof_void_p@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -611,6 +638,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -620,7 +648,6 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = . benchmark
AM_CPPFLAGS = -I$(srcdir)/../lib
noinst_LIBRARIES = libruntests.a
# To support MinGW and Non-MinGW at the same time:
@@ -637,8 +664,10 @@ runtests_SOURCES = \
runtestspp_SOURCES = \
runtestspp.cpp
runtests_LDADD = libruntests.a ../lib/libexpat.la
runtestspp_LDADD = libruntests.a ../lib/libexpat.la
runtests_LDADD = libruntests.a ../lib/libexpatinternal.la
runtestspp_LDADD = libruntests.a ../lib/libexpatinternal.la
runtests_LDFLAGS = @AM_LDFLAGS@ @LIBM@
runtestspp_LDFLAGS = @AM_LDFLAGS@ @LIBM@
EXTRA_DIST = \
chardata.h \
structdata.h \
@@ -702,11 +731,11 @@ libruntests.a: $(libruntests_a_OBJECTS) $(libruntests_a_DEPENDENCIES) $(EXTRA_li
runtests$(EXEEXT): $(runtests_OBJECTS) $(runtests_DEPENDENCIES) $(EXTRA_runtests_DEPENDENCIES)
@rm -f runtests$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(runtests_OBJECTS) $(runtests_LDADD) $(LIBS)
$(AM_V_CCLD)$(runtests_LINK) $(runtests_OBJECTS) $(runtests_LDADD) $(LIBS)
runtestspp$(EXEEXT): $(runtestspp_OBJECTS) $(runtestspp_DEPENDENCIES) $(EXTRA_runtestspp_DEPENDENCIES)
@rm -f runtestspp$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(runtestspp_OBJECTS) $(runtestspp_LDADD) $(LIBS)
$(AM_V_CXXLD)$(runtestspp_LINK) $(runtestspp_OBJECTS) $(runtestspp_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -981,7 +1010,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
fi; \
echo "$${col}$$br$${std}"; \
echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \
echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \
echo "$${col}$$br$${std}"; \
create_testsuite_report --maybe-color; \
echo "$$col$$br$$std"; \
@@ -1043,7 +1072,6 @@ runtestspp.log: runtestspp$(EXEEXT)
@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
+3 -2
View File
@@ -6,7 +6,8 @@
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2017 Expat development team
# Copyright (c) 2017 Sebastian Pipping <[email protected]>
# Copyright (c) 2020 Jeffrey Walton <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
@@ -28,7 +29,7 @@
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
# USE OR OTHER DEALINGS IN THE SOFTWARE.
AM_CPPFLAGS = -I$(srcdir)/../../lib
AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(srcdir)/../../lib
noinst_PROGRAMS = benchmark
+26 -8
View File
@@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.16.1 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -22,7 +22,8 @@
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2017 Expat development team
# Copyright (c) 2017 Sebastian Pipping <[email protected]>
# Copyright (c) 2020 Jeffrey Walton <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
@@ -207,14 +208,16 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in \
$(top_srcdir)/conftools/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_CFLAGS = @AM_CFLAGS@
AM_CPPFLAGS = @AM_CPPFLAGS@ -I$(srcdir)/../../lib
AM_CXXFLAGS = @AM_CXXFLAGS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AM_LDFLAGS = @AM_LDFLAGS@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
@@ -224,8 +227,10 @@ AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CMAKE_SHARED_LIBRARY_PREFIX = @CMAKE_SHARED_LIBRARY_PREFIX@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
@@ -241,7 +246,15 @@ ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
EXPAT_ATTR_INFO = @EXPAT_ATTR_INFO@
EXPAT_CHAR_TYPE = @EXPAT_CHAR_TYPE@
EXPAT_CONTEXT_BYTES = @EXPAT_CONTEXT_BYTES@
EXPAT_DTD = @EXPAT_DTD@
EXPAT_LARGE_SIZE = @EXPAT_LARGE_SIZE@
EXPAT_MIN_SIZE = @EXPAT_MIN_SIZE@
EXPAT_NS = @EXPAT_NS@
FGREP = @FGREP@
FILEMAP = @FILEMAP@
GREP = @GREP@
@@ -254,6 +267,8 @@ LD = @LD@
LDFLAGS = @LDFLAGS@
LIBAGE = @LIBAGE@
LIBCURRENT = @LIBCURRENT@
LIBDIR_BASENAME = @LIBDIR_BASENAME@
LIBM = @LIBM@
LIBOBJS = @LIBOBJS@
LIBREVISION = @LIBREVISION@
LIBS = @LIBS@
@@ -283,6 +298,9 @@ RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SO_MAJOR = @SO_MAJOR@
SO_MINOR = @SO_MINOR@
SO_PATCH = @SO_PATCH@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
@@ -293,6 +311,7 @@ ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
ac_cv_sizeof_void_p = @ac_cv_sizeof_void_p@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -330,6 +349,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -338,7 +358,6 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CPPFLAGS = -I$(srcdir)/../../lib
benchmark_SOURCES = benchmark.c
benchmark_LDADD = ../../lib/libexpat.la
EXTRA_DIST = \
@@ -483,7 +502,6 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
+4 -2
View File
@@ -6,8 +6,10 @@
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2003-2006 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2005-2007 Steven Solie <steven@solie.ca>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@@ -1,25 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "benchmark", "benchmark.vcxproj", "{FF89BA66-62C4-49EC-9189-1E7B603A1FD6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
Template|Win32 = Template|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FF89BA66-62C4-49EC-9189-1E7B603A1FD6}.Debug|Win32.ActiveCfg = Debug|Win32
{FF89BA66-62C4-49EC-9189-1E7B603A1FD6}.Debug|Win32.Build.0 = Debug|Win32
{FF89BA66-62C4-49EC-9189-1E7B603A1FD6}.Release|Win32.ActiveCfg = Release|Win32
{FF89BA66-62C4-49EC-9189-1E7B603A1FD6}.Release|Win32.Build.0 = Release|Win32
{FF89BA66-62C4-49EC-9189-1E7B603A1FD6}.Template|Win32.ActiveCfg = Template|Win32
{FF89BA66-62C4-49EC-9189-1E7B603A1FD6}.Template|Win32.Build.0 = Template|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
+7 -5
View File
@@ -6,8 +6,12 @@
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2002-2004 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2003 Greg Stein <gstein@users.sourceforge.net>
Copyright (c) 2016 Gilles Espinasse <g.esp@free.fr>
Copyright (c) 2016-2021 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Joe Orton <jorton@redhat.com>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@@ -30,9 +34,7 @@
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifdef HAVE_EXPAT_CONFIG_H
# include <expat_config.h>
#endif
#include <expat_config.h>
#include "minicheck.h"
#include <assert.h>
+3 -2
View File
@@ -7,8 +7,9 @@
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2002-2004 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+2 -2
View File
@@ -6,8 +6,8 @@
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+2 -2
View File
@@ -7,8 +7,8 @@
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+24 -12
View File
@@ -10,8 +10,11 @@
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2004-2006 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2016-2020 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2018 Marco Maggi <marco.maggi-ipsu@poste.it>
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@@ -141,11 +144,18 @@ _check_set_test_info(char const *function, char const *filename, int lineno) {
}
static void
add_failure(SRunner *runner, int verbosity) {
runner->nfailures++;
handle_success(int verbosity) {
if (verbosity >= CK_VERBOSE) {
printf("%s:%d: %s\n", _check_current_filename, _check_current_lineno,
_check_current_function);
printf("PASS: %s\n", _check_current_function);
}
}
static void
handle_failure(SRunner *runner, int verbosity, const char *phase_info) {
runner->nfailures++;
if (verbosity != CK_SILENT) {
printf("FAIL: %s (%s at %s:%d)\n", _check_current_function, phase_info,
_check_current_filename, _check_current_lineno);
}
}
@@ -164,14 +174,14 @@ srunner_run_all(SRunner *runner, int verbosity) {
if (tc->setup != NULL) {
/* setup */
if (setjmp(env)) {
add_failure(runner, verbosity);
handle_failure(runner, verbosity, "during setup");
continue;
}
tc->setup();
}
/* test */
if (setjmp(env)) {
add_failure(runner, verbosity);
handle_failure(runner, verbosity, "during actual test");
continue;
}
(tc->tests[i])();
@@ -179,15 +189,17 @@ srunner_run_all(SRunner *runner, int verbosity) {
/* teardown */
if (tc->teardown != NULL) {
if (setjmp(env)) {
add_failure(runner, verbosity);
handle_failure(runner, verbosity, "during teardown");
continue;
}
tc->teardown();
}
handle_success(verbosity);
}
tc = tc->next_tcase;
}
if (verbosity) {
if (verbosity != CK_SILENT) {
int passed = runner->nchecks - runner->nfailures;
double percentage = ((double)passed) / runner->nchecks;
int display = (int)(percentage * 100);
@@ -203,8 +215,8 @@ _fail_unless(int condition, const char *file, int line, const char *msg) {
it is.
*/
UNUSED_P(condition);
UNUSED_P(file);
UNUSED_P(line);
_check_current_filename = file;
_check_current_lineno = line;
if (msg != NULL) {
const int has_newline = (msg[strlen(msg) - 1] == '\n');
fprintf(stderr, "ERROR: %s%s", msg, has_newline ? "" : "\n");
+3 -2
View File
@@ -12,8 +12,9 @@
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2004-2006 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2006-2012 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016-2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
File diff suppressed because it is too large. Load diff
-24
View File
@@ -1,24 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "runtests", "runtests.vcxproj", "{63D6D820-B526-4A5F-9605-9B8551FAC591}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
Template|Win32 = Template|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{63D6D820-B526-4A5F-9605-9B8551FAC591}.Debug|Win32.ActiveCfg = Debug|Win32
{63D6D820-B526-4A5F-9605-9B8551FAC591}.Debug|Win32.Build.0 = Debug|Win32
{63D6D820-B526-4A5F-9605-9B8551FAC591}.Release|Win32.ActiveCfg = Release|Win32
{63D6D820-B526-4A5F-9605-9B8551FAC591}.Release|Win32.Build.0 = Release|Win32
{63D6D820-B526-4A5F-9605-9B8551FAC591}.Template|Win32.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
+2 -2
View File
@@ -9,8 +9,8 @@
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2005 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+3 -5
View File
@@ -6,8 +6,8 @@
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2017-2021 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@@ -30,9 +30,7 @@
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifdef HAVE_EXPAT_CONFIG_H
# include "expat_config.h"
#endif
#include "expat_config.h"
#include <assert.h>
#include <stdlib.h>
+1 -2
View File
@@ -7,8 +7,7 @@
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+2 -1
View File
@@ -6,7 +6,8 @@
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2017 Expat development team
# Copyright (c) 2017 Rhodri James <[email protected]>
# Copyright (c) 2017 Sebastian Pipping <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
+37 -6
View File
@@ -1,24 +1,55 @@
#! /usr/bin/env bash
# EXPAT TEST SCRIPT FOR W3C XML TEST SUITE
# EXPAT TEST SCRIPT FOR W3C XML TEST SUITE
#
# This script can be used to exercise Expat against the
# w3c.org xml test suite, available from
# http://www.w3.org/XML/Test/xmlts20020606.zip.
#
# To run this script, first set XMLWF below so that xmlwf can be
# found, then set the output directory with OUTPUT.
#
# The script lists all test cases where Expat shows a discrepancy
# from the expected result. Test cases where only the canonical
# output differs are prefixed with "Output differs:", and a diff file
# is generated in the appropriate subdirectory under $OUTPUT.
#
# If there are output files provided, the script will use
# output from xmlwf and compare the desired output against it.
# However, one has to take into account that the canonical output
# produced by xmlwf conforms to an older definition of canonical XML
# and does not generate notation declarations.
#
# __ __ _
# ___\ \/ /_ __ __ _| |_
# / _ \\ /| '_ \ / _` | __|
# | __// \| |_) | (_| | |_
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2002-2004 Fred L. Drake, Jr. <[email protected]>
# Copyright (c) 2002 Karl Waclawek <[email protected]>
# Copyright (c) 2008-2019 Sebastian Pipping <[email protected]>
# Copyright (c) 2017 Rhodri James <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the
# following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
# NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
# USE OR OTHER DEALINGS IN THE SOFTWARE.
shopt -s nullglob
+4 -3
View File
@@ -6,7 +6,7 @@
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2017 Expat development team
# Copyright (c) 2017-2021 Sebastian Pipping <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
@@ -37,12 +37,13 @@ xmlwf_SOURCES = \
codepage.c \
@[email protected]
xmlwf_CPPFLAGS = -I$(srcdir)/../lib
xmlwf_CPPFLAGS = @AM_CPPFLAGS@ -I$(srcdir)/../lib
xmlwf_LDFLAGS = @AM_LDFLAGS@ @LIBM@
if MINGW
if UNICODE
xmlwf_CPPFLAGS += -mwindows
xmlwf_LDFLAGS = -municode
xmlwf_LDFLAGS += -municode
endif
endif
+28 -9
View File
@@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.16.1 from Makefile.am.
# Makefile.in generated by automake 1.16.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -22,7 +22,7 @@
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2017 Expat development team
# Copyright (c) 2017-2021 Sebastian Pipping <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
@@ -120,6 +120,7 @@ build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = xmlwf$(EXEEXT)
@MINGW_TRUE@@UNICODE_TRUE@am__append_1 = -mwindows
@MINGW_TRUE@@UNICODE_TRUE@am__append_2 = -municode
subdir = xmlwf
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
@@ -215,14 +216,16 @@ am__define_uniq_tagged_files = \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in \
$(top_srcdir)/conftools/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_CFLAGS = @AM_CFLAGS@
AM_CPPFLAGS = @AM_CPPFLAGS@
AM_CXXFLAGS = @AM_CXXFLAGS@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AM_LDFLAGS = @AM_LDFLAGS@
AR = @AR@
AS = @AS@
AUTOCONF = @AUTOCONF@
@@ -232,8 +235,10 @@ AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CMAKE_SHARED_LIBRARY_PREFIX = @CMAKE_SHARED_LIBRARY_PREFIX@
CPPFLAGS = @CPPFLAGS@
CSCOPE = @CSCOPE@
CTAGS = @CTAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
@@ -249,7 +254,15 @@ ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
EXPAT_ATTR_INFO = @EXPAT_ATTR_INFO@
EXPAT_CHAR_TYPE = @EXPAT_CHAR_TYPE@
EXPAT_CONTEXT_BYTES = @EXPAT_CONTEXT_BYTES@
EXPAT_DTD = @EXPAT_DTD@
EXPAT_LARGE_SIZE = @EXPAT_LARGE_SIZE@
EXPAT_MIN_SIZE = @EXPAT_MIN_SIZE@
EXPAT_NS = @EXPAT_NS@
FGREP = @FGREP@
FILEMAP = @FILEMAP@
GREP = @GREP@
@@ -262,6 +275,8 @@ LD = @LD@
LDFLAGS = @LDFLAGS@
LIBAGE = @LIBAGE@
LIBCURRENT = @LIBCURRENT@
LIBDIR_BASENAME = @LIBDIR_BASENAME@
LIBM = @LIBM@
LIBOBJS = @LIBOBJS@
LIBREVISION = @LIBREVISION@
LIBS = @LIBS@
@@ -291,6 +306,9 @@ RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SO_MAJOR = @SO_MAJOR@
SO_MINOR = @SO_MINOR@
SO_PATCH = @SO_PATCH@
STRIP = @STRIP@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
@@ -301,6 +319,7 @@ ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
ac_cv_sizeof_void_p = @ac_cv_sizeof_void_p@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -338,6 +357,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -353,8 +373,8 @@ xmlwf_SOURCES = \
codepage.c \
@[email protected]
xmlwf_CPPFLAGS = -I$(srcdir)/../lib $(am__append_1)
@MINGW_TRUE@@UNICODE_TRUE@xmlwf_LDFLAGS = -municode
xmlwf_CPPFLAGS = @AM_CPPFLAGS@ -I$(srcdir)/../lib $(am__append_1)
xmlwf_LDFLAGS = @AM_LDFLAGS@ @LIBM@ $(am__append_2)
EXTRA_DIST = \
codepage.h \
ct.c \
@@ -605,7 +625,6 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
+15 -16
View File
@@ -7,7 +7,11 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2005-2006 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016-2019 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@@ -38,9 +42,11 @@
# define WIN32_LEAN_AND_MEAN 1
# include <windows.h>
#endif /* defined(_WIN32) */
int
codepageMap(int cp, int *map) {
#if defined(_WIN32)
int i;
CPINFO info;
if (! GetCPInfo(cp, &info) || info.MaxCharSize > 2)
@@ -68,32 +74,25 @@ codepageMap(int cp, int *map) {
}
}
return 1;
#else
UNUSED_P(cp);
UNUSED_P(map);
return 0;
#endif
}
int
codepageConvert(int cp, const char *p) {
#if defined(_WIN32)
unsigned short c;
if (MultiByteToWideChar(cp, MB_PRECOMPOSED | MB_ERR_INVALID_CHARS, p, 2, &c,
1)
== 1)
return c;
return -1;
}
#else /* not _WIN32 */
int
codepageMap(int cp, int *map) {
UNUSED_P(cp);
UNUSED_P(map);
return 0;
}
int
codepageConvert(int cp, const char *p) {
#else
UNUSED_P(cp);
UNUSED_P(p);
return -1;
#endif
}
#endif /* not _WIN32 */
+3 -1
View File
@@ -7,7 +7,9 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2016-2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+2 -1
View File
@@ -7,7 +7,8 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2016-2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+3 -1
View File
@@ -7,7 +7,9 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2016-2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+6 -1
View File
@@ -7,7 +7,12 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2001-2004 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2002-2009 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016-2017 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2017 Franek Korta <fkorta@gmail.com>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+5 -1
View File
@@ -7,7 +7,11 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2001-2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2006 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016-2017 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+3 -1
View File
@@ -7,7 +7,9 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2016-2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+12 -5
View File
@@ -7,7 +7,14 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002-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-2021 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
Copyright (c) 2021 Dong-hee Na <donghee.na@python.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@@ -30,6 +37,8 @@
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <expat_config.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
@@ -38,9 +47,7 @@
#ifdef _WIN32
# include "winconfig.h"
#elif defined(HAVE_EXPAT_CONFIG_H)
# include <expat_config.h>
#endif /* ndef _WIN32 */
#endif
#include "expat.h"
#include "internal.h" /* for UNUSED_P only */
@@ -176,7 +183,7 @@ externalEntityRefFilemap(XML_Parser parser, const XML_Char *context,
static int
processStream(const XML_Char *filename, XML_Parser parser) {
/* passing NULL for filename means read intput from stdin */
/* passing NULL for filename means read input from stdin */
int fd = 0; /* 0 is the fileno for stdin */
if (filename != NULL) {
+4 -1
View File
@@ -7,7 +7,10 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2005 Karl Waclawek <karl@waclawek.net>
Copyright (c) 2016-2019 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+3 -1
View File
@@ -7,7 +7,9 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2016-2018 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2018 Marco Maggi <marco.maggi-ipsu@poste.it>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+2 -1
View File
@@ -7,7 +7,8 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2002 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2016-2017 Sebastian Pipping <sebastian@pipping.org>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
+6 -1
View File
@@ -7,7 +7,8 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2016-2021 Sebastian Pipping <sebastian@pipping.org>
Copyright (c) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@@ -54,6 +55,8 @@
# define tmain wmain
# define tremove _wremove
# define tchar wchar_t
# define tcstof wcstof
# define tcstoull wcstoull
#else /* not XML_UNICODE */
# define T(x) x
# define ftprintf fprintf
@@ -71,4 +74,6 @@
# define tmain main
# define tremove remove
# define tchar char
# define tcstof strtof
# define tcstoull strtoull
#endif /* not XML_UNICODE */
-45
View File
@@ -1,45 +0,0 @@
/*
__ __ _
___\ \/ /_ __ __ _| |_
/ _ \\ /| '_ \ / _` | __|
| __// \| |_) | (_| | |_
\___/_/\_\ .__/ \__,_|\__|
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifdef __cplusplus
extern "C" {
#endif
int XML_URLInit();
void XML_URLUninit();
int XML_ProcessURL(XML_Parser parser,
const XML_Char *url,
unsigned flags);
#ifdef __cplusplus
}
#endif
+157 -29
View File
@@ -7,7 +7,16 @@
|_| XML parser
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
Copyright (c) 2000-2017 Expat development team
Copyright (c) 2000 Clark Cooper <coopercc@users.sourceforge.net>
Copyright (c) 2001-2003 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
Copyright (c) 2004-2009 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) 2017 Rhodri James <rhodri@wildebeest.org.uk>
Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
Copyright (c) 2020 Joe Orton <jorton@redhat.com>
Copyright (c) 2020 Kleber Tarcísio <klebertarcisio@yahoo.com.br>
Copyright (c) 2021 Tim Bray <tbray@textuality.com>
Licensed under the MIT license:
Permission is hereby granted, free of charge, to any person obtaining
@@ -30,11 +39,15 @@
USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <expat_config.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <math.h> /* for isnan */
#include <errno.h>
#include "expat.h"
#include "codepage.h"
@@ -50,6 +63,14 @@
# include <wchar.h>
#endif
enum ExitCode {
XMLWF_EXIT_SUCCESS = 0,
XMLWF_EXIT_INTERNAL_ERROR = 1,
XMLWF_EXIT_NOT_WELLFORMED = 2,
XMLWF_EXIT_OUTPUT_ERROR = 3,
XMLWF_EXIT_USAGE_ERROR = 4,
};
/* Structures for handler user data */
typedef struct NotationList {
struct NotationList *next;
@@ -322,6 +343,13 @@ freeNotations(XmlwfUserData *data) {
data->notationListHead = NULL;
}
static void
cleanupUserData(XmlwfUserData *userData) {
free((void *)userData->currentDoctypeName);
userData->currentDoctypeName = NULL;
freeNotations(userData);
}
static int
xcscmp(const XML_Char *xs, const XML_Char *xt) {
while (*xs != 0 && *xt != 0) {
@@ -848,16 +876,19 @@ usage(const XML_Char *prog, int rc) {
stderr,
/* Generated with:
* $ xmlwf/xmlwf_helpgen.sh
* To update, change xmlwf/xmlwf_helpgen.py, then paste the output of
* xmlwf/xmlwf_helpgen.sh in here.
*/
/* clang-format off */
T("usage: %s [-s] [-n] [-p] [-x] [-e ENCODING] [-w] [-r] [-d DIRECTORY]\n")
T(" [-c | -m | -t] [-N]\n")
T(" [FILE [FILE ...]]\n")
T("usage:\n")
T(" %s [OPTIONS] [FILE ...]\n")
T(" %s -h\n")
T(" %s -v\n")
T("\n")
T("xmlwf - Determines if an XML document is well-formed\n")
T("\n")
T("positional arguments:\n")
T(" FILE files to process (default: STDIN)\n")
T(" FILE file to process (default: STDIN)\n")
T("\n")
T("input control arguments:\n")
T(" -s print an error if the document is not [s]tandalone\n")
@@ -867,6 +898,7 @@ usage(const XML_Char *prog, int rc) {
T(" -e ENCODING override any in-document [e]ncoding declaration\n")
T(" -w enable support for [W]indows code pages\n")
T(" -r disable memory-mapping and use normal file [r]ead IO calls instead\n")
T(" -k when processing multiple files, [k]eep processing after first file with error\n")
T("\n")
T("output control arguments:\n")
T(" -d DIRECTORY output [d]estination directory\n")
@@ -875,14 +907,27 @@ usage(const XML_Char *prog, int rc) {
T(" -t write no XML output for [t]iming of plain parsing\n")
T(" -N enable adding doctype and [n]otation declarations\n")
T("\n")
T("billion laughs attack protection:\n")
T(" NOTE: If you ever need to increase these values for non-attack payload, please file a bug report.\n")
T("\n")
T(" -a FACTOR set maximum tolerated [a]mplification factor (default: 100.0)\n")
T(" -b BYTES set number of output [b]ytes needed to activate (default: 8 MiB)\n")
T("\n")
T("info arguments:\n")
T(" -h show this [h]elp message and exit\n")
T(" -v show program's [v]ersion number and exit\n")
T("\n")
T("libexpat is software libre, licensed under the MIT license.\n")
T("exit status:\n")
T(" 0 the input files are well-formed and the output (if requested) was written successfully\n")
T(" 1 could not allocate data structures, signals a serious problem with execution environment\n")
T(" 2 one or more input files were not well-formed\n")
T(" 3 could not create an output file\n")
T(" 4 command-line argument error\n")
T("\n")
T("xmlwf of libexpat is software libre, licensed under the MIT license.\n")
T("Please report bugs at https://github.com/libexpat/libexpat/issues. Thank you!\n")
, /* clang-format on */
prog);
prog, prog, prog);
exit(rc);
}
@@ -891,6 +936,19 @@ usage(const XML_Char *prog, int rc) {
int wmain(int argc, XML_Char **argv);
#endif
#define XMLWF_SHIFT_ARG_INTO(constCharStarTarget, argc, argv, i, j) \
{ \
if (argv[i][j + 1] == T('\0')) { \
if (++i == argc) \
usage(argv[0], XMLWF_EXIT_USAGE_ERROR); \
constCharStarTarget = argv[i]; \
} else { \
constCharStarTarget = argv[i] + j + 1; \
} \
i++; \
j = 0; \
}
int
tmain(int argc, XML_Char **argv) {
int i, j;
@@ -902,6 +960,13 @@ tmain(int argc, XML_Char **argv) {
int useNamespaces = 0;
int requireStandalone = 0;
int requiresNotations = 0;
int continueOnError = 0;
float attackMaximumAmplification = -1.0f; /* signaling "not set" */
unsigned long long attackThresholdBytes;
XML_Bool attackThresholdGiven = XML_FALSE;
int exitCode = XMLWF_EXIT_SUCCESS;
enum XML_ParamEntityParsing paramEntityParsing
= XML_PARAM_ENTITY_PARSING_NEVER;
int useStdin = 0;
@@ -965,31 +1030,64 @@ tmain(int argc, XML_Char **argv) {
j++;
break;
case T('d'):
if (argv[i][j + 1] == T('\0')) {
if (++i == argc)
usage(argv[0], 2);
outputDir = argv[i];
} else
outputDir = argv[i] + j + 1;
i++;
j = 0;
XMLWF_SHIFT_ARG_INTO(outputDir, argc, argv, i, j);
break;
case T('e'):
if (argv[i][j + 1] == T('\0')) {
if (++i == argc)
usage(argv[0], 2);
encoding = argv[i];
} else
encoding = argv[i] + j + 1;
i++;
j = 0;
XMLWF_SHIFT_ARG_INTO(encoding, argc, argv, i, j);
break;
case T('h'):
usage(argv[0], 0);
usage(argv[0], XMLWF_EXIT_SUCCESS);
return 0;
case T('v'):
showVersion(argv[0]);
return 0;
case T('k'):
continueOnError = 1;
j++;
break;
case T('a'): {
const XML_Char *valueText = NULL;
XMLWF_SHIFT_ARG_INTO(valueText, argc, argv, i, j);
errno = 0;
XML_Char *afterValueText = (XML_Char *)valueText;
attackMaximumAmplification = tcstof(valueText, &afterValueText);
if ((errno != 0) || (afterValueText[0] != T('\0'))
|| isnan(attackMaximumAmplification)
|| (attackMaximumAmplification < 1.0f)) {
// This prevents tperror(..) from reporting misleading "[..]: Success"
errno = ERANGE;
tperror(T("invalid amplification limit") T(
" (needs a floating point number greater or equal than 1.0)"));
exit(XMLWF_EXIT_USAGE_ERROR);
}
#ifndef XML_DTD
ftprintf(stderr, T("Warning: Given amplification limit ignored") T(
", xmlwf has been compiled without DTD support.\n"));
#endif
break;
}
case T('b'): {
const XML_Char *valueText = NULL;
XMLWF_SHIFT_ARG_INTO(valueText, argc, argv, i, j);
errno = 0;
XML_Char *afterValueText = (XML_Char *)valueText;
attackThresholdBytes = tcstoull(valueText, &afterValueText, 10);
if ((errno != 0) || (afterValueText[0] != T('\0'))) {
// This prevents tperror(..) from reporting misleading "[..]: Success"
errno = ERANGE;
tperror(T("invalid ignore threshold")
T(" (needs an integer from 0 to 2^64-1)"));
exit(XMLWF_EXIT_USAGE_ERROR);
}
attackThresholdGiven = XML_TRUE;
#ifndef XML_DTD
ftprintf(stderr, T("Warning: Given attack threshold ignored") T(
", xmlwf has been compiled without DTD support.\n"));
#endif
break;
}
case T('\0'):
if (j > 1) {
i++;
@@ -998,7 +1096,7 @@ tmain(int argc, XML_Char **argv) {
}
/* fall through */
default:
usage(argv[0], 2);
usage(argv[0], XMLWF_EXIT_USAGE_ERROR);
}
}
if (i == argc) {
@@ -1017,7 +1115,22 @@ tmain(int argc, XML_Char **argv) {
if (! parser) {
tperror(T("Could not instantiate parser"));
exit(1);
exit(XMLWF_EXIT_INTERNAL_ERROR);
}
if (attackMaximumAmplification != -1.0f) {
#ifdef XML_DTD
XML_SetBillionLaughsAttackProtectionMaximumAmplification(
parser, attackMaximumAmplification);
#endif
}
if (attackThresholdGiven) {
#ifdef XML_DTD
XML_SetBillionLaughsAttackProtectionActivationThreshold(
parser, attackThresholdBytes);
#else
(void)attackThresholdBytes; // silence -Wunused-but-set-variable
#endif
}
if (requireStandalone)
@@ -1051,13 +1164,24 @@ tmain(int argc, XML_Char **argv) {
}
outName = (XML_Char *)malloc((tcslen(outputDir) + tcslen(file) + 2)
* sizeof(XML_Char));
if (! outName) {
tperror(T("Could not allocate memory"));
exit(XMLWF_EXIT_INTERNAL_ERROR);
}
tcscpy(outName, outputDir);
tcscat(outName, delim);
tcscat(outName, file);
userData.fp = tfopen(outName, T("wb"));
if (! userData.fp) {
tperror(outName);
exit(1);
exitCode = XMLWF_EXIT_OUTPUT_ERROR;
free(outName);
XML_ParserFree(parser);
if (continueOnError) {
continue;
} else {
break;
}
}
setvbuf(userData.fp, NULL, _IOFBF, 16384);
#ifdef XML_UNICODE
@@ -1119,8 +1243,12 @@ tmain(int argc, XML_Char **argv) {
}
XML_ParserFree(parser);
if (! result) {
exit(2);
exitCode = XMLWF_EXIT_NOT_WELLFORMED;
cleanupUserData(&userData);
if (! continueOnError) {
break;
}
}
}
return 0;
return exitCode;
}
+27 -3
View File
@@ -6,7 +6,8 @@
# \___/_/\_\ .__/ \__,_|\__|
# |_| XML parser
#
# Copyright (c) 2019 Expat development team
# Copyright (c) 2019-2021 Sebastian Pipping <[email protected]>
# Copyright (c) 2021 Tim Bray <[email protected]>
# Licensed under the MIT license:
#
# Permission is hereby granted, free of charge, to any person obtaining
@@ -31,11 +32,25 @@
import argparse
epilog = """
libexpat is software libre, licensed under the MIT license.
exit status:
0 the input files are well-formed and the output (if requested) was written successfully
1 could not allocate data structures, signals a serious problem with execution environment
2 one or more input files were not well-formed
3 could not create an output file
4 command-line argument error
xmlwf of libexpat is software libre, licensed under the MIT license.
Please report bugs at https://github.com/libexpat/libexpat/issues. Thank you!
"""
usage = """
%(prog)s [OPTIONS] [FILE ...]
%(prog)s -h
%(prog)s -v
"""
parser = argparse.ArgumentParser(prog='xmlwf', add_help=False,
usage=usage,
description='xmlwf - Determines if an XML document is well-formed',
formatter_class=argparse.RawTextHelpFormatter,
epilog=epilog)
@@ -48,6 +63,7 @@ input_related.add_argument('-x', action='store_true', help='enable processing of
input_related.add_argument('-e', action='store', metavar='ENCODING', help='override any in-document [e]ncoding declaration')
input_related.add_argument('-w', action='store_true', help='enable support for [W]indows code pages')
input_related.add_argument('-r', action='store_true', help='disable memory-mapping and use normal file [r]ead IO calls instead')
input_related.add_argument('-k', action='store_true', help='when processing multiple files, [k]eep processing after first file with error')
output_related = parser.add_argument_group('output control arguments')
output_related.add_argument('-d', action='store', metavar='DIRECTORY', help='output [d]estination directory')
@@ -57,7 +73,15 @@ output_mode.add_argument('-m', action='store_true', help='write [m]eta XML, not
output_mode.add_argument('-t', action='store_true', help='write no XML output for [t]iming of plain parsing')
output_related.add_argument('-N', action='store_true', help='enable adding doctype and [n]otation declarations')
parser.add_argument('files', metavar='FILE', nargs='*', help='files to process (default: STDIN)')
billion_laughs = parser.add_argument_group('billion laughs attack protection',
description='NOTE: '
'If you ever need to increase these values '
'for non-attack payload, please file a bug report.')
billion_laughs.add_argument('-a', metavar='FACTOR',
help='set maximum tolerated [a]mplification factor (default: 100.0)')
billion_laughs.add_argument('-b', metavar='BYTES', help='set number of output [b]ytes needed to activate (default: 8 MiB)')
parser.add_argument('files', metavar='FILE', nargs='*', help='file to process (default: STDIN)')
info = parser.add_argument_group('info arguments')
info = info.add_mutually_exclusive_group()
Loaded 100 of 1203 files, more files were not shown because too many files have changed in this diff. Show more