Compare commits

...
596 Commits
Author SHA1 Message Date
Jessica Clarke 9aed7107bb mips: Extract HWREna configuration and call from APs
The intent of mips_get_identity is to perform any feature detection and
corresponding global system configuration, but currently it is also
abused to set HWREna.UL on the BSP when available, with APs being left
unconfigured. Extract that part out into its own function that gets
called after mips_get_identity on the BSP, and call it on the APs from
smp_init_secondary.

This is a direct commit to stable/13 as mips no longer exists in main.

Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D48064

(cherry picked from commit 8176157d69)
2024-12-13 21:37:51 +00:00
Jessica Clarke d4e02f74fe rtld-elf: Fix for mips with LLD 14+
As of LLD 14, it no longer falls back to the address of .text if it
can't find the entry point, and instead just uses address 0. Since the
mips port has always used rtld_start as its entry point symbol but has
never set RTLD_ENTRY to match (instead getting the default .rtld_start),
with LLD 14+ it ends up using an entry point of 0, i.e. reinterpreting
various headers and metadata sections as code, and thus quickly dies, in
my case with SIGILL. This has seemingly always been a warning with LLD
even when it defaulted to .text, but that went unnoticed this whole
time, until now. Fix this by specifying the right symbol name.

This is a direct commit to stable/13 as mips no longer exists in main.

(cherry picked from commit d7bf409a63)
2024-12-13 00:29:50 +00:00
Alex Richardson 50a53aacc9 Allow bootstrapping makefs on older FreeBSD hosts and Linux/macOS
In order to do so we need to install the msdosfs headers to the bootstrap
sysroot and avoid includes of kernel headers that may not exist on every
host (e.g. sys/lockmgr.h). This change should allow bootstrapping of makefs
on FreeBSD 11+ as well as Linux and macOS.

We also have to avoid using the IO_SYNC macro since that may not be
available. In makefs it is only used to switch between calling
bwrite() and bdwrite() which both call the same function. Therefore we
can simply always call bwrite().

For our CheriBSD builds we always bootstrap makefs by setting
LOCAL_XTOOL_DIRS='lib/libnetbsd usr.sbin/makefs' and use the makefs binary
from the build tree to create a bootable disk image.

Reviewed By:	brooks
Differential Revision: https://reviews.freebsd.org/D23201

(cherry picked from commit 162ae9c834)
2024-12-12 21:41:16 +00:00
Ed Maste 3e750057fb makefs: avoid warning when creating FAT filesystem on existing file
Previously the mkfs_msdos function (from newfs_msdos) emitted warnings
in the case that an image size is specified and the target is not a
file, or no size is specified and the target is not a character device.
The latter warning (not a character device) doesn't make sense when this
code is used in makefs, regardless of whether an image size is specified
or not.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit d9aee13f6f)
2024-12-12 21:40:40 +00:00
Jessica Clarke 0c9b413e1a mips/malta: Prefer _start over _locore for entry point symbol
These are aliases, but it's probably nicer to use the same symbol as we
use for the actual ELF entry point.

This is a direct commit to stable/13 as mips no longer exists in main.

(cherry picked from commit e32b14ef10)
2024-12-12 21:20:32 +00:00
Jessica Clarke 2151a0bec0 mips/malta: Explicitly set AP entry point to _locore
Otherwise we rely on the firmware implicitly ending up there without
faulting. Perhaps the hardware this was tested on does so, but on QEMU
this is not the case, as the AP will otherwise re-run bootloader code
that tries to reconfigure PCI BARs and ends up faulting, so the AP is
never seen by FreeBSD to have started.

This matches Linux's arch/mips/kernel/smp-mt.c:vsmp_boot_secondary,
which unconditionally writes to TCRestart (this register), albeit using
a separate entry point, whilst ours is shared.

This is a direct commit to stable/13 as mips no longer exists in main.

Obtained from:	CheriBSD (diagnosis; patch rewritten from scratch)

(cherry picked from commit cc521bcf79)
2024-12-12 21:11:15 +00:00
Eugene Grosbein 41efd8eef3 libalias: fix subtle racy problem in outside-inside forwarding
sys/netinet/libalias/alias_db.c has internal static function UseLink()
that passes a link to CleanupLink() to verify if the link has expired.
If so, UseLink() may return NULL.

_FindLinkIn()'s usage of UseLink() is not quite correct.

Assume there is "redirect_port udp" configured to forward incoming
traffic for specific port to some internal address.
Such a rule creates partially specified permanent link.

After first such incoming packet libalias creates new fully specified
temporary LINK_UDP with default timeout of 60 seconds.
Also, in case of low traffic libalias may assign "timestamp"
for this new temporary link way in the past because
LibAliasTime is updated seldom and can keep old value
for tens of seconds, and it will be used for the temporary link.

It may happen that next incoming packet for redirected port
passed to _FindLinkIn() results in a call to UseLink()
that returns NULL due to detected expiration.
Immediate return of NULL results in broken translation:
either a packet is dropped (deny_incoming mode) or delivered to
original destination address instead of internal one.

Fix it with additional check for NULL to proceed with a search
for original partially specified link. In case of UDP,
it also recreates temporary fully specified link
with a call to ReLink().

Practical examples are "redirect_port udp" rules for unidirectional
SYSLOG protocol (port 514) or some low volume VPN encapsulated in UDP.

Thanks to Peter Much for initial analysis and first version of a patch.

Reported by:	Peter Much <[email protected]>
PR:		269770

(cherry picked from commit 8132e95909)
(cherry picked from commit e5b8538083)
2024-08-25 13:47:32 +07:00
Philip Paeps 1980b3dfa1 openssh: Fix pre-authentication remote code execution in sshd.
Reported by:	Qualys Threat Research Unit (TRU)
Approved by:	so
Security:	FreeBSD-SA-24:04.openssh
Security:	CVE-2024-6387

(cherry picked from commit 2abea9df01)
(cherry picked from commit 25cf430cd5)
2024-07-01 09:25:49 -04:00
Gordon Bergling 6f545abb9a virtio(4): Fix two typos in KASSERT messages
- s/emtpy/empty/

(cherry picked from commit 018a361f89)
2024-06-21 05:47:47 +02:00
Gordon Bergling 0a2739feae camcontrol.8: Fix a typo in the manual page
- s/emtpy/empty/

(cherry picked from commit d1e652bf04)
2024-06-19 06:18:25 +02:00
Gordon Bergling 4b62662bcd ipfw: Fix a typo in a source code comment
- s/defaul/default/

(cherry picked from commit 78e4dbc345)
2024-05-16 07:59:48 +02:00
Gordon Bergling f3e5aa50fc wtap: Fix typos in kernel messages
- s/cant/can't/

(cherry picked from commit 026520a5f2)
2024-04-28 07:22:44 +02:00
Gordon Bergling cd79c46103 vmm(4): Fix a typo in a kernel message
- s/cant/can't/

(cherry picked from commit 8b5c5cae92)
2024-04-28 07:22:31 +02:00
Gordon Bergling 2e9bfb6a00 sys: Remove two double words in source code comments
- s/of of/of/

(cherry picked from commit cf5d9c4124)
2024-04-25 08:18:14 +02:00
Gordon Bergling 0cb97c19b1 mwlstats: Fix a typo in an error message
- s/the the/the/

(cherry picked from commit e1e149ad8a)
2024-04-25 08:17:58 +02:00
Gordon Bergling d7deb6833d arm: Fix a typo in a KASSERT message
- s/resoure/resource/

(cherry picked from commit 178cf4b9db)
2024-04-24 12:22:24 +02:00
Gordon Bergling d94c239888 freescale: Fix a typo in a source code comment
- s/cant/can't/

(cherry picked from commit 26f6c148bc)
2024-04-24 12:22:12 +02:00
Gordon Bergling 87f5c26218 geom(4): Fix a typo in a source code comment
- s/cant/can't/

(cherry picked from commit c0a01ee83d)
2024-04-24 12:21:59 +02:00
Gordon Bergling 656ec7b966 uipc_domain: Fix a typo in a source code comment
- s/cant/can't/

(cherry picked from commit 9576fc16ca)
2024-04-24 12:21:47 +02:00
Gordon Bergling 05b5b4e966 oce(4): Fix a typo in a source code comment
- s/addres/address/

(cherry picked from commit e991acd5d0)
2024-04-21 09:36:37 +02:00
Gordon Bergling 411f60811b muge(4): Fix a typo in a source code comment
- s/addres/address/

(cherry picked from commit 046fe202e7)
2024-04-21 09:36:19 +02:00
Gordon Bergling 2ba9bcd976 if_hn: Fix two typos in source code comments
- s/managment/management/
- s/transacion/transaction/

Obtained from:	NetBSD

(cherry picked from commit 61b88a230b)
2024-02-27 09:25:06 +01:00
Gordon Bergling ef2b2b0bf3 umcs(4): Fix two typos in source code comments
- s/frequences/frequencies/

(cherry picked from commit 059fd69e74)
2024-02-25 08:47:09 +01:00
Gordon Bergling 64d52e1605 sk(4): Fix a typo in a source code comment
- /integeated/integrated/
- s/extented/extended/

Obtained from:	NetBSD

(cherry picked from commit a53204c227)
2024-02-25 08:46:57 +01:00
Gordon Bergling eeee62ac1e bge(4): Fix some typos in source code comments
- s/firwmare/firmware/
- s/recue/reduce/
- s/throughpout/throughput/
- s/hardwares/hardware/

Obtainted from:	NetBSD

(cherry picked from commit d646dca3bc)
2024-02-25 08:46:43 +01:00
Gordon Bergling 8dbf4f6c23 random(4): Fix a typo in a source code comment
- s/parmeter/parameter/

(cherry picked from commit 5e89e34f84)
2024-02-25 08:46:29 +01:00
Gordon Bergling c513a1b09b vge(4): Fix a typo in a source code comment
- s/embadded/embedded/

(cherry picked from commit 04440331b5)
2024-02-25 08:46:11 +01:00
Gordon Bergling 442d1ee07e uath(4): Fix a typo in a source code comment
- s/parmeter/parameter/

(cherry picked from commit 5a476e64b5)
2024-02-25 08:46:00 +01:00
Gordon Bergling 13c7c0e565 iov.h: Fix a typo in a source code comment
- s/subystem/subsystem/

(cherry picked from commit f24c816daa)
2024-02-22 10:38:54 +01:00
Cy Schubert bec5e729ce heimdal: Fix NULL deref
A flawed logical condition allows a malicious actor to remotely
trigger a NULL pointer dereference using a crafted negTokenInit
token.

Upstream notes:

    Reported to Heimdal by Michał Kępień <[email protected]>.

    From the report:

    Acknowledgement
    ---------------

    This flaw was found while working on addressing ZDI-CAN-12302: ISC BIND
    TKEY Query Heap-based Buffer Overflow Remote Code Execution
    Vulnerability, which was reported to ISC by Trend Micro's Zero Day

Security:	CVE-2022-3116
Obtained from:	upstream 7a19658c1

(cherry picked from commit fc773115fa)
(cherry picked from commit 6b421e431a)
2024-02-21 15:24:16 -05:00
Eugene Grosbein 68bc302ed0 graid: MFC: unbreak Promise RAID1 with 4+ providers
Fix a problem in graid implementation of Promise RAID1 created with 4+ disks.
Such an array generally works fine until reboot only due to a bug
in metadata writing code. Before the fix, next taste erronously created
RAID1E (kind of RAID10) instead of RAID1, hence graid used wrong offsets
for I/O operations.

The bug did not affect Promise RAID1 arrays with 2 or 3 disks only.

Reviewed by:	mav

(cherry picked from commit 81092e92ea)
2024-02-16 12:31:12 +07:00
Dimitry Andric ca89a51d40 msun: remove fabs from Symbol.map, and adjust comment
We have s_fabs.c, but fabs(3) is already provided by libc due to
historical reasons, so it is not compiled into libm. When the linker
does not use --undefined-version, this leads to a complaint about the
symbol being nonexistent, so remove it from Symbol.map.

While here, adjust the comment about some functions being supplied by
libc: while it is true that all these are indeed in libc, libm still
includes its own versions of frexp(3), isnan(3), isnanf(3), and
isnanl(3).

Reported by:	Steve Kargl <[email protected]>
MFC after:	3 days

(cherry picked from commit d04e03c19a)
2024-01-30 18:52:55 +01:00
Zhenlei Huang 445eb90240 kern linker: Do not retry loading modules on EEXIST
LINKER_LOAD_FILE() calls linker_load_dependencies() which will return
EEXIST in case the module to be loaded has already been compiled into
the kernel. Since the format of the module is now recognized then there
is no need to retry loading with a different linker, otherwise the
userland will get misleading error number ENOEXEC.

PR:		274936
Reviewed by:	dfr
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D42474

(cherry picked from commit ecf710f0e0)
(cherry picked from commit e7fd435d3d)
(cherry picked from commit d18326a7cf)
2024-01-15 18:31:01 +08:00
Cy Schubert 0bbd273750 heimdal: Fix man page and documentation typos
Reported by:	Jens Schweikhardt <[email protected]>

(cherry picked from commit fc55c20355)
2024-01-04 10:42:01 -08:00
Rick Macklem 263ed87413 nfscl: Fix handling of expired Kerberos credentials (NFSv4.1/4.2)
If the NFS server detects that the Kerberos credentials provided
by a NFSv4.1/4.2 mount using sec=krb5[ip] have expired, the NFS
server replies with a krpc layer error of RPC_AUTHERROR.
When this happened, the client erroneously left the NFSv4.1/4.2
session slot busy, so that it could not be used by other RPCs.
If this happened for all session slots, the mount point would
hang.

This patch fixes the problem by releasing the session slot
and resetting its sequence# upon receiving a RPC_AUTHERROR
reply.

This bug only affects NFSv4.1/4.2 mounts using sec=krb5[ip],
but has existed since NFSv4.1 client support was added to
FreeBSD.

So, why has the bug remained undetected for so long?
I cannot be sure, but I suspect that, often, the client detected
the Kerberos credential expiration before attempting the RPC.
For this case, the client would not do the RPC and, as such,
there would be no busy session slot.  Also, no hang would
occur until all session slots are busied (64 for a FreeBSD
client/server), so many cases of the bug probably went undetected?
Also, use of sec=krb5[ip] mounts are not that common.

PR:	275905

(cherry picked from commit a558130881)
2024-01-01 17:55:14 -08:00
Dimitry Andric 9734bad361 Fix snprintf truncation in telnet
Building telnet with clang 18 results in the following warning:

  contrib/telnet/telnet/telnet.c:231:5: error: 'snprintf' will always be truncated; specified size is 10, but format string expands to at least 11 [-Werror,-Wformat-truncation]
    231 |     snprintf(temp2, sizeof(temp2), "%c%c%c%c....%c%c", IAC, SB, TELOPT_COMPORT,
	|     ^

The temp2 buffer is 10 chars, while the format string also consists of
10 chars. Therefore, snprintf(3) will truncate the last character, 'SE'
(end sub negotation) in this case.

Bump the buffer to 11 chars to avoid truncation.

MFC after:	3 days

(cherry picked from commit c794d18822)
2023-12-24 15:01:35 +01:00
Philip Paeps 98a75346bb contrib/tzdata: import tzdata 2023d
Changes: https://github.com/eggert/tz/blob/2023d/NEWS

(cherry picked from commit eebb9c2cae)
2023-12-24 09:42:38 +08:00
Rick Macklem 08143226d0 nfscl: Fix comment for commit 6aded1e6b2
Commit 6aded1e6b2 fixed a rare case when handling an NFSv4
Rename reply when delegations are in use.  This patch fixes the
associated comment.

(cherry picked from commit 0a958aa16f)
2023-12-17 13:14:30 -08:00
Rick Macklem dd6bdfcd07 nfscl: Fix processing of a rare Rename reply case
When delegations are enabled (they are not by default in
the FreeBSD NFSv4 server), rename will check for and return
delegations.  If the second of these DelegReturn operations
were to fail (they rarely do), then the code would not retry
the rename with returning delegations, as it is intended to do.

The patch fixes the problem, since the DelegReturn reply status
is the second iteration of the loop and not the first iteration.

As noted, this bug would have rarely manifested a problem, since
DelegReturn operations do not normally fail.

(cherry picked from commit 6aded1e6b2)
2023-12-17 13:13:01 -08:00
Philip Paeps 890afd892c rc.conf: correct $ntp_leapfile_sources
IETF is no longer serving leap-seconds.list.  Point at IANA instead.

This fixes "service ntpd fetch".

(cherry picked from commit b1c95af454)
2023-12-16 10:34:43 +08:00
Mark Johnston d76303c9d3 tty: Avoid a kernel memory discloure via kern.ttys
Four pad bytes at the end of each xtty structure were not being cleared
before being copied out.  Fix this by clearing the whole structure
before populating fields.

MFC after:	3 days
Reported by:	KMSAN

(cherry picked from commit 3c0fb026b2)
2023-12-14 09:29:42 -05:00
Mark Johnston a9dcfac2fd OpenZFS: Ensure that zfs_getattr() initializes the va_rdev field
Otherwise the field is left uninitialized, leading to a possible kernel
memory disclosure to userspace or to the network.  Use the same
initialization value we use in zfsctl_common_getattr().

Reported-by: KMSAN
Sponsored-by: The FreeBSD Foundation
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Ed Maste <[email protected]>
Signed-off-by: Mark Johnston <[email protected]>

(cherry picked from commit 11656234b5)
(cherry picked from commit af1e8b52d26502bac9a2484b87d1879334debd67)

Differential Revision:	https://reviews.freebsd.org/D42987
2023-12-10 12:48:51 -05:00
Xin LI 80560eec65 periodic/daily/480.leapfile-ntpd: only attempt to refresh leap-seconds.list
when ntpd is enabled.

The leap-seconds.list is used exclusively by ntpd, therefore, do not bother
to perform the fetch when ntpd is not enabled.

PR:		conf/275419
Reviewed by:	cy, michaelo, imp
Differential Revision: https://reviews.freebsd.org/D42875

(cherry picked from commit 3b3195f676)
2023-12-05 23:55:17 -08:00
Eugene Grosbein b743fda102 usbdevs: add quirk for WD MyPassport Ultra External HDD
WD MyPassport Ultra External HDD needs quirk
UQ_MSC_NO_TEST_UNIT_READY to attach.

(cherry picked from commit 970d73856b)
2023-12-06 11:32:41 +07:00
Kristof Provost 0415f0554b pf: remove incorrect fragmentation check
We do not need to check PFDESC_IP_REAS while tracking TCP state.
Moreover, this check incorrectly considers no-data packets (e.g. RST) to
be in-window when this flag is not set.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Approved by:	so
Security:	FreeBSD-SA-23:17.pf

(cherry picked from commit 6284d5f76d)
2023-12-05 13:25:58 -05:00
Eugene Grosbein 2e6541b943 rc.conf(5): add <service>_umask to run the service using this value
None of tools working with login classes change umask(1)
and we had no ways to specify non-default umask for a service
not touching its startup script. This change makes in possible.

Some file-sharing services that create new files may benefit from it.

Differential:	https://reviews.freebsd.org/D36309

(cherry picked from commit 160a2f2cdd)
2023-12-02 15:40:59 +07:00
Franco Fichtner b1e0b0cb7c rc: add ${name}_setup script support
Run a service-based setup script before running the start command.
Useful for automatic configuration file generation.

Reviewed by:	https://reviews.freebsd.org/D36006

(cherry picked from commit c9be47b34d)
2023-12-02 15:20:40 +07:00
Alan Somers c7d8a572ac libc/libc/rpc: refactor some global variables
* Combine dg_fd_locks and dg_cv into one array.
* Similarly for vc_fd_locks and vc_cv
* Turn some macros into inline functions

This is a mostly cosmetic change to make refactoring these strutures in
a future commit easier.

Sponsored by:	Axcient
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D42597

(cherry picked from commit a5c2f4e939)

lib/libc/rpc: switch the per-fd structs in clnt_{dg,vc}.c to RB Trees

This saves oodles of memory, especially when "ulimit -n" is large.  It
also prevents a buffer overflow if getrlimit should fail.

Also replace per-fd condvars with mutexes to simplify the code.

PR:		274968
Sponsored by:	Axcient
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D42597

(cherry picked from commit 24938f9311)
2023-12-01 14:15:45 -07:00
Rob Norris 8959056352 dnode_is_dirty: check dnode and its data for dirtiness
Over its history this the dirty dnode test has been changed between
checking for a dnodes being on `os_dirty_dnodes` (`dn_dirty_link`) and
`dn_dirty_record`.

It turns out both are actually required.

In the case of appending data to a newly created file, the dnode proper
is dirtied (at least to change the blocksize) and dirty records are
added.  Thus, a single logical operation is represented by separate
dirty indicators, and must not be separated.

The incorrect dirty check becomes a problem when the first block of a
file is being appended to while another process is calling lseek to skip
holes. There is a small window where the dnode part is undirtied while
there are still dirty records. In this case, `lseek(fd, 0, SEEK_DATA)`
would not know that the file is dirty, and would go to
`dnode_next_offset()`. Since the object has no data blocks yet, it
returns `ESRCH`, indicating no data found, which results in `ENXIO`
being returned to `lseek()`'s caller.

This change simply updates the dirty check to check both types of dirty.
If there's anything dirty at all, we immediately go to the "wait for
sync" stage, It doesn't really matter after that; both changes are on
disk, so the dirty fields should be correct.

Sponsored by:	Klara, Inc.
Sponsored by:	Wasabi Technology, Inc.
2023-11-30 00:28:33 -05:00
Eugene Grosbein 7342935fb3 ng_ipfw: allow use of 32 bits wide cookies
There is no reason in truncating 32 bits cookie value to 16 bits.

Reviewed by:	glebius

(cherry picked from commit 20e1f207cc)
2023-11-29 21:22:38 +07:00
Cy Schubert 8cc42e13f4 libevent: Import libevent 2.1.12
Merge commit '5223d1d95fddcef6f9a36e264a5800bd907ade8b' into main

(cherry picked from commit b50261e21f)
2023-11-27 07:26:32 -08:00
Cy Schubert 6663d2f673 Unbound: Manually update version strings
This was missed earlier today.

Reported by:	"Herbert J. Skuhra" <[email protected]>
Fixes:		16fd0b2491

(cherry picked from commit 6726773431)
2023-11-27 07:26:32 -08:00
Cy Schubert 0bca2586dc Unbound: Remove backup file brought in from upstream
Upstream tarball included config.h~.

This was previously manually removed from vendor where in fact it
should not have been as it would have caused a merge conflict.

Reported by:	"Herbert J. Skuhra" <[email protected]>

(cherry picked from commit 5aab39b24c)
2023-11-27 07:26:31 -08:00
Cy Schubert a68b13ba56 unbound: Vendor import 1.19.0
Release notes at
    https://www.nlnetlabs.nl/news/2023/Aug/30/unbound-1.19.0-released/

Merge commit '16fd0b24910488e59ca1941387b9ac7fb646a837' into unbound

(cherry picked from commit 103ba509e7)
2023-11-27 07:26:31 -08:00
Cy Schubert bad2804aec sqlite3: Vendor import of sqlite3 3.44.0
Release notes at https://www.sqlite.org/releaselog/3_44_0.html.

Obtained from:  https://www.sqlite.org/2023/sqlite-autoconf-3440000.tar.gz

Merge commit '3a88fe13354325b9f56f07927e654de4f5398707'

(cherry picked from commit 7963e41154)
2023-11-27 07:26:31 -08:00
Gordon Bergling 92dff9984d libcasper: Fix a typo in a source code comment
- s/mutiple/multiple/

(cherry picked from commit 637e4ef1a6)
2023-11-26 08:55:11 +01:00
Gordon Bergling 3d5d348bb5 ath(4): Fix a typo in a source code comment
- s/mutiple/multiple/

(cherry picked from commit 4e36d081f3)
2023-11-26 08:55:04 +01:00
Zhenlei Huang 281f61d211 bpf: Make dead_bpf_if const
The dead_bpf_if is not subjected to be written. Make it const so that
on destructive writing to it the kernel will panic instead of silent
memory corruption.

No functional change intended.

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D42189

(cherry picked from commit 7a974a6498)
(cherry picked from commit 5d031613af)
(cherry picked from commit 1e14798049)
2023-11-13 18:22:41 +08:00
Dag-Erling Smørgrav 6a0891c6eb fflush: Add test for buffer handling in __sflush
Sponsored by:	Klara, Inc.

(cherry picked from commit b8dbfb0a6c)
(cherry picked from commit ba490dfc95)
(cherry picked from commit 66d84f1362)

Approved by:	so
2023-11-07 09:30:07 -05:00
Dag-Erling Smørgrav 3a2ea31568 fflush: correct buffer handling in __sflush
This fixes CVE-2014-8611 correctly.

The commit that purported to fix CVE-2014-8611 (805288c2f0) only hid
it behind another bug.  Two later commits, 86a16ada1e and
44cf1e5eb4, attempted to address this new bug but mostly just confused
the issue.  This commit rolls back the three previous changes and fixes
CVE-2014-8611 correctly.

The key to understanding the bug (and the fix) is that `_w` has
different meanings for different stream modes.  If the stream is
unbuffered, it is always zero.  If the stream is fully buffered, it is
the amount of space remaining in the buffer (equal to the buffer size
when the buffer is empty and zero when the buffer is full).  If the
stream is line-buffered, it is a negative number reflecting the amount
of data in the buffer (zero when the buffer is empty and negative buffer
size when the buffer is full).

At the heart of `fflush()`, we call the stream's write function in a
loop, where `t` represents the return value from the last call and `n`
the amount of data that remains to be written.  When the write function
fails, we need to move the unwritten data to the top of the buffer
(unless nothing was written) and adjust `_p` (which points to the next
free location in the buffer) and `_w` accordingly.  These variables have
already been set to the values they should have after a successful
flush, so instead of adjusting them down to reflect what was written,
we're adjusting them up to reflect what remains.

The bug was that while `_p` was always adjusted, we only adjusted `_w`
if the stream was fully buffered.  The fix is to also adjust `_w` for
line-buffered streams.  Everything else is just noise.

Fixes: 805288c2f0
Fixes: 86a16ada1e
Fixes: 44cf1e5eb4
Sponsored by:	Klara, Inc.

(cherry picked from commit d09a3bf72c)
(cherry picked from commit 92709431b1)
(cherry picked from commit 6cb5690b34)

Approved by:	so
2023-11-07 09:11:54 -05:00
Dag-Erling Smørgrav 95fbce59c9 fflush: Split a temporary variable in two.
It is clearer to avoid reusing temporary variables for different
purposes.

Sponsored by:	Klara, Inc.

(cherry picked from commit 1f90b4edff)
(cherry picked from commit 1e99535be2)
(cherry picked from commit ccdd8337f9)
2023-11-06 09:43:45 -05:00
Kyle Evans ee4bdd4b0d libbe: bail out early if the zfs kmod isn't loaded
As noted in the comment, we already know the rest of libbe_init() will
fail because there's no pool imported.  Avoid the side effect by
checking beforehand and bailing out early.

With this, freebsd-update(8) should no longer trigger a load of the zfs
kmod just because it runs `bectl check`.

Reviewed by:	jwmaag_gmail.com, rew

(cherry picked from commit 2f700ca965)
2023-11-02 23:50:46 -05:00
Rick Macklem f383f4ad30 nfsd: Fix NFSv4.1/4.2 Claim_Deleg_Cur_FH
When I implemented a test patch using Open Claim_Deleg_Cur_FH
I discovered that the NFSv4.1/4.2 server was broken for this
Open option.  Fortunately it is never used by the FreeBSD
client and never used by other clients unless delegations
are enabled. (The FreeBSD NFSv4 server does not have delegations
enabled by default.)

Claim_Deleg_Cur_FH was broken because the code mistakenly
assumed a stateID argument, which is not the case.
This patch fixes the bug by changing the XDR parser to not
expect a stateID and to fill most of the stateID in from the
clientID. The clientID is the first two elements of the "other"
array for the stateID and is sufficient to identify which
client the delegation is issued to.  Since there is only one
delegation issued to a client per file, this is sufficient to
locate the correct delegation.

If you are running non-FreeBSD NFSv4.1/4.2 mounts against the
FreeBSD server, you need this patch if you have delegations enabled.

PR:	274574

(cherry picked from commit f300335d9a)
2023-11-02 16:44:27 -07:00
Zhenlei Huang 71f147c607 x86: Prefer consistent naming for loader tunables
The following loader tunables do have corresponding sysctl MIBs but
with inconsistent naming. That may be historical reason. Let's prefer
consistent naming for them so that it will be easier to maintain.

 1. hw.dmar.timeout -> hw.iommu.dmar.timeout
 2. hw.lapic_eoi_suppression -> hw.apic.eoi_suppression
 3. hw.lapic_tsc_deadline -> hw.apic.timer_tsc_deadline
 4. hw.x2apic_enable -> hw.apic.x2apic_mode

Those tunables are for field debugging, no need to keep old names for
compatibility.

Reviewed by:	kib
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42248

(cherry picked from commit 12cce5994b)
(cherry picked from commit 6cd7e3d118)
(cherry picked from commit 8ca5539ae1)
2023-10-24 12:46:31 +08:00
Zhenlei Huang 180695b8e6 amd64 pmap: Prefer consistent naming for loader tunable
The sysctl knob 'vm.pmap.allow_2m_x_ept' is loader tunable and have
public document entry in security(7) but is fetched from kernel
environment 'hw.allow_2m_x_ept'. That is inconsistent and obscure.

As there is public security advisory FreeBSD-SA-19:25.mcepsc [1],
people may refer to it and use 'hw.allow_2m_x_ept', let's keep old
name for compatibility.

[1] https://www.freebsd.org/security/advisories/FreeBSD-SA-19:25.mcepsc.asc

Reviewed by:	kib
Fixes:		c08973d09c Workaround for Intel SKL002/SKL012S errata
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42311

(cherry picked from commit 9e7f349ff1)
(cherry picked from commit 8784b153a3)
(cherry picked from commit 350e79edf9)
2023-10-24 12:46:30 +08:00
Zhenlei Huang 95c4e64bf6 vmx: Prefer consistent naming for loader tunables
The following loader tunables do have corresponding sysctl MIBs but
with different names. That may be historical reason. Let's prefer
consistent naming for them so that it will be easier to read and
maintain.

 1. hw.vmm.l1d_flush -> hw.vmm.vmx.l1d_flush
 2. hw.vmm.l1d_flush_sw -> hw.vmm.vmx.l1d_flush_sw
 3. hw.vmm.vmx.use_apic_pir -> hw.vmm.vmx.cap.posted_interrupts
 4. hw.vmm.vmx.use_apic_vid -> hw.vmm.vmx.cap.virtual_interrupt_delivery
 5. hw.vmm.vmx.use_tpr_shadowing -> hw.vmm.vmx.cap.tpr_shadowing

Old names are kept for compatibility.

Meanwhile, add sysctl flag CTLFLAG_TUN to them so that `sysctl -T` will
report them correctly.

Reviewed by:	corvink, jhb, kib, #bhyve
MFC after:	5 days
Differential Revision:	https://reviews.freebsd.org/D42251

(cherry picked from commit f3ff0918ff)
(cherry picked from commit 9e48b627ae)
(cherry picked from commit ba924ff8c4)
2023-10-24 12:46:30 +08:00
Kyle Evans c1c0873c9d freebsd-update: create deep BEs by default
The -r flag to bectl needs to go away, and we need to just do the right
thing.  In the meantime, we can apply an -r in freebsd-update as a
minimal fix to stop creating partial backups in these (non-default) deep
BE setups.

PR:		267535
(cherry picked from commit 989c5f6da9)
2023-10-23 19:04:42 -05:00
Zhenlei Huang 0ceaf5d462 pmap: Prefer consistent naming for loader tunable
The sysctl knob 'vm.pmap.pv_entry_max' becomes a loader tunable since
7ff48af704 (Allow a specific setting for pv entries) but is fetched
from system environment 'vm.pmap.pv_entries'. That is inconsistent and
obscure.

This reverts 36e1b9702e (Correct the tunable name in the message).

PR:		231577
Reviewed by:	jhibbits, alc, kib
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42274

(cherry picked from commit 02320f6420)
(cherry picked from commit e53f8ca323)
(cherry picked from commit 16afc2a4d9)
2023-10-23 18:17:44 +08:00
Zhenlei Huang 6be29d44ec veriexec: Correctly export symbols
There's no symbol named 'mac_veriexec_get_executable_flags', the right
one should be the function 'mac_veriexec_metadata_get_executable_flags()'.

Reviewed by:	stevek
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D42133

(cherry picked from commit f34c9c4e3b)
(cherry picked from commit d8aaf09792)
(cherry picked from commit 36180ffe86)
2023-10-23 18:17:42 +08:00
Zhenlei Huang 5173f00ae2 amd64: Fix two typos of loader tunables
To match the sysctl MIBs and document entries in security(7).

Fixes:	2dec2b4a34 amd64: flush L1 data cache on syscall return with an error
Fixes:	17edf152e5 Control for Special Register Buffer Data Sampling mitigation

Reviewed by:	kib
MFC after:	1 day
Differential Revision:	https://reviews.freebsd.org/D42249

(cherry picked from commit afbb8041a0)
(cherry picked from commit 032a0b4454)
(cherry picked from commit a72ab19000)
2023-10-21 22:50:51 +08:00
Zhenlei Huang 9aeb24e214 vm_phys: Add corresponding sysctl knob for loader tunable
The loader tunable 'vm.numa.disabled' does not have corresponding sysctl
MIB entry. Add it so that it can be retrieved, and `sysctl -T` will also
report it correctly.

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D42138

(cherry picked from commit c415cfc8be)
(cherry picked from commit e26b7e8d02)
(cherry picked from commit b180f0040f)
2023-10-19 22:26:18 +08:00
Gregory Neil Shapiro 98f15d8f2f MFC: Remove confDH_PARAMETERS settings in favor of using sendmail's
built-in default which was added in sendmail 8.15.2 (the config
line predates that 8.15.2 feature).  This also alleviates the need
for admins to create the DH parameters file if they opt to use
Diffie-Hellman.

PR:		248387

(cherry picked from commit 98fd1add67)
2023-10-17 19:48:22 +00:00
Zhenlei Huang 53379a4039 sctp: Various fixes for loader tunables
The following sysctl variables are actually loader tunables. Add sysctl
flag CTLFLAG_TUN to them so that `sysctl -T` will report them correctly.

 1. net.inet.sctp.tcbhashsize
 2. net.inet.sctp.pcbhashsize
 3. net.inet.sctp.chunkscale

The loader tunable 'net.inet.sctp.tcbhashsize' and 'net.inet.sctp.chunkscale'
are only used during vnet initializing, thus it make no senses to make them
writable tunable.

Validate the values of loader tunables on vnet initialize, reset them to
theirs defaults if invalid to prevent potential kernel panics.

Reviewed by:	tuexen, #transport, #network
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D42007

(cherry picked from commit dac91eb766)
(cherry picked from commit fd9de12a71)
(cherry picked from commit 69e05e06c6)
2023-10-16 23:49:59 +08:00
Zhenlei Huang 0a31dbecd4 tcp: Simplify the initialization of loader tunable 'net.inet.tcp.tcbhashsize'
No functional change intended.

Reviewed by:	cc, rscheff, #transport
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D41998

(cherry picked from commit 38ecc80b2a)
(cherry picked from commit 3a97686fc1)
(cherry picked from commit 379f41a117)
2023-10-16 23:49:59 +08:00
Cy Schubert 7d9c0fb578 unbound: Import upstream 0ee44ef3 when ENOBUFS is returned
From upstream 0ee44ef3:

- Fix send of udp retries when ENOBUFS is returned. It stops looping
  and also waits for the condition to go away. Reported by Florian
  Obser.

PR:		274352

Merge commit '292d51198aa319c58f534549851e9c28486abdf4'

(cherry picked from commit 6e71235e55)
2023-10-12 18:54:35 -07:00
Zhenlei Huang fd18dc70ce mbuf: Add sysctl flag CTLFLAG_TUN to loader tunables
The following sysctl variables are actually loader tunables. Add sysctl
flag CTLFLAG_TUN to them so that `sysctl -T` will report them correctly.

 1. kern.ipc.nmbclusters
 2. kern.ipc.nmbjumbop
 3. kern.ipc.nmbjumbo9
 4. kern.ipc.nmbjumbo16
 5. kern.ipc.nmbufs

No functional change intended.

Reviewed by:	kib, imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42113

(cherry picked from commit 6a88498e53)
(cherry picked from commit b1456fd620)
(cherry picked from commit 0007ba082c)
2023-10-12 18:09:39 +08:00
Zhenlei Huang 5e5a2ef858 buf: Add sysctl flag CTLFLAG_TUN to loader tunable
The sysctl variable 'vfs.unmapped_buf_allowed' is actually a loader
tunable. Add sysctl flag CTLFLAG_TUN to it so that `sysctl -T` will
report it correctly.

No functional change intended.

Reviewed by:	kib, imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42113

(cherry picked from commit 31b9406530)
(cherry picked from commit 8c4eaac153)
(cherry picked from commit 5184476107)
2023-10-12 13:09:31 +08:00
Zhenlei Huang 8651da9552 sockets: Add sysctl flag CTLFLAG_TUN to loader tunable
The sysctl variable 'kern.ipc.maxsockets' is actually a loader tunable.
Add sysctl flag CTLFLAG_TUN to it so that `sysctl -T` will report it
correctly.

No functional change intended.

Reviewed by:	kib, imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42113

(cherry picked from commit 978be1ee5d)
(cherry picked from commit e4f97a1ec7)
(cherry picked from commit 6dbde84245)
2023-10-12 13:09:31 +08:00
Zhenlei Huang 7563e1baf4 fd: Add sysctl flag CTLFLAG_TUN to loader tunables
The following sysctl variables are actually loader tunables. Add sysctl
flag CTLFLAG_TUN to them so that `sysctl -T` will report them correctly.

 1. kern.maxfiles
 2. kern.maxfilesperproc

No functional change intended.

Reviewed by:	kib, imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42113

(cherry picked from commit 2af5ce5b5e)
(cherry picked from commit d9aa723347)
(cherry picked from commit 4f8eaa24a2)
2023-10-12 13:09:31 +08:00
Zhenlei Huang 9d6eb30abb x86: Add sysctl flag CTLFLAG_TUN to loader tunables
The following sysctl variables are actually loader tunables. Add sysctl
flag CTLFLAG_TUN to them so that `sysctl -T` will report them correctly.

 1. machdep.idle
 2. machdep.idle_apl31

No functional change intended.

Reviewed by:	kib, imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42113

(cherry picked from commit 149b9c234b)
(cherry picked from commit 9eac775b41)
(cherry picked from commit cabab5c362)
2023-10-12 13:09:31 +08:00
Zhenlei Huang 4e74b80165 nfscl: Add sysctl flag CTLFLAG_TUN to loader tunable
The sysctl variable 'vfs.nfs.iodmin' is actually a loader tunable. Add
sysctl flag CTLFLAG_TUN to it so that `sysctl -T` will report it
correctly.

No functional change intended.

Reviewed by:	kib, imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42113

(cherry picked from commit 95c01e9b32)
(cherry picked from commit 3133f4d9de)
(cherry picked from commit 2349193301)
2023-10-12 13:09:31 +08:00
Zhenlei Huang 148a0f6bf0 ddb: Add sysctl flag CTLFLAG_TUN to loader tunable
The sysctl variable 'debug.ddb.capture.bufsize' is actually a loader
tunable. Add sysctl flag CTLFLAG_TUN to it so that `sysctl -T` will
report it correctly.

No functional change intended.

Reviewed by:	kib, imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42113

(cherry picked from commit 0eb2e19789)
(cherry picked from commit 0de3d5316c)
(cherry picked from commit 9edd545370)
2023-10-12 13:09:31 +08:00
Zhenlei Huang e266819e47 cam/scsi: Add sysctl flag CTLFLAG_TUN to loader tunable
The sysctl variable 'kern.cam.scsi_delay' is actually a loader tunable.
Add sysctl flag CTLFLAG_TUN to it so that `sysctl -T` will report it
correctly.

No functional change intended.

Reviewed by:	kib, imp (for #cam)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42113

(cherry picked from commit e2ad7ce37b)
(cherry picked from commit 4bf3810546)
(cherry picked from commit 7ac42534c2)
2023-10-12 13:09:27 +08:00
Scott Long 73765a5fa7 Advertise the MPI Message Version that's contained in the IOCFacts message
in the sysctl block for the driver.  mpsutil/mprutil needs this so it can
know how big of a buffer to allocate when requesting the IOCFacts from the
controller.  This eliminates the kernel console messages about wrong
allocation sizes.

Reported by:	imp

(cherry picked from commit 69e85eb8ae)

mprutil: "fix user reply buffer (64)..." warnings

Depending on the card's firmware version, it may return different length
responses for MPI2_FUNCTION_IOC_FACTS.  But the first part of the
response contains the length of the rest, so query it first to get the
length and then use that to size the buffer for the full response.

Also, correctly zero-initialize MPI2_IOC_FACTS_REQUEST.  It only worked
by luck before.

PR:		264848
Reported by:	Julien Cigar <[email protected]>
Sponsored by:	Axcient
Reviewed by:	scottl, imp
Differential Revision: https://reviews.freebsd.org/D38739

(cherry picked from commit 7d154c4dc6)
2023-10-05 14:36:00 -06:00
Michael Osipov 8d939b7d98 libfetch: don't rely on ca_root_nss for certificate validation
Before certctl(8), there was no system trust store, and libfetch
relied on the CA certificate bundle from the ca_root_nss port to
verify peers.

We now have a system trust store and a reliable mechanism for
manipulating it (to explicitly add, remove, or revoke certificates),
but if ca_root_nss is installed, libfetch will still prefer that to
the system trust store.

With this change, unless explicitly overridden, libfetch will rely on
OpenSSL to pick up the default system trust store.

PR:		256902
MFC after:	3 days
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D42059

(cherry picked from commit 09f5c1e118)
2023-10-05 17:58:59 +02:00
Mina Galic 757524b3db local-unbound: remove stray config.h.in backup
despite being ignored in our main .gitignore, such files can still be
merged from vendor branches.

Reviewed by:		cy
Fixes:			8f76bb7dad (unbound: Vendor import 1.18.0)
MFC after:		2 weeks
X-MFC with:		8f76bb7dad
Differential Revision:	https://reviews.freebsd.org/D41920

(cherry picked from commit 948e11aaf4)
2023-10-03 18:00:54 -07:00
Cy Schubert 8ac4404ce2 unbound: Vendor import 1.18.0
Release notes at
    https://www.nlnetlabs.nl/news/2023/Aug/30/unbound-1.18.0-released/

Merge commit '401770e05c71ecb5ae61a59d316069b4b78bf622' into main

(cherry picked from commit 8f76bb7dad)
2023-10-02 19:01:07 -07:00
Cy Schubert b607e17bca sqlite3: Vendor import of sqlite3 3.43.1
Release notes at https://www.sqlite.org/releaselog/3_43_1.html.

Obtained from:  https://www.sqlite.org/2023/sqlite-autoconf-3430100.tar.gz

Merge commit 'fa2bb1440e13602676feec708ac7a9a3bb5ce5c8' into main

(cherry picked from commit ec99498144)
2023-10-02 19:01:06 -07:00
Zhenlei Huang 3f44d78705 ipfilter: Add sysctl flag CTLFLAG_TUN to loader tunable
The sysctl variable `net.inet.ipf.large_nat` is actually a loader
tunable. Add sysctl flag CTLFLAG_TUN to it so that `sysctl -T` will
report it correctly.

No functional change intended.

Reviewed by:	cy (for #network)
Fixes:		a805ffbcbc ipfilter: Make LARGE_NAT a tunable
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42005

(cherry picked from commit ba883e7a5a)
(cherry picked from commit a9359dcde2)
(cherry picked from commit 25c371dc55)
2023-10-02 17:08:55 +08:00
Zhenlei Huang 6a6202b4cc ip_mroute: Fix sysctl knobs
The loader tunable `net.inet.ip.mfchashsize` does not have corresponding
sysctl MIB entry. Just add it.

While here, the sysctl variable `net.inet.pim.squelch_wholepkt` is actually
a loader tunable. Add sysctl flag CTLFLAG_TUN to it so that `sysctl -T`
will report it correctly.

Reviewed by:	kp
Fixes:		443fc3176d Introduce a number of changes to the MROUTING code
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D41997

(cherry picked from commit f549e22901)
(cherry picked from commit b0f026435a)
(cherry picked from commit ef3edef9ec)
2023-10-02 17:08:55 +08:00
Zhenlei Huang 6b8183c70c ipfw.8: Adjust section for loader tunables
Move the descriptions of loader tunables from section 'SYSCTL VARIABLES'
to section 'LOADER TUNABLES'.

See also 49197c391b (ipfw: Add sysctl flag CTLFLAG_TUN to loader tunables).

MFC after:	2 days
Differential Revision:	https://reviews.freebsd.org/D41981

(cherry picked from commit 12349f3889)
(cherry picked from commit bb6f9a9540)
(cherry picked from commit e31a331ddd)
2023-10-02 17:08:55 +08:00
Zhenlei Huang 8d6188b131 ipfw: Add sysctl flag CTLFLAG_TUN to loader tunables
The following sysctl variables are actually loader tunables. Add sysctl
flag CTLFLAG_TUN to them so that `sysctl -T` will report them correctly.

 1. net.inet.ip.fw.enable
 2. net.inet6.ip6.fw.enable
 3. net.link.ether.ipfw

No functional change intended.

Reviewed by:	glebius
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D41928

(cherry picked from commit 49197c391b)
(cherry picked from commit f5f6da9059)
(cherry picked from commit 09f08dbe24)
2023-10-02 17:08:54 +08:00
Zhenlei Huang 2d43654e6a netinet6: Add sysctl flag CTLFLAG_TUN to loader tunables
The following sysctl variables are actually loader tunables. Add sysctl
flag CTLFLAG_TUN to them so that `sysctl -T` will report them correctly.

 1. net.inet6.ip6.auto_linklocal
 2. net.inet6.ip6.accept_rtadv
 3. net.inet6.ip6.no_radr

No functional change intended.

Reviewed by:	glebius
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D41928

(cherry picked from commit 03dac3e379)
(cherry picked from commit da2b630c12)
(cherry picked from commit 28a80239fd)
2023-10-02 17:08:54 +08:00
Zhenlei Huang 453abc9f3a rtsock: Add sysctl flag CTLFLAG_TUN to loader tunable
The sysctl variable `net.route.netisr_maxqlen` is actually a loader
tunable. Add sysctl flag CTLFLAG_TUN to it so that `sysctl -T` will
report it correctly.

No functional change intended.

Reviewed by:	glebius
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D41928

(cherry picked from commit 21a722d959)
(cherry picked from commit bffb01eda9)
(cherry picked from commit c6afda2e5a)
2023-10-02 17:08:54 +08:00
Juraj Lutter 05f988e987 freebsd-update: Allow for upper/lowercase y/n
Allow for upper/lowercase y/n in "Does this look right?" question.

Reviewed by:		emaste
Approved by:		emaste
Differential revision:	https://reviews.freebsd.org/D40434

(cherry picked from commit 39f4633b3d)
2023-10-01 13:30:58 -04:00
Ed Maste 274281864f freebsd-update: handle file -> directory on upgrade
Upgrading from FreeBSD 13.2 to 14.0 failed with
  install: ///usr/include/c++/v1/__string exists but is not a directory
because __string changed from a file to a directory with an LLVM
upgrade.

Now, remove the existing file when the type conflicts.  Note that this
is only an interim fix to facilitate upgrades from 13.2 for 14.0 BETA
testing.  This change does not handle the directory -> file case and
further work is needed.

PR:		273661
Reviewed by:	dim, gordon
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41893

(cherry picked from commit f6d37c9ca1)
2023-10-01 12:33:56 -04:00
Christos Zoulas 25307d6c92 regcomp: use unsigned char when testing for escapes
- cast GETNEXT to unsigned where it is being promoted to int to prevent
  sign-extension (really it would have been better for PEEK*() and
  GETNEXT() to return unsigned char; this would have removed a ton of
  (uch) casts, but it is too intrusive for now).
- fix an isalpha that should have been iswalpha

PR:		264275, 274032
Reviewed by:	kevans, eugen (previous version)
Obtained from:	NetBSD

(cherry picked from commit 3fb80f1476)
2023-09-29 20:41:57 -05:00
Colin Percival 5f446a12da freebsd-update: Fix merging already-updated files
When performing an "upgrade" (moving between FreeBSD releases, as
opposed to "update" which merely applies security/errata updates
to the installed release) FreeBSD Update:

1. Generates a list of "files needing to be merged", namely those
files which don't match the version installed in the "old" release
and have paths matching the MergeChanges configuration directive
(by default, /boot/device.hints and everything under /etc/).

and later on,

2. Compares the currently-installed files to the versions in the
"new" release, removing index entries for files which "don't need
to be updated because they're not changing".

Unfortunately if a file falls into both of these categories -- that
is to say, if a file in /etc/ is the same as the version in the new
release and not the same as the version in the old release -- the
resulting "merge" step saw that the file was no longer listed as
being part of the new release, resulting in the file being deleted.

For the first 18 years of FreeBSD Update's existence, this never
happened, since $FreeBSD$ tags resulted in "new release" files
always being different from any files systems would already have
installed.

This commit fixes this behaviour by only placing a file into the
"files needing to be merged" list if it does not match the version
in the old release *or* the version in the new release.

Reported by:	des
Reviewed by:	delphij (earlier version), des, emaste
MFC after:	7 days
X-EN-Candidate:	yes
Differential Revision:	https://reviews.freebsd.org/D39973

(cherry picked from commit c55b7e5226)
2023-09-28 09:40:38 -04:00
Cy Schubert b083794291 ipfilter: Avoid allocating a new ipf token when not needed
Only allocate a new ipftoken_t if one cannot be found. This eliminates
allocating unnecessary token structures that will never be used when
performing simple lookups for existing token structures.

(cherry picked from commit 7f5e3b9fa3)
2023-09-26 19:22:26 -07:00
John Hein 205f9a4fbc libprocstat: use elf_getphdrnum rather than deprecated elf_getphnum
PR:             273966
Reviewed by:	emaste

(cherry picked from commit 633094c27f)
(cherry picked from commit fd8bf2ecc0)
2023-09-26 09:05:16 -04:00
Wolfram Schneider 2e866693bc switch groff parameter -man to -mandoc for new groff release 1.23.0
PR: 273565

(cherry picked from commit cd89fe3923)
2023-09-25 17:33:15 +00:00
Wolfram Schneider 0e71efa38c switch groff parameter -man to -mandoc
groff 1.23.0 changed the semantics of the -man parameter, and many
manual pages are not rendered. The -mandoc parameter brings back
the old behavior, as in groff 1.22.4 and earlier.

PR: 273565, 273245

Reviewed by:	emaste, bapt
MFC after: 1 week for all supported branches (stable/12, 13, 14)
Differential Revision:	https://reviews.freebsd.org/D41737

(cherry picked from commit 035f7c9a36)
2023-09-25 17:33:08 +00:00
Alan Somers b2dff90c0b Fix zfsd with the device_removal pool feature.
Previously zfsd would crash in the presence of a pool with a
top-level-vdev that had previously been removed.  The crash happened
because the configuration nvlist of such a TLV contains an empty
ZPOOL_CONFIG_CHILDREN array, which led to a pop_front from an empty
list, which has undefined behavior.

The crash only happened in stable/14 and later, probably do to
differences in libcxx, but the change should be MFCed anyway.

PR:		273663
Reported by:	Marek Zarychta <[email protected]>
Sponsored by:	Axcient
Reviewed by:	mav
Differential Revision: https://reviews.freebsd.org/D41818

(cherry picked from commit 0b294a386d)
2023-09-21 16:26:29 -06:00
Zhenlei Huang d5dbed2f1e net: Check per-flow priority code point for untagged traffic
Commit 868aabb470 introduced per-flow priority. There's a defect in the
logic for untagged traffic, it does not check M_VLANTAG set in the mbuf
packet header or MTAG_8021Q/MTAG_8021Q_PCP_OUT tag set by firewall, then
can result missing desired priority in the outbound packets.

For mbuf packet with M_VLANTAG in header, some interfaces happen to work
due to bug in the drivers mentioned in D39499. As modern interfaces have
VLAN hardware offloading, the defect is barely noticeable unless the
feature per-flow priority is widely tested.

As a side effect of this defect, the soft padding to work around buggy
bridges is bypassed. That may result in regression if soft padding is
requested.

PR:		273431
Discussed with:	kib
Fixes:	868aabb470 Add IP(V6)_VLAN_PCP to set 802.1 priority per-flow
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39536

(cherry picked from commit 49d6743da1)
(cherry picked from commit c750055382)
(cherry picked from commit 8303afca17)
2023-09-20 18:05:14 +08:00
Dimitry Andric 08862a1a5e Fix geom build with clang 17 and KTR enabled
When building a kernel with clang 17 and KTR enabled, such as with the
LINT configurations, a -Werror warning is emitted:

    sys/geom/geom_io.c:145:31: error: use of logical '&&' with constant operand [-Werror,-Wconstant-logical-operand]
      145 |         if ((KTR_COMPILE & KTR_GEOM) && (ktr_mask & KTR_GEOM)) {
          |             ~~~~~~~~~~~~~~~~~~~~~~~~ ^
    sys/geom/geom_io.c:145:31: note: use '&' for a bitwise operation
      145 |         if ((KTR_COMPILE & KTR_GEOM) && (ktr_mask & KTR_GEOM)) {
          |                                      ^~
          |                                      &
    sys/geom/geom_io.c:145:31: note: remove constant to silence this warning

Replace the multiple uses of the expression with one macro, and in this
macro use "!= 0" to get a logical operand instead of a bitwise one.

Reviewed by:	jhb
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D41823

(cherry picked from commit 479d224efc)
2023-09-20 09:04:10 +02:00
Eugene Grosbein e21f1fa8fa MFC: unbreak BEGEMOT-LM75-MIB.txt
The MIB has several bugs making it unusable. Fix it.

Reported-by:	Eugene M. Zheganin <[email protected]>

(cherry picked from commit 872e894056)
2023-09-14 19:24:51 +07:00
Ed Maste 4214f6cbb4 ftpd: add deprecation notice
Approved by:	gordon
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26447

(cherry picked from commit 98b98ec1bc)
(cherry picked from commit cc9347cc79)
(cherry picked from commit 01d8215102)
(cherry picked from commit 3ea83e94cd)
(cherry picked from commit 0e383bb3cd)
2023-09-14 10:57:57 +01:00
Andrey V. Elsukov 5f30a218ca ahci: add AMD device id in RAID mode
Found on Asus ROX Strix X570-F Gaming.

MFC after:	1 week

(cherry picked from commit 3afe6b5253)
2023-09-13 20:46:29 +03:00
Mateusz Piotrowski 8e9979050a getdirentries.2: Reference dir(5)
As a note, parts of manual pages getdirentries(2) and dir(5) should
probably be consolidated.

MFC after:	3 days

(cherry picked from commit 5b7a776f48)
2023-09-12 13:54:11 +02:00
Mateusz Piotrowski 9cc3b0704e getdirentries.2: Improve readability of dirent members
MFC after:	3 days

(cherry picked from commit 52d374a067)
2023-09-12 13:54:11 +02:00
Mateusz Piotrowski 01e15ca6c8 getdirentries.2: Reference directory(3)
MFC after:	3 days

(cherry picked from commit 3a02df5e27)
2023-09-12 13:54:10 +02:00
Konstantin Belousov 79802c179a msdosfs: zero partially valid extended cluster
(cherry picked from commit 7e4c6b2163)
(cherry picked from commit 868f3eadc5)
2023-09-11 14:05:09 -04:00
Konstantin Belousov b2e3ab898c msdosfs deextend: validate pages of the partial buffer
PR:	269341

(cherry picked from commit 0152d453a0)
(cherry picked from commit c2ee668306)
2023-09-11 14:04:59 -04:00
Konstantin Belousov 0754c27f49 msdosfs deextend(): memoize DETOV(dep)
(cherry picked from commit 67dc1e7b04)
(cherry picked from commit 03562adbef)
2023-09-11 14:04:52 -04:00
Konstantin Belousov 8b95f9fe92 msdosfs: correct handling of vnode pager size on file extension error
(cherry picked from commit e59180ea09)
(cherry picked from commit 6415222502)
2023-09-11 14:04:29 -04:00
Jung-uk Kim 43842be195 OpenSSL: Regen manual pages for OpenSSL 1.1.1w 2023-09-11 13:28:31 -04:00
Jung-uk Kim 70337f73e9 OpenSSL: Merge OpenSSL 1.1.1w
(cherry picked from commit a1860b94f62494288804faebb1bf6ea8110ca148)
2023-09-11 13:27:54 -04:00
Martin Matuska af386f70fa libarchive: merge security fix from vendor branch
This commit fixes a couple of security vulnerabilities in the PAX writer:
1. Heap overflow in url_encode() in archive_write_set_format_pax.c
2. NULL dereference in archive_write_pax_header_xattrs()
3. Another NULL dereference in archive_write_pax_header_xattrs()
4. NULL dereference in archive_write_pax_header_xattr()

Security:	No known reference yet
Obtained from:	https://github.com/libarchive/libarchive/commit/1b4e0d0f9
MFC after:	3 days

(cherry picked from commit f10f65999f)
2023-09-11 09:03:43 +02:00
Ed Maste e4e41b39a4 iir: prevent negative offsets in ioctl
MFS of direct commit to stable/13 as this driver has been removed from
main in commit 399188a2c6 ("iir: Remove").

PR:		273328
Reported by:	ChenHao Lu
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit b5a5a06fc0)
2023-09-09 11:16:19 -04:00
Ed Maste 3284a5929d release: remove inet blackhole sysctls from GCE config
Other cloud images do not do this, and it can produce confusing results.

Reviewed by:	Jose Luis Duran, delphij
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41751

(cherry picked from commit b7528b16c6)
(cherry picked from commit 5623352ec0)
(cherry picked from commit 413687812b)
2023-09-09 11:16:18 -04:00
Kyle Evans b06aed1e78 caroot: add a primitive script to re-stamp certs
The tooling in main isn't stamping output with $FreeBSD$ strings going
forward, so we need to remember to do that in this branch with each
update.  Add a stupid simple script that we can just run every time we
MFC an update without having to put much thought into it.

Direct commit to stable/12 because we don't need this in stable/13 or
stable/14.
2023-09-09 00:34:31 -05:00
Kyle Evans a8e9827d4e caroot: update the root bundle and regenerate with OpenSSL 3
Summary:
- Twenty six (26) newly trusted
- Thirteen (13) distrusted

(cherry picked from commit f5e5dcdbeb)
(cherry picked from commit ee0aa1ce12)
(cherry picked from commit 65fd80909e)
(cherry picked from commit 8ed0ecf802)
2023-09-09 00:34:16 -05:00
Dag-Erling Smørgrav f0cfac77c6 libc: Fix fmemopen(3) prototype in fopen(3) man page.
While here, also update a mention of ANSI C.

Sponsored by:	Klara, Inc.
Reviewed by:	kevans, markj
Differential Revision:	https://reviews.freebsd.org/D41686

(cherry picked from commit 5a57401e71)

libc: Further nit in fopen(3) man page.

Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D41687

(cherry picked from commit c9f5889d05)
2023-09-08 12:16:22 +02:00
Dag-Erling Smørgrav 9f9ba56692 wmistat: don't restrict reading to the pid that opened the fd.
PR:		273405
MFC after:	1 week
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D41621

(cherry picked from commit 28977cb9bc)
2023-09-08 12:12:21 +02:00
John Baldwin dd66ba430c netsmb: Add bounds checking to smb_t2_placedata
Verify that the requested region of the mbuf chain is not beyond the
end of the chain before trimming it from the end.  If it is out of
bounds, fail with an error (EPROTO).

While here, properly handle the case that the amount of data at the
end of the chain might span more than one mbuf by using m_adj to drop
the extra bytes rather than assuming m_len of the last mbuf can be
adjusted directly.

PR:		258504
Reported by:	Robert Morris <[email protected]>
Co-authored-by:	Robert Morris <[email protected]>
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41229

(cherry picked from commit aca3d65fed)
2023-09-06 13:03:18 -07:00
John Baldwin 16f142865c cd9660: Reject volumes with small logical block sizes
ISO9660 permits specifying a logical block size that is any power of 2
greater than or equal to 512.  The geom disk layer requires requests
to be aligned on sector boundaries of the provider.  With a volume
that uses a logical block size smaller than the underlying disk sector
size (e.g. a logical block size of 512 or 1024 on a CD which uses 2048
byte sectors), the current cd9660 vfs can issue requests for partial
sectors, or on non-sector boundaries.

Fixing this properly would require wrapping all of the calls to
bread*/bwrite* in cd9660 vfs to roundup requests to be on sector
boundaries which can include both the length, but also the starting
sector number (and thus requiring use of an offset relative to b_data
in the resulting buf).

These images do not seem to be common however given that no one has
fixed this in cd9660's vfs in the past few decades, so just reject
them during mount with an error.  If such images are found to be used
in the wild in practice, then the larger fix can be applied.

PR:		258063
Reported by:	Robert Morris <[email protected]>
Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41228

(cherry picked from commit 4af849d71f)
2023-09-06 13:03:05 -07:00
John Baldwin 0f6ffc7ff3 g_raid concat: Fail requests to read beyond the end of the volume
Previously a debug kernel would trigger an assertion failure if an I/O
request attempted to read off the end of a concat volume, but a
non-debug kernel would use an invalid sub-disk to try to complete the
request eventually resulting in some sort of fault in the kernel.

Instead, turn the assertions into explicit checks that fail requests
beyond the end of the volume with EIO.  For requests which run over
the end of the volume, return a short request.

PR:		257838
Reported by:	Robert Morris <[email protected]>
Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41222

(cherry picked from commit 4c89c0127d)
2023-09-06 13:02:51 -07:00
John Baldwin 0db7f4b419 udf: Reject read requests with an invalid length
- If the size is negative or if rounding it up to a multiple of
  the block size overflows, fail the read request with ERANGE.

- While here, add a sanity check that the ICB length for the root
  directory is at least as long as a minimum-sized file entry.

PR:		257768
Reported by:	Robert Morris <[email protected]>
MFC after:	1 week
Sponsored by:	FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D41220

(cherry picked from commit c70e615051)
2023-09-06 13:02:33 -07:00
John Baldwin f9c3282775 libpfctl: Don't pass stack garbage to free.
GCC 9 on stable/12 reports a -Wmaybe-uninitialized error for the call
to free in _pfctl_clear_states.

Reviewed by:	mjg
Differential Revision:	https://reviews.freebsd.org/D39198

(cherry picked from commit 48c519be0e)
2023-09-06 13:02:00 -07:00
Chris Rees a42a905c2a elftoolchain: stop leaving tempfiles on error
Temporary files were not cleaned up, resulting in $TMPDIR or even
the current directory becoming littered with ecp.* files.

This happened with error and even sometimes on success!

Approved by:		dim
MFC after:		4 weeks
Accepted upstream:	https://sourceforge.net/p/elftoolchain/code/3918/
Differential Revision:	https://reviews.freebsd.org/D28651

(cherry picked from commit 5ac70383c8)
2023-09-06 17:02:30 +02:00
Zhenlei Huang aadedc5b3e tcp: Initialize the maximum number of entries in a client cookie cache bucket
This vnet loader tunable is defined with SYSCTL_PROC, thus will not be
initialized by kernel on vnet creating and will always have the default
value TCP_FASTOPEN_CCACHE_BUCKET_LIMIT_DEFAULT.

Fix by fetching the value from the corresponding kernel environment during
vnet constructing.

PR:		273509
Reviewed by:	#transport, tuexen
Fixes:	c560df6f12 This is an implementation of the client side of TCP Fast Open (TFO) [RFC7413]
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D41691

(cherry picked from commit 224aec05e7)
(cherry picked from commit 144851777e)
(cherry picked from commit 3fc299d688)
2023-09-06 12:32:56 +08:00
Zhenlei Huang c0038743d3 net: Remove vlan metadata on pcp / vlan encapsulation
For oubound traffic, the flag M_VLANTAG is set in mbuf packet header to
indicate the underlaying interface do hardware VLAN tag insertion if
capable, otherwise the net stack will do 802.1Q encapsulation instead.

Commit 868aabb470 introduced per-flow priority which set the priority ID
in the mbuf packet header. There's a corner case that when the driver is
disabled to do hardware VLAN tag insertion, and the net stack do 802.1Q
encapsulation, then it will result double tagged packets if the driver do
not check the enabled capability (hardware VLAN tag insertion).

Unfortunately some drivers, currently known cxgbe(4) re(4) ure(4) igc(4)
and vmx(4), have this issue. From a quick review for other interface
drivers I believe a lot more drivers have the same issue. It makes more
sense to fix in net stack than to try to change every single driver.

PR:		270736
Reviewed by:	kp
Fixes:	868aabb470 Add IP(V6)_VLAN_PCP to set 802.1 priority per-flow
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39499

(cherry picked from commit b22aae410b)
(cherry picked from commit 494de30b63)
(cherry picked from commit 337475505b)
2023-09-06 12:32:56 +08:00
Zhenlei Huang 70e32e5b52 geom_linux_lvm: Check the offset of physical volume header
The LVM label is stored on any of the first four sectors, and the
PV (physical volume) header is stored within the same sector following
the LVM label. The current implementation does not fully check the
offset of PV header, when attaching a bad formatted LVM PV the kernel
may crash due to out-of-bounds memory read.

PR:		266562
Reviewed by:	jhb
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D36773

(cherry picked from commit c941b82e1c)
(cherry picked from commit 809450c4b5)
2023-09-06 12:32:56 +08:00
Zhenlei Huang 8fdb1181ab geom_part: Fix potential integer overflow when checking size of the table
`hdr_entries` and `hdr_entsz` are both uint32_t as defined in UEFI spec.
Current spec does not have upper limit of the number of partition
entries and the size of partition entry, it is potential that malicious
or corrupted GPT header read from untrusted source contains large size of
entry number or size.

PR:		266548
Reviewed by:	oshogbo, cem, imp, markj
Approved by:	kp (mentor)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D36709

(cherry picked from commit 2e543af13a)
(cherry picked from commit 3070bedd3d)
2023-09-06 12:32:56 +08:00
Zhenlei Huang 61b426a0b6 geom_part: Check number of GPT entries and size of GPT entry
Current specification does not have upper limit of the number of
partition entries and the size of partition entry. In
799eac8c3d Andrey V. Elsukov introduced a
limit maximum number of GPT entries to 4k, but that is for write routine
(gpart create) only. When attaching disks that have large number of GPT
entries exceeding the limit, or disks with large size of partition
entry, it is still possible to exhaust kernel memory.

1. Reuse the limit of the maximum number of partition entries.
2. Limit the maximum size of GPT entry to 1k.

In current specification (2.10) the size of GPT entry is 128 *
2^n while n >= 0, and the size - 128 is reserved. 1k should be
sufficient enough for foreseen future.

PR:		266548
Discussed with:	imp
Reviewed by:	markj
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D36717

(cherry picked from commit 5be5d0d5cb)
(cherry picked from commit e8c769b22d)
2023-09-06 12:32:56 +08:00
Zhenlei Huang dddf410362 bridge.4: Document the net.link.bridge.log_mac_flap sysctl variable
It was introduced in 2d3614fb13 (bridge: Log MAC address port flapping).

Reviewed by:	gbe (manpages)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D39465

(cherry picked from commit 3fdb40d1be)
(cherry picked from commit 5a3f517110)
2023-09-01 18:10:40 +08:00
Andrey V. Elsukov de114db0fe carp: delete interface routes on link loss.
Obtained from:	Yandex LLC
MFC after:	10 days
Sponsored by:	Yandex LLC
Differential Revision: https://reviews.freebsd.org/D41290

(cherry picked from commit 600bf006d3)
2023-09-01 12:02:23 +03:00
Konstantin Belousov e579e7e328 libthr pshared: correct a bug in allocation
PR:	269277

(cherry picked from commit 25c862ae50)
2023-08-27 10:10:52 +03:00
Konstantin Belousov 62729a88b8 libthr: add pshared_destroy() helper
(cherry picked from commit 3cf37d1251)
2023-08-27 10:10:45 +03:00
Eugene Grosbein c6dc07c6f1 tftpd: cleanup after conflict resolution
Fixes:	a99bf99665
2023-08-20 02:28:49 +07:00
Eugene Grosbein a99bf99665 tftpd: introduce new option -S
Historically, tftpd disallowed write requests to existing files
that are not publicly writable. Such requirement is questionable at least.
Let us make it possible to run tftpd in chrooted environment
keeping files non-world writable.

New option -S enables write requests to existing files
for chrooted run according to generic file permissions.
It is ignored unless tftpd runs chrooted.

Requested by:	marck
Differential:	https://reviews.freebsd.org/D41090 (based on)

(cherry picked from commit 273a307d0b)
(cherry picked from commit 03c2616dc5)
2023-08-19 13:53:28 +07:00
Mike Karels 55b79ced00 md driver compat32: fix structure padding for arm, powerpc
Because the 32-bit md_ioctl structure contains 64-bit members, arm
and powerpc add padding to a multiple of 8.  i386 doesn't do this.
The md_ioctl32 definition was correct for amd64/i386 without padding,
but wrong for arm64 and powerpc64.  Make __packed__ conditional on
__amd64__, and test for the expected size on non-amd64.  Note that
mdconfig is used in the ATF test suite.  Note, I verified the
structure size for powerpc, but was unable to test.

Reviewed by:	jrtc27
Differential Revision:	https://reviews.freebsd.org/D41339
Discussed with:	jhibbits

(cherry picked from commit 58a46cfd75)
2023-08-18 07:41:06 -05:00
Kevin Bowling 50b52fe14b vlan: Respect IFCAP_LRO mask
vlan_capabilities(), used by the IFCAP ioctl, was not respecting the
IFCAP_LRO bit if it was masked by the requestor.

This prevented if_bridge(4) from automasking LRO with a message like:
bridge0: can't disable some capabilities on em3.11: 0x400

This also prevented manually disabling LRO from any vlan interface.

PR:		254596
Reported by:	Paul Vixie <[email protected]>

(cherry picked from commit b1a39c31a3)
2023-08-17 18:00:07 -07:00
Richard Scheffenegger b2d895f70d tcp: Handle <RST,ACK> in SYN-RCVD
Patch base stack to correctly handle the RST bit independently
of other header flags per TCP RFC.

MFC after: 1 week
Reviewed By: tuexen, #transport
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D40982

(cherry picked from commit b352ef58c2)
2023-08-14 11:38:03 +02:00
Steve Kargl afa7546359 Clean up libm use of the __ieee754_ prefix
This removes the __ieee754_ prefix from a number of the math functions.
msun/src/math_private.h contains the statement that

  /*
   * ieee style elementary functions
   *
   * We rename functions here to improve other sources' diffability
   * against fdlibm.
   */
   #define        __ieee754_sqrt  sqrt
   ...

Here, fdlibm refers to https://netlib.org/fdlibm. It is seen from
https://netlib.org/fdlibm/readme that this prefix was used to
differentiate between different standards:

   Wrapper functions will twist the result of the ieee754
   function to comply to the standard specified by the value
   of _LIB_VERSION
      if _LIB_VERSION = _IEEE_, return the ieee754 result;
      if _LIB_VERSION = _SVID_, return SVID result;
      if _LIB_VERSION = _XOPEN_, return XOPEN result;
      if _LIB_VERSION = _POSIX_, return POSIX/ANSI result.
   (These are macros, see fdlibm.h for their definition.)

AFAICT, FreeBSD has never supported these wrappers. In addition, as C99,
principally the long double, functions were added to libm, this
convention was not maintained. Given that only 148 of 324 files under
lib/msun contain a "Copyright (C) 1993 by Sun Microsystems" statement,
the removal of the __ieee754_ prefix provides consistency across all
source files.

The last time someone compared lib/msun to fdlibm appears to be

  commit 3f70824172
  Author: David Schultz <[email protected]>
  Date:   Fri Feb 4 18:26:06 2005 +0000

  Reduce diffs against vendor source (Sun fdlibm 5.3).

The most recent fdlibm RCS string that appears in a Sun Microsystem
copyrighted file is date "95/01/18". With Oracle Corporation's
acquisition of Sun Microsystems in 2009, it is unlikely that fdlibm will
ever be updated. A search for fdlibm at https://opensource.oracle.com/
yields no hits.

Finally, OpenBSD removed the use of this prefix over 21 years ago. pSee
revision 1.6 of OpenBSD's math_private.h.

Note: this does not drop the __ieee754_ prefix from the trigonometric
argument reduction functions, e.g., __ieee754_rem_pio2. These functions
are internal to the libm and exported through Symbol.map; and thus,
reserved for the implementation.

PR:		272783
MFC after:	1 week

(cherry picked from commit 99843eb899)
2023-08-13 10:39:13 +02:00
Andrew Turner dd565d9990 Use a builtin where possible in msun
Some of the functions in msun can be implemented using a compiler
builtin function to generate a small number of instructions. Implement
this support in fma, fmax, fmin, and sqrt on arm64.

Care must be taken as the builtin can be implemented as a function
call on some architectures that lack direct support. In these cases
we need to use the original code path.

As we don't set errno on failure build with -fno-math-errno so the
toolchain doesn't convert a builtin into a function call when it
detects a failure, e.g. gcc will add a call to sqrt when the input
is negative leading to an infinite loop.

Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32801

(cherry picked from commit b2e843161d)
2023-08-13 10:39:08 +02:00
Konstantin Belousov 2030f99a9a cd9660: do not leak buffers in cd9660_rrip_loop()
PR:	272856

(cherry picked from commit fa3cf6cdc6)
(cherry picked from commit 746c8f0cd7)
2023-08-08 14:12:29 -04:00
Ed Maste c734abca95 ssh: comment deprecated option handling for retired local patches
Older versions of FreeBSD included the HPN patch set and provided
client-side VersionAddendum.  Both of these changes have been retired
but we've retained the option parsing for backwards compatibility to
avoid breaking upgrades.  Add comment references to the relevant
commits.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit a93cbba2de)
(cherry picked from commit edd0014a6e)
2023-08-08 12:48:45 -04:00
Ed Maste 41b9679205 ssh: remove pre- and post-merge update steps
We no longer use the pre- and post-merge scripts to strip/add RCS tags.
The tags have been removed from main, but persist on older branches.

While here renumber the steps in the update documentation using a more
conventional scheme.

Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36904

(cherry picked from commit fca7ac55f8)
(cherry picked from commit b9622c483b)
2023-08-08 12:46:47 -04:00
Gordon Bergling 53c5e27329 et(4): Fix a typo in a source code comment
- s/diabled/disabled/

(cherry picked from commit 734c9698d9)
2023-08-05 06:44:46 +02:00
Gordon Bergling c487db6d0c usb(4): Fix a typo in a source code comment
- s/determin/determine/

(cherry picked from commit a924b48579)
2023-08-05 06:44:31 +02:00
Gordon Bergling 49f796ac92 vnic: Fix a typo in a source code comment
- s/Enabele/Enable/

(cherry picked from commit b73763fc10)
2023-08-05 06:44:13 +02:00
Gordon Bergling a2384525c9 linux(4): Fix two typos in source code comments
- s/decriptors/descriptors/

(cherry picked from commit 29eab3e4e0)
2023-08-05 06:43:16 +02:00
Gordon Bergling 61697581ec elf(3): Fix a typo in a source code comment
- s/speciaal/special/

(cherry picked from commit 2f0e0bd506)
2023-08-05 06:43:01 +02:00
Gordon Bergling 6b5988f201 aic7xxx: Fix two typos in source code comments
- s/reslection/reselection/

(cherry picked from commit 3514686b34)
2023-08-05 06:42:18 +02:00
Gordon Bergling bb23c1b4b1 netpfil: Fix a typo in a source code comment
- s/interprted/interpreted/

(cherry picked from commit cfd05de194)
2023-08-05 06:42:02 +02:00
Gordon Bergling b0fca69edb nfsserver: Fix a typo in a source code comment
- s/restared/restarted/

(cherry picked from commit 11892bc710)
2023-08-05 06:41:43 +02:00
Kristof Provost 8922b9ac0b pf: handle multiple IPv6 fragment headers
With 'scrub fragment reassemble' if a packet contains multiple IPv6
fragment headers we would reassemble the packet and immediately
continue processing it.

That is, we'd remove the first fragment header and expect the next
header to be a final header (i.e. TCP, UDP, ICMPv6, ...). However, if
it's another fragment header we'd not treat the packet correctly.
That is, we'd fail to recognise the payload and treat it as if it were
an IPv6 fragment rather than as its actual payload.

Fix this by restarting the normalisation on the reassembled packet.
If there are multiple fragment headers drop the packet.

Reported by:	Enrico Bassetti [email protected] (NetSecurityLab @ Sapienza University of Rome)
MFC after:	instant
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 76afcbb524)
2023-08-04 16:01:23 +02:00
Gordon Bergling 8d8b3e18f7 sk(4): Fix a typo in a source code comment
- s/nomral/normal/

(cherry picked from commit 135c2b7156)
2023-08-04 08:02:43 +02:00
Mike Karels 193f782e52 netstat -i: compute most field widths dynamically
The network and address fields were sometimes truncated for netstat -i
without -W, and often much too wide for netstat -i with the -W option.
Fields such as normal packet counts often overflowed.  As a result,
columns didn't line up, and large white spaces made it harder to
follow a line across the display.  Change the code to compute the
required field sizes for network, address, and various packet counts.
Hoist the code to format network and address into a subroutine that
can be called twice, once to measure the required field widths,
and once to emit the values.  Use separate field widths for input
and output packets, byte counts, and error and drop counters.
These are left at defaults (the preceding values) with the -h
option, in which case the fields have a limited total width.
An extra space is included between the Network and Address, which
otherwise seemed too close.

Change the mention of -W with -i in the man page to say that most
field widths are computed dynamically in this case.

Reviewed by:	sjg, glebius
Differential Revision:	https://reviews.freebsd.org/D41160

(cherry picked from commit 372e3d561d)
2023-08-03 07:50:15 -05:00
Kristof Provost 734518564f libpfct: ensure the initial allocation is large enough
Ensure that we allocate enough memory for the packed nvlist, no matter
what size hint was provided.

MFC after:	1 week
Reported by:	R. Christian McDonald <[email protected]>
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 6422599e74)
2023-08-02 10:41:51 +02:00
Jonathan T. Looney 234ef73f5a frag6: Avoid a possible integer overflow in fragment handling
Reviewed by:	kp, markj, bz
Approved by:	so
Security:	FreeBSD-SA-23:06.ipv6
Security:	CVE-2023-3107

(cherry picked from commit ff3d1a3f9d)
2023-08-01 16:05:08 -04:00
Jung-uk Kim 40693d64cb OpenSSL: Regen manual pages for OpenSSL 1.1.1v 2023-08-01 15:18:47 -04:00
Jung-uk Kim 1b34edce0a OpenSSL: Import OpenSSL 1.1.1v
(cherry picked from commit cc0d356166e39da7f956c39f874e6dee67fd5d60)
2023-08-01 15:15:45 -04:00
Arthur Kiyanovski a3927f6e3a ena: Update driver version to v2.6.3
Bug Fixes:
* Initialize statistics before the interface is available
* Fix driver unload crash

Minor Changes:
* Mechanically convert ena(4) to DrvAPI
* Remove usage of IFF_KNOWSEPOCH

MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit ac40021c93)
2023-07-31 14:50:09 +02:00
Arthur Kiyanovski b390fe1d80 ena: Fix driver unload crash
When ena_detach is called, we first call ether_ifdetach(),
which destroys internal addresses of ifp. One such address
is ifp->if_addr->ifa_addr. Then during ena_destroy_device(),
if_link_state_change() is called, eventually trying to access
ifp->if_addr->ifa_addr->sa_family. This causes an access
to garbage memory and crashes the kernel.

Ticket [1] was opened to the FreeBSD community to add null
check in the code of if_link_state_change().
A fix was submitted in commit [2], however it was noted
that it is our driver's responsibilty to not call
if_link_state_change() after calling ether_ifdetach().

This commit makes sure if_link_state_change() is not called
after ether_ifdetach().

[1]: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270813
[2]: https://reviews.freebsd.org/D39614

Fixes: 32f63fa7f9 ("Split ENA reset routine into restore and destroy stages")
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit c59a5fbd8a)
2023-07-31 14:49:58 +02:00
Osama Abboud 383cf7052a ena: Initialize statistics before the interface is available
In [1], the FBSD community exposed a bug in the fbsd/ena driver.

Bug description:
----------------
Current function call order is as follows:

1. ena_attach()
1.1. ena_setup_ifnet()
1.1.1. Registration of ena_get_counter()
1.1.2. ether_ifattach(ifp, adapter->mac_addr);
1.2. Statistics allocation and initialization.

At point 1.1.2, when ether_ifattach() returns, the interface is available,
and stats can be read before they are allocated, leading to kernel panic.

Also fixed a potential memory leak by freeing the stats since they were
not freed in case the following calls failed.

Fix:
----
This commit moves the statistics allocation and initialization to happen
before ena_setup_ifnet()

[1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268934

Fixes: 9b8d05b8ac ("Add support for Amazon Elastic Network Adapter (ENA) NIC")
Fixes: 30217e2dff ("Rework counting of hardware statistics in ENA driver")
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit b9e80b5280)
2023-07-31 14:49:47 +02:00
Dimitry Andric 98e7f836e6 Work around VNET and DPCPU related panics on aarch64
lld >= 14 and recent GNU ld can relax adrp+add and adrp+ldr
instructions, which breaks VNET and DPCPU when used in modules.

Until VNET and DPCPU can be fixed to deal with these relaxed
instructions, disable linker relaxation for now.

PR:		264094
Reviewed by:	markj
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D41156

(cherry picked from commit 80e4ac2964)
2023-07-26 20:03:46 +02:00
Ed Maste 56749f05db ssh: disallow loading PKCS#11 modules by default
This is the rest of the OpenSSH 9.3p2 change to address CVE-2023-38408.

From the release notes:

 * ssh-agent(8): the agent will now refuse requests to load PKCS#11
   modules issued by remote clients by default. A flag has been added
   to restore the previous behaviour "-Oallow-remote-pkcs11".

   Note that ssh-agent(8) depends on the SSH client to identify
   requests that are remote. The OpenSSH >=8.9 ssh(1) client does
   this, but forwarding access to an agent socket using other tools
   may circumvent this restriction.

Security:	CVE-2023-38408
Sponsored by:	The FreeBSD Foundation
2023-07-21 12:25:51 -04:00
Ed Maste 039d7ad8ee ssh-agent: document "-O no-restrict-websafe"
OpenSSH commits 9fd2441113fc and 4a4883664d6b, which are part of
OpenSSH 9.2p1.

Sponsored by:	The FreeBSD Foundation
2023-07-21 12:08:12 -04:00
Ed Maste abf778208f ssh: Apply CVE-2023-38408 fix from OpenSSH 9.3p2
OpenSSH 9.3p2 provides a fix CVE-2023-38408 - a condition where specific
libaries loaded via ssh-agent(1)'s PKCS#11 support could be abused to
 achieve remote code execution via a forwarded agent socket if the
following conditions are met:

* Exploitation requires the presence of specific libraries on
  the victim system.
* Remote exploitation requires that the agent was forwarded
  to an attacker-controlled system.

This commit is the primary part of the fix in 9.3p2, applied to the
OpenSSH version in FreeBSD 12.x.

Security:	CVE-2023-38408
Sponsored by:	The FreeBSD Foundation
2023-07-21 10:46:53 -04:00
Robert Clausecker 99544e13ee lib/libc/string/bcmp.c: fix integer overflow bug
bcmp() returned the number of remaining bytes when the main loop exits.
In case of a match, this is zero, else a positive integer.  On systems
where SIZE_MAX > INT_MAX, the implicit conversion from size_t to int in
the return value may cause the number of remaining bytes to overflow,
becoming zero and falsely indicating a successful comparison.

Fix the bug by always returning 0 on equality, 1 otherwise.

PR:		272474
Approved by:	emaste
Reviewed by:	imp
MFC After:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41011

(cherry picked from commit 4da7282a18)
2023-07-21 11:57:32 +03:00
Przemyslaw Lewandowski 2617bca5a8 iflib: Unlock ctx lock around call to ether_ifattach()
Panic occurs during loading driver using kldload. It exists since netlink is
enabled.  There is problem with double locking ctx. This fix allows to call
ether_ifattach() without locked ctx.

Signed-off-by: Eric Joyner <[email protected]>

PR:		271768
Reviewed by:	erj@, jhb@
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D40557

(cherry picked from commit a52f23f4c4)
2023-07-20 15:56:41 -07:00
Glen Barber 58bc084de5 release: adjust lang/python* dependencies for GCE
The lang/python3 port had failed to properly install because
it did in fact already exist and FORCE_PKG_REGISTER was not
set.  So, behaviorally everything here was correct.  However,
installing lang/python3 is in fact not correct and not needed,
so only install the lang/python port to provide symbolic links.

PR:		272354
Sponsored by:	GoFundMe https://www.gofundme.com/f/gjbbsd
Sponsored by:	PayPal https://paypal.me/gjbbsd

(cherry picked from commit b24c35b326)
2023-07-19 21:36:06 -04:00
Glen Barber ad6773477b release: remove a stray backslash
PR:		272354 (related)
Sponsored by:	GoFundMe https://www.gofundme.com/f/gjbbsd
Sponsored by:	PayPal https://paypal.me/gjbbsd

(cherry picked from commit 510fd83138)
2023-07-19 21:35:39 -04:00
Glen Barber 7815d3738a release: follow-up to previous commit to install lang/python{,3}
PR:		272354
Sponsored by:	GoFundMe https://www.gofundme.com/f/gjbbsd
Sponsored by:	PayPal https://paypal.me/gjbbsd

(cherry picked from commit cd8cad0ef5)
2023-07-19 21:35:14 -04:00
Glen Barber e7ee4c09f7 release: ensure gce-check-depends installs lang/python{,3}
PR:		272354
Sponsored by:	GoFundMe https://www.gofundme.com/f/gjbbsd
Sponsored by:	PayPal https://paypal.me/gjbbsd

(cherry picked from commit 0ed426276f)
2023-07-19 21:34:49 -04:00
Kristof Provost d84a5e9018 pf: fix error descriptions in the man page
PR:		272459
Submitted by:	[email protected]
MFC after:	1 week

(cherry picked from commit df56c8069a)
2023-07-19 09:27:08 +02:00
Kristof Provost e14a1e0029 pf: fix pfi_kif definition in the man page
PR:		272455
Submitted by:	[email protected]
MFC after:	1 week

(cherry picked from commit 64b30b7aeb)
2023-07-19 09:26:55 +02:00
Eugene Grosbein 85c1418ba1 syslog.3: MFC: document ident[N] format
When libc switched to generation of logs as per RFC 5424,
that change broke application ability to insert specific process id
using ident[N] format, the feature existed for decades.
Some processes rely on it (including logger and syslogd).

Later the regression was fixed but the feature remained undocumented.
This change documents it.

(cherry picked from commit 5aee3e14d4)
2023-07-18 15:07:04 +07:00
Eugene Grosbein 829dbdcac2 logger(1): MFC: fix timestamps in case of long run
An example:

( echo test; sleep 2; echo test2 ) | logger -h /var/run/log

Before fix, logger assigned same timestamp to both records.

Fixes:		65547fb33d
Reported by:	Vadim Goncharov

(cherry picked from commit 83fd35b3f3)
2023-07-18 14:24:26 +07:00
Koichiro Iwao 8cf8bbfef5 ifconfig.8: Document limitation of groupname
Approved by:		kp
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D40645

(cherry picked from commit 9aca30d878)
2023-07-11 13:49:34 +09:00
Kristof Provost 9835aa0d7d if_bridge: fix potential panic
When a new bridge_rtnode is added it is added with a NULL brt_dst. The
brt_dst is set after the entry is added. This means there's a small
window where another core could also attempt to add this node, leading
to the code attempting to log that the MAC addresses moved to a new
interface.
Aside from that being a spurious log entry it also panics, because
obif is NULL (and we attempt to dereference it).

Avoid this by settings brt_dst before we insert the bridge_rtnode.
Assert that obif is non-NULL, as an extra precaution.

Reported by:	olivier@
Reviewed by:	zlei@
Differential Revision:	https://reviews.freebsd.org/D40147

(cherry picked from commit f3546eacf0)
2023-07-09 14:27:01 +02:00
Cy Schubert 6edaf8c7ae pam_krb5: Add missing patch
Include a portion of the patch that was missed in 813847e49e.

Reported by:	markj
Fixes:		813847e49e

(cherry picked from commit bfa51318de)
2023-07-07 22:44:51 -07:00
Devin Teske 98358de575 Fix spurious error from sysrc
When using sysrc to modify a file, the file should be created silently.
However, with the introduction of SVN r335280, an error of "No such file
or directory" would appear despite everything else working as-expected.

The nature of this spurious error is that SVN r335280 did not check if
the file exists first, before trying to fixup the line-endings in the
file just prior to modification.

PR:		bin/240875
Reported by:	Jose Luis Duran
MFC after:	3 days

(cherry picked from commit e19a2226fe)
2023-07-06 17:39:23 +02:00
Glen Barber afbcdd6e08 release: update GCE configuration for python3
Reported by:	asomers
PR:		272354
Sponsored by:	GoFundMe https://www.gofundme.com/f/gjbbsd

(cherry picked from commit 3f21d3e0ba)
2023-07-05 17:00:31 -04:00
Brad Davis 6dd5f02313 release: allow VM_EXTRA_PACKAGES to be specified in the environment
This is useful for adding extra packages to the build of an AMI.
For example:
	env VM_EXTRA_PACKAGES="zsh" make -C release ec2ami

(cherry picked from commit 83952a5baa)
2023-07-05 17:00:20 -04:00
Ka Ho Ng 2d148ce84d syscalls: fix modspecific_t stack content leak
Zero-initialize the whole modspecific_t so that there would
not be kernel stack content leak in the unused part.

Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D40815

(cherry picked from commit 2cab2d43b8)
2023-07-04 08:52:50 -04:00
Dag-Erling Smørgrav 0f0b8bb211 Upgrade to OpenPAM Ximenia.
Merge commit '5894a4142a9d5ae5f7f6bee1f46237a3d20d0b5b'

(cherry picked from commit 3ba4c8c81a)
2023-07-03 17:13:49 +02:00
Ka Ho Ng 593211cc71 SYSCALL_MODULE(9): fix references to modfind(2) and modstat(2)
Sponsored by:	Juniper Networks, Inc.
Reviewed by:	delphij
MFC after:	1 week

(cherry picked from commit 9f135336f5)
2023-07-01 14:43:15 -04:00
Dimitry Andric 2846052cd4 Apply llvm fix for hanging gcc builds on 32-bit arm
Merge commit 962c306a11d0 from llvm-project (by Florian Hahn):

  [LV] Don't consider pointer as uniform if it is also stored.

  Update isVectorizedMemAccessUse to also check if the pointer is stored.
  This prevents LV to incorrectly consider a pointer as uniform if it is
  used as both pointer and stored by the same StoreInst.

  Fixes #61396.

PR:		271992
Reported by:	John F. Carr <[email protected]>
MFC after:	3 days

(cherry picked from commit dbbaf77801)
2023-06-28 20:00:06 +02:00
Kristof Provost d0076c7a86 netinet: re-read IP length after PFIL hook
The pfil hook may modify the packet, so before we check its length (to
decide if it needs to be fragmented or not) we should re-read that
length.

This is most likely to happen when pf is reassembling packets. In that
scenario we'd receive the last fragment, which is likely to be a short
packet, pf would reassemble it (likely exceeding the interface MTU) and
then we'd transmit it without fragmenting, because we're comparing the
MTU to the length of the last fragment, not the fully reassembled
packet.

See also:	https://redmine.pfsense.org/issues/14396
Reviewed by:	cy
MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D40395

(cherry picked from commit 185c1cddd7)
2023-06-28 11:15:59 +02:00
Kevin Bowling dac6aa05f8 e1000: Add SPDX tag to em_txrx
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D30072

(cherry picked from commit 034f38cdf8)
2023-06-27 14:03:43 -07:00
Kevin Bowling 670a17e9f9 e1000: Format em_txrx
No functional changes intended.

Reviewed by:	markj (prior version)
Differential Revision:	https://reviews.freebsd.org/D30072

(cherry picked from commit 5253d74e46)
2023-06-27 14:03:36 -07:00
Dag-Erling Smørgrav 372f51eaf3 Merge upstream r948: fix race condition in openpam_ttyconv(3).
(cherry picked from commit a90c7d9aa8)
2023-06-27 19:21:25 +02:00
domienschepers 84d538470b net80211: fail for unicast traffic without unicast key
Falling back to the multicast key may cause unicast traffic to leak.
Instead fail when no key is found.

For more information see the 'Framing Frames: Bypassing Wi-Fi Encryption
by Manipulating Transmit Queues' paper.

[ I updated the commit message to reference the paper and the code
comment to record historic behaviour as discussed in private email. ]

(cherry picked from commit 61605e0ae5)
2023-06-26 12:28:52 +00:00
Michael Tuexen 6dc94f4ba1 libalias: improve handling of invalid SCTP packets
In case of a paritial chunk only pretend the result is OK if
the packet is not the last fragment and there is a valid association.

PR:		267476

(cherry picked from commit 9a71437621)
2023-06-25 21:42:28 +02:00
R. Christian McDonald cc6d0b4bd2 wpa: Enable receiving priority tagged (VID 0) frames
Certain internet service providers transmit vlan 0 priority tagged
EAPOL frames from the ONT towards the residential gateway. VID 0
should be ignored, and the frame processed according to the priority
set in the 802.1P bits and the encapsulated EtherType (i.e. EAPOL).

The pcap filter utilized by l2_packet is inadquate for this use case.

Here we modify the pcap filter to accept both unencapsulated and
encapsulated (with VLAN 0) EAPOL EtherTypes. This preserves the
original filter behavior while also matching on encapsulated EAPOL.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Reviewed by:	cy
Differential Revision:	https://reviews.freebsd.org/D40442

(cherry picked from commit bb5d6d14d8)
2023-06-24 21:08:04 -07:00
Dmitriy Alexandrov e66b677c97 kern_ntptime: Fix undefined behavior of the shift operator
L_LINT macro is used with negative numbers [i.e.
L_LINT(time_freq, -MAXFREQ)], it could cause undefined
behavior. It should be similar to the L_RSHIFT(v, n) macro.

MFC after:	2 weeks
Reviewed by:	cy
Pull Request:	https://github.com/freebsd/freebsd-src/pull/769
Signed-off-by: Dmitriy Alexandrov <[email protected]>
(cherry picked from commit af9ce4e9bb)
2023-06-22 21:35:04 -07:00
Brad Smith f651a3f8ff msun: Correct FreeBSD version in sincos() man page
The sincos() man page notes the function was added to msun in FreeBSD
9.0 which must have been an oversight in the review as it was commited
to 12.0 and then backported to the 11 branch.

So I have provided a diff to correct this to the first FreeBSD version
it did ship with which was 11.2.

Reviewed by:	dim, imp
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D40308

(cherry picked from commit 2c01176a28)
2023-06-23 00:02:27 +02:00
Gordon Bergling 3d4102fad4 nameser: Fix a typo in a source code comment
-s /unknwon/unknown/

(cherry picked from commit 8f79b07564)
2023-06-22 06:32:12 +02:00
Kristof Provost 48bb8ea97e pf: fix pf_nv##_array() size check
We want to set the maximum number of elements we'll accept, not the
exact number we need.

MFC after:	3 weeks
Sponsored by:	Orange Business Services

(cherry picked from commit 76c8f202a4)
2023-06-21 16:29:18 +02:00
Poul-Henning Kamp 917f8b6781 freebsd-update: Mention 13.2-RELEASE in usage.
(cherry picked from commit e0e5bf4d62)
(cherry picked from commit c6d3829c09)
2023-06-21 08:59:47 -04:00
Ed Maste bb72791736 freebsd-update: re-edit files if merge conflict markers remain
freebsd-update will open ${EDITOR} if conflicts occur while merging
updates to config files.  Inform the user if they've left conflict
markers behind, and go back to editing the file.

PR:		185546
PR:		229689
Reviewed by:	delphij
Approved by:	re (cperciva, expedited MFC)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37703

(cherry picked from commit ceb5f28ba5)
(cherry picked from commit c7e3703352)
(cherry picked from commit e27ded83c7)
(cherry picked from commit b562307b70)
2023-06-21 08:58:01 -04:00
Ed Maste 2004a768e4 freebsd-update: avoid effects of user's environment on grep
A user had GREP_OPTIONS containing --color=always, which broke grep use
in freebsd-update.  Unset this environment variable.

PR:		255990
Reviewed by:	kevans
Approved by:	re (cperciva, expedited MFC)
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit e093c61b2d)
(cherry picked from commit 24fe8a5183)
2023-06-21 08:54:37 -04:00
Cy Schubert 5018f551ec pam_krb5: Fix spoofing vulnerability
An adversary on the network can log in via ssh as any user by spoofing
the KDC. When the machine has a keytab installed the keytab is used to
verify the service ticket. However, without a keytab there is no way
for pam_krb5 to verify the KDC's response and get a TGT with the
password.

If both the password _and_ the KDC are controlled by an adversary, the
adversary can provide a password that the adversary's spoofed KDC will
return a valid tgt for.  Currently, without a keytab, pam_krb5 is
vulnerable to this attack.

Reported by:	Taylor R Campbell <[email protected]> via emaste@
Reviewed by:	so
Approved by:	so
Security:	FreeBSD-SA-23:04.pam_krb5
Security:	CVE-2023-3326

(cherry picked from commit 813847e49e)
2023-06-20 22:26:03 -07:00
Gordon Bergling f7d6966853 xdr(3): Fix a typo in a source code comment
- s/curren/current/

(cherry picked from commit 85604f7008)
2023-06-20 06:00:53 +02:00
Sean Eric Fagan ba129c5716 Allow a comma-separated list in login class capabilities,
by adding a version of strcspn that allows quoting.

PR:		236204
Differential Revision:	https://reviews.freebsd.org/D25368

(cherry picked from commit f32db40650)
(cherry picked from commit f122e55235)
2023-06-14 09:38:26 -04:00
Mina Galić fedfe27422 rc(8): document how to reload rc's configuration
The fact that rc(8) only reads its configuration once is in the man
page, but how to trigger a reload is only in the code.

Discovered while trying to make cloud-init disable and stop syslogd.

Thanks to RhodiumToad for providing the words.

Reviewed by:           debdrup, grahamperrin
Approved by:           grahamperrin, imp
Sponsored by:          The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D40329

(cherry picked from commit 0981275c75)
2023-06-10 19:23:06 +01:00
Cy Schubert 2a5324685d ntp: import ntp-4.2.8p17
Fixes two small bugs including one regression.

Merge commit 'ab1f1aa8333369a83ff284848fc3fc2e52d5f29f'

(cherry picked from commit e6bfd18d21)

ntp: Fix build

Two files used to obtain time from reference clocks did not include
ntp_types.h resulting in an undefined NONEMPTY_TRANSLATION_UNIT.

Fixes:		e6bfd18d21

(cherry picked from commit 82aa1470c9)
2023-06-09 06:39:05 -07:00
Ed Maste 52503c4477 sftp: avoid leaking path arg in calls to make_absolute_pwd_glob
As Coverity reports:
    Overwriting tmp in tmp = make_absolute_pwd_glob(tmp, remote_path)
    leaks the storage that tmp points to.

Consume the first arg in make_absolute_pwd_glob, and add xstrdup() to
the one case which did not assign to the same variable that was passed
in. With this change make_absolute() and make_absolute_pwd_glob() have
the same semantics with respect to freeing the input string.

This change was reported to OpenSSH in
https://lists.mindrot.org/pipermail/openssh-unix-dev/2022-November/040497.html
[and was later adopted upstream].

Reported by:	Coverity Scan
CID:		1500409
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37253

(cherry picked from commit 69c72a57af)
(cherry picked from commit 533a942a21)
2023-06-05 15:07:56 -04:00
Ed Maste 77d002b9cb ssh: fix leak and apply style(9) to hostname canonicalization
Fixes:		bf2e2524a2 ("ssh: canonicize the host name before...")
Fixes:		3e74849a1e ("ssh: canonicize the host name before...")
Reviewed by:	rew
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D38441

(cherry picked from commit 19aba210e1)
(cherry picked from commit 792d3f1686)
2023-06-05 15:05:32 -04:00
Ed Maste 2b4fb1350c openssh: include destination constraints for smartcard keys
From openssh-portable 54ac4ab2b53ce9fcb66b8250dee91c070e4167ed,
OpenBSD-Commit-ID: add879fac6903a1cb1d1e42c4309e5359c3d870f

PR:		271839
Sponsored by:	The FreeBSD Foundation
2023-06-05 10:56:23 -04:00
Cy Schubert 60ab53f3a6 sqlite3: Vendor import of sqlite3 3.42.0
Release notes at https://www.sqlite.org/releaselog/3_42_0.html.

Obtained from:  https://www.sqlite.org/2023/sqlite-autoconf-3420000.tar.gz

Merge commit '92b2b066353ddd32e1d59f8c52c430d552d9a9a5' into sqlite3/main

(cherry picked from commit 402cee1f19)
2023-06-04 20:42:08 -07:00
Przemyslaw Lewandowski 197106cf41 ixgbe: Change if condition for RSS and rxcsum
This patch fixes TCP connection hangs for 1 rxq and 1 txq without rxcsum
enabled. Documentation for 10G cards and other drivers suggest enabling
rxcsum for RSS and disabling otherwise. When PCSD bit is not set then
fragment checksum and IP identification are reported in the rx
descriptor. When PCSD bit is set then RSS hash value is reported in the
rx descriptor. RSS and RX IPP checksum are mutually exclusive.

Signed-off-by: Eric Joyner <[email protected]>

PR:		268910
Reviewed by:	erj@
Tested by:	[email protected]
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D38621

(cherry picked from commit 156424fce9)
2023-06-02 12:35:05 -07:00
Cy Schubert 58df1aed1c ntp: Update version string
Chase a466cc5537, updating the version string in the local config.h.

Reported by:	 Trond Endrestol <[email protected]>
Fixes:		a466cc5537

(cherry picked from commit 4d78061377)
2023-06-01 15:18:06 -07:00
Dimitry Andric dbbac83e39 Apply clang fixes for crashes compiling ARM/AArch64 CRC intrinsics
Merge commit 069ecd0c6e2c from llvm-project (by Fangrui Song):

  [ARM] Check target feature support for __builtin_arm_crc*

  `__builtin_arm_crc*` requires the target feature crc which is available on armv8
  and above. Calling the fuctions for armv7 leads to a SelectionDAG crash.

  ```
  % clang -c --target=armv7-unknown-linux-gnueabi -c a.c
  fatal error: error in backend: Cannot select: intrinsic %llvm.arm.crc32b
  PLEASE submit a bug report to ...
  ```

  Add `TARGET_BUILTIN` and define required features for these builtins to
  report an error in `CodeGenFunction::checkTargetFeatures`. The problem is quite widespread.
  I will add `TARGET_BUILTIN` for more builtins later.

  Fix https://github.com/llvm/llvm-project/issues/57802

  Differential Revision: https://reviews.llvm.org/D134127

Merge commit b2d7a0dcf1ff from llvm-project (by Fangrui Song):

  [AArch64] Check target feature support for __builtin_arm_crc*

  This is the AArch64 counterpart of D134127.
  Daniel Kiss will change more `BUILTIN` to `TARGET_BUILTIN`.

  Fix #57802

Note that programs attempting to use ARM/AArch64 CRC intrinsics, when
they are not supported by the targeted CPU, will still receive a regular
compilation error (instead of a fatal backend error) similar to:

  7zCrc.c:4:10: error: '__builtin_arm_crc32b' needs target feature crc
    return __builtin_arm_crc32b(a, b);
           ^

Reported by:	Alastair Hogge <[email protected]>
PR:		271624
MFC after:	3 days

(cherry picked from commit 8792c03886)
2023-06-01 21:16:11 +02:00
Cy Schubert cf960e546b ntp: import ntp-4.2.8p16
Security:       NtpBUg3767, NtpBug3808, NtpBug3807 (CVE-2023-26555)

(cherry picked from commit a466cc5537)
2023-06-01 07:46:42 -07:00
Eric van Gyzen 8fa89d8b19 Fix NULL deref in ip_output during route change
When changing the interface address during a route change,
the rtentry's rt_ifa will be NULL briefly.  Some parts of
ip_output do not handle that NULL.  In such case, re-validate
the rtentry.  That validation does not check the rt_ifa, but
it does lock the route, which will synchronize with
rtrequest1_fib_change.

I would prefer to leave the rt_ifa pointer intact during
the route change, but ip6_output is not fully protected
by the net_epoch, so that could allow a use-after-free.
ip6_output already handles a NULL rt_ifa.

This is a direct commit to stable/12 because later branches
have nexthop and do not appear to have this bug.

PR:		271573
Reported by:	[email protected]
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D40236
2023-05-30 07:10:03 -05:00
Jung-uk Kim 48f06dbeb3 OpenSSL: Regen manual pages for OpenSSL 1.1.1u
(cherry picked from commit 5b1268252c)
2023-05-30 13:03:56 -04:00
Jung-uk Kim 53e3243b05 OpenSSL: Merge OpenSSL 1.1.1u
(cherry picked from commit 84ffbd7782)
2023-05-30 13:03:44 -04:00
Jung-uk Kim 37cf93a969 OpenSSL: Merge OpenSSL 1.1.1u
(cherry picked from commit 8ecb489345f08012fdc92a202a40119891cac330)
(cherry picked from commit 8f1ef87a6b)
2023-05-30 13:02:51 -04:00
Kristof Provost 78c6659238 pfsync tests: check for the correct IP address
When checking if the state synced over we should look for
198.51.100.254, not 198.51.100.2. The test worked because the incorrect
address is a substring of the correct one, but we should fix it anyway.

Reported by:	Naman Sood <[email protected]>
MFC after:	1 week

(cherry picked from commit 0d574d8ba8)
2023-05-25 03:56:19 +02:00
Rick Macklem 886d82afb0 nfsd: Fix NFSv3 Readdir/ReaddirPlus reply for large i-node numbers
If the i-node number (d_fileno) for a file on the server did
not fit in 32bits, it would be truncated to the low order 32bits
for the NFSv3 Readdir and ReaddirPlus RPC replies.
This is no longer correct, given that ino_t is now 64bits.

This patch fixes this by sending the full 64bits of d_fileno
on the wire in the NFSv3 Readdir/ReaddirPlus RPC reply.

PR:	271174

(cherry picked from commit 648a208ef3)
2023-05-22 12:08:30 -07:00
Piotr Kubaj 737f887379 ix(4): correct max MTU
The max MTU for the ix(4) is 9710.

Differential revision:	https://reviews.freebsd.org/D40003
Approved by:	erj, bcr

(cherry picked from commit 2e57f7bf20)
(cherry picked from commit af8fd75b45)
2023-05-19 14:33:21 +02:00
Jose Luis Duran e896ce8e37 passwd.5: Update man page after e0155c6989
MFC After:	3 days

(cherry picked from commit 6e068d6bea)
2023-05-19 10:19:56 +02:00
Jose Luis Duran 45f3aa3ddf passwd.5: Remove .Tn (Trade Name) macros
To appease mandoc -T lint, remove .Tn macros.

MFC After:	3 days

(cherry picked from commit d047a4e486)
2023-05-19 10:19:56 +02:00
pbuff 554f8644b0 pw: The pw_checkname function has added ';' checking.
The pw_checkname function forgot to include a ';'
when checking usernames, causing shell commands
to be executed when a username with a ';' is deleted.

PR:		271427
MFC After:	3 days

(cherry picked from commit e0155c6989)
2023-05-19 10:19:55 +02:00
Michael Osipov 0cf997acbf periodic: Use locale-agnostic (ISO 8601) timestamp format
Instead of reyling on locale-sensitive output which can be mangled when e-mailed
use consistently ISO 8601 format which contains the same information as '-T'.

PR:		271240
MFC After:	3 days

(cherry picked from commit d2b4753f06)
2023-05-19 10:19:55 +02:00
Baptiste Daroussin 2f251aa5ad pw: do not call system()
Calling system makes pw(8) spawn a shell, which can then be abused.

MFC After:	3 days

(cherry picked from commit ef7d0eb948)
2023-05-19 10:19:55 +02:00
Zhenlei Huang 4f6be38eed mrsas: Fix a typo in a source code comment
- s/feild/field/

MFC after:	3 days

(cherry picked from commit bbfb244724)
(cherry picked from commit 62af5091a4)
2023-05-17 18:03:30 +08:00
Zhenlei Huang a043c76d3e mps: Fix a typo in a source code comment
- s/feild/field/

MFC after:	3 days

(cherry picked from commit 5bcbdb0b2e)
(cherry picked from commit 3056dfbdf8)
2023-05-17 18:03:17 +08:00
Ian Moffett b23360fe13 ixgbe: Fix typos in source code comments
- s/feilds/fields/

Reviewed by:	zlei
MFC after:	3 days
Pull Request:	https://github.com/freebsd/freebsd-src/pull/707

(cherry picked from commit 99cb088f1a)
(cherry picked from commit 1437712fd8)
2023-05-17 18:03:03 +08:00
Zhenlei Huang c0612a203c elf.5: Fix conjugation of holds
MFC after:	1 week

(cherry picked from commit 6f96b5487f)
(cherry picked from commit 4d7d39b0f2)
2023-05-17 18:02:49 +08:00
Zhenlei Huang 2a3147f962 ip_mroute: Delete unreachable code
As the flag M_WAITOK is passed to ip_encap_attach(), then the function
will never return NULL, and the following code within NULL check branch
will be unreachable.

No functional change intended.

Reviewed by:	kp
Fixes:		6d8fdfa9d5 Rework IP encapsulation handling code
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39746

(cherry picked from commit b658c0fce1)
(cherry picked from commit ece63e96c3)
2023-05-17 18:02:29 +08:00
Zhenlei Huang 1ff44a05d6 if_stf: Delete unreachable code
As the flag M_WAITOK is passed to ip_encap_attach(), then the function
will never return NULL, and the following code within NULL check branch
will be unreachable.

No functional change intended.

Reviewed by:	kp
Fixes:		6d8fdfa9d5 Rework IP encapsulation handling code
MFC after:	1 week
Differential Revision:  https://reviews.freebsd.org/D39746

(cherry picked from commit c373e1d6ad)
(cherry picked from commit f70caf1b45)
2023-05-17 18:02:12 +08:00
Kristof Provost 5cb5b36882 e1000: fix VLAN 0
VLAN 0 essentially means "Treat as untagged, but with priority bits",
and is used by some ISPs.

On igb/em interfaces we did not receive packets with VLAN tag 0 unless
vlanhwfilter was disabled.

This can be fixed by explicitly listing VLAN 0 in the hardware VLAN
filter (VFTA). Do this from em_setup_vlan_hw_support(), where we already
(re-)write the VFTA.

Reviewed by:	kbowling
Sponsored by:   Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D40046

(cherry picked from commit 0229fab2fe)
2023-05-15 06:49:51 +02:00
Mina Galic d3ee609cf2 ntpd: Support IPv6-only hosts
0.pool.* returns only IPv4 addresses.
2.pool.* returns both, IPv6 and IPv4 addresses.

conservatively extend our IPv4 only pool configuration by adding a
second pool, which also returns IPv6 addresses.

PR:			270536
Reported by:		Lapo Luchini <[email protected]>
Pull Request:		https://github.com/freebsd/freebsd-src/pull/731
Differential Revision:	https://reviews.freebsd.org/D39954

(cherry picked from commit fff1551c03)
2023-05-07 21:17:59 -07:00
Jason A. Harmening 95e02a4192 Intel DMAR: remove parsing of 6-level paging capability
Early versions of the VT-d spec mentioned 6-level paging support as a
possible value for the SAGAW capability, but later versions removed it
and SAGAW=0x10 is currently listed as a reserved value.

The 6-level (agaw=64) entry in sagaw_bits is furthermore problematic
with clang15 because the attempted comparison against 1ULL << 64 in
dmar_maxaddr2mgaw() causes the compiler to elide the last iteration
of the initial loop, which bypasses the subsequent logic to find the
greatest HW-supported address width.  This results in 5-level paging
always being selected regardless of whether the hardware supports it,
which can result address translation failure due to invalid context-
entry programming.

Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D39896

(cherry picked from commit 6f378116e9)
2023-05-05 20:00:34 -05:00
Ravi Pokala d0049a46bd jedec_dimm(4): Refactor offset adjustment and page0 reset
Offsets greater than 255 bytes reside on page1 of the SPD device.
Accessing them requires switching to page1, and adjusting the absolute
offset to be relative to the start of page1. After the access, the page
must be set back to page0. These operations are performed in several
places, so break them out into their own functions.

Also, replace a pair of default cases, which should be impossible due to
earlier checks, with __assert_unreachable().

Reviewed by:	imp
MFC after:	1 week
Sponsored by:	Panasas
Differential Revision:	https://reviews.freebsd.org/D39842

(cherry picked from commit 15d69c840d)
2023-05-04 17:30:29 -07:00
Ravi Pokala a9ee57e46f jedec_dimm(4): Add manufacturing year and week.
DDR3 and DDR4 encode the week and year that the DIMM was manufactured,
as a pair of two-digit binary-coded decimal values. Read the values, and
report them as (uint8_t)s.

Reviewed by:	imp, jhb
MFC after:	1 week
Sponsored by:	Panasas
Differential Revision:	https://reviews.freebsd.org/D39795

(cherry picked from commit de57e0ef5a)
2023-05-04 17:30:19 -07:00
Dimitry Andric 22028f12f1 powerpc: fix another pmap related function to return the correct type
Missed one prototype while cherry-picking commit d142601887.

Fixes:		e9e1f2a88e
2023-05-03 16:31:11 +02:00
Dimitry Andric c3da468bef boolean_t: change to unsigned int to avoid signed bitfield warnings
This is the final part, which actually makes boolean_t unsigned. Note
that we do not change its size, nor do we try to change it directly to
bool, since that results in a lot of regressions.

Converting the remaining instances of boolean_t to plain C99 bool can
now be done in a piecemeal fashion, after which boolean_t may hopefully
be retired.

MFC after:	1 week
Reviewed by:	jhb
Differential Revision: https://reviews.freebsd.org/D39753

(cherry picked from commit 3029b0b0e9)
2023-05-03 11:36:36 +02:00
Dimitry Andric 3f527b4b8f vm: fix a number of functions to match the expected prototypes
Noticed while attempting to make boolean_t unsigned: some vm-related
function declarations and defintions were using boolean_t where they
should have used int, and vice versa.

MFC after:	1 week
Reviewed by:	jhb
Differential Revision: https://reviews.freebsd.org/D39753

(cherry picked from commit f74be55e30)
2023-05-03 11:36:32 +02:00
Dimitry Andric 44f4aaee6b Apply clang fix for assertion building emulators/rpcs3
Merge commit a5e1a93ea10f from llvm-project (by Mariya Podchishchaeva):

  [clang] Fix crash when handling nested immediate invocations

  Before this patch it was expected that if there was several immediate
  invocations they all belong to the same expression evaluation context.
  During parsing of non local variable initializer a new evaluation context is
  pushed, so code like this
  ```
  namespace scope {
  struct channel {
      consteval channel(const char* name) noexcept { }
  };
  consteval const char* make_channel_name(const char* name) { return name;}

  channel rsx_log(make_channel_name("rsx_log"));
  }
  ```
  produced a nested immediate invocation whose subexpressions are attached
  to different expression evaluation contexts. The constructor call
  belongs to TU context and `make_channel_name` call to context of
  variable initializer.

  This patch removes this assumption and adds tracking of previously
  failed immediate invocations, so it is possible when handling an
  immediate invocation th check that its subexpressions from possibly another
  evaluation context contains errors and not produce duplicate
  diagnostics.

  Fixes https://github.com/llvm/llvm-project/issues/58207

  Reviewed By: aaron.ballman, shafik

  Differential Revision: https://reviews.llvm.org/D146234

PR:		269489
MFC after:	3 days

(cherry picked from commit 56f2446575)
2023-05-03 10:25:29 +02:00
John Baldwin 076116b884 libpmc: Use LIB_CXX instead of explicit LDADD to link a C++ library.
This uses the C++ compiler as the linker instead of the C compiler
letting the compiler driver pick the right libraries.  This is a no-op
on main and stable/13 but matters for stable/12 where the current
logic breaks for external GCC since it tries to use a non-existent
libstdc++.

Reviewed by:	emaste
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39197

(cherry picked from commit c6b3f47fed)
2023-05-02 09:52:38 -07:00
Mariusz Zaborski 4850058011 mpr: don't use hardcoded value in debug branch
Pointed out by:	imp
Sponsored by:   Klara Inc.

(cherry picked from commit 444c661545)
2023-05-02 14:19:35 +02:00
Mariusz Zaborski 2de69df6f3 mpr: fix copying of event_mask
Before the commit 6cc44223cb the
field event_mask was fully copied to the EventMasks field.
After this commit the event_mask (uint8_t) is 4 times casted to
EventMask (uint32_t). Because of that 24 bits of each event_mask array
is lost.

This commits brings back simple copying of field, and after words
converting 32 bits field to the requested endian.

I don't think we need more sophisticated method,
as the array is of size 4 (for 32 bits version).

Reviewed by:	imp
MFC after:	1 week
Sponsored by:	Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D39562

(cherry picked from commit ea6597c38c)
2023-05-02 14:19:26 +02:00
Cy Schubert c3bbba00e4 sqlite3: Vendor import of sqlite3 3.41.2
Release notes at https://www.sqlite.org/releaselog/3_41_2.html.

Obtained from:  https://www.sqlite.org/2023/sqlite-autoconf-3410200.tar.gz

Merge commit '853a43f7c79218855a6e45a25a00b942972e3fa1'

(cherry picked from commit e7e621f94d)
2023-04-30 21:14:45 -07:00
Dimitry Andric aee9018306 al_eth: make function definitions consistent with declarations
The declarations for al_eth_lm_retimer_ds25_signal_detect() and
al_eth_lm_retimer_ds25_cdr_lock() say that these functions return
'al_bool', but the definitions actually return 'boolean_t'.

Make the definitions match the declarations.

Reviewed by:	jhb, emaste
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D39759

(cherry picked from commit 9ea31d78f0)
2023-04-29 09:35:40 +02:00
Dimitry Andric 821e1767aa Use bool for one-bit wide bit-fields
A signed one-bit wide bit-field can take only the values 0 and -1. Clang
16 introduced a warning that "implicit truncation from 'int' to a
one-bit wide bit-field changes value from 1 to -1". Fix the warnings by
using C99 bool.

Reported by:	Clang 16
Reviewed by:	emaste, jhb
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D39705

(cherry picked from commit bab8274c09)
2023-04-29 09:35:33 +02:00
Dimitry Andric e9e1f2a88e powerpc: fix a few pmap related functions to return correct types
While experimenting with changing boolean_t to another type, I noticed
that several powerpc pmap related functions returned the wrong type:
boolean_t instead of int.

Fix several declarations and definitions to match the actual pmap
function types: pmap_dev_direct_mapped_t and pmap_ts_referenced_t.

MFC after:	3 days

(cherry picked from commit d142601887)
2023-04-29 09:35:10 +02:00
Dimitry Andric 4e7487f388 Include bsd.linker.mk to get LINKER_TYPE and VERSION in rescue
To be able to use these make variables, you also have to include
bsd.linker.mk, apparently.

Fixes:		458f4722bf
MFC after:	1 week

(cherry picked from commit 653e8c11f4)
2023-04-29 09:24:37 +02:00
Dimitry Andric d5ee36dbb2 Suppress lld 16 errors about undefined symbols in version maps
lld >= 16 turned on --no-undefined-version by default, which results in
errors whenever symbols are mentioned in version maps, but are not
actually defined in the binary.

Since we have quite a few instances of symbols that are defined or not,
depending on various compile-time settings, suppress this lld check for
the time being.

MFC after:	1 week

(cherry picked from commit 2ba84b4bcd)
2023-04-29 09:24:32 +02:00
Dimitry Andric c14351db0d Suppress lld 16 errors about multiply defined symbols in rescue
lld >= 16 became more strict about multiply defined symbols. Since there
are many of those in crunchgen'd programs, turn off the check when
linking the rescue binary.

MFC after:	1 week

(cherry picked from commit 458f4722bf)
2023-04-29 09:24:24 +02:00
Eugene Grosbein dffde5aa07 ipfw.8: MFC: improve description for interface matching
The manual describes "if*" form only while kernel uses fnmatch(3)
and allows use for more versatile shell-like patterns.
Note that explicitly and provide an example.

(cherry picked from commit 9f5dc374d0)
2023-04-28 13:02:17 +07:00
Ed Maste 545163d9bc openssh: restore PrintLastLog option
Upstream's autoconf sets DISABLE_LASTLOG if lastlog.ll_line does not
exist, but PrintLastLog also works with utmpx and other mechanisms.

Reported upstream at
https://lists.mindrot.org/pipermail/openssh-unix-dev/2022-May/040242.html

PR:		209441
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 43c6b7a60a)
(cherry picked from commit 170511589e)
(cherry picked from commit 170520f882)
2023-04-27 12:48:33 -04:00
Dimitry Andric 4c1575e360 kern.mk: clang >= 16 already infers ELFv2 for powerpc64
There is no need to pass -mabi=elfv2 explicitly anymore, and with clang
16 in fact results in a "unused argument" warning.

MFC after:	3 days

(cherry picked from commit 4214005276)
2023-04-23 11:33:12 +02:00
Gordon Bergling 1511a4136c net80211: Remove double words in source code comments
- s/we we/we/

(cherry picked from commit 93e4914816)
2023-04-23 07:16:47 +02:00
Gordon Bergling 576efbba86 last(1): Remove double words in source code comments
- s/on on/on/
- s/we we/we/

(cherry picked from commit 1190b82c22)
2023-04-23 07:16:38 +02:00
Gordon Bergling 7e61ff285f stand: Remove a double word in a source code comment
- s/value value/value/

(cherry picked from commit 66095010d1)
2023-04-23 07:16:27 +02:00
Dimitry Andric 17eaa359dc ichiic: use bool for one-bit wide bit-fields
A one-bit wide bit-field can take only the values 0 and -1. Clang 16
introduced a warning that "implicit truncation from 'int' to a one-bit
wide bit-field changes value from 1 to -1". Fix by using c99 bool.

Reported by:	Clang
Reviewed by:	emaste, wulf
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D39665

(cherry picked from commit 87f55ab0b4)
2023-04-22 11:00:22 +02:00
Dimitry Andric 449c294936 libarchive: make single bit bitfields unsigned to avoid clang 16 warning
Clang 16 introduced a warning about single bit bitfields in structs,
which is triggered by various declarations in libarchive:

    contrib/libarchive/libarchive/archive_write_set_format_7zip.c:1541:13: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                    file->dir = 1;
                              ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:5127:15: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                    isoent->dir = 1;
                                ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:5213:14: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
            isoent->dir = 1;
                        ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:5214:18: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
            isoent->virtual = 1;
                            ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:7149:18: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
            isoent->virtual = 1;
                            ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:7435:32: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                    iso9660->zisofs.detect_magic = 1;
                                                 ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:7495:25: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
            iso9660->zisofs.making = 1;
                                   ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:7496:26: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
            iso9660->zisofs.allzero = 1;
                                    ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:7702:28: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                            iso9660->zisofs.allzero = 1;
                                                    ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:7871:25: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                    zisofs->header_passed = 1;
                                          ^ ~
    contrib/libarchive/libarchive/archive_write_set_format_iso9660.c:7894:24: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                            zisofs->initialized = 1;
                                                ^ ~

Signed one-bit bitfields can only have values -1 and 0, but the intent
here is to use the fields as booleans, so make them unsigned.

This has also been sent upstream.

MFC after:	3 days

(cherry picked from commit 67ecab6f50)
2023-04-22 11:00:16 +02:00
Dimitry Andric 859735832d bsnmp: make single bit bitfields unsigned to avoid clang 16 warning
Clang 16 introduced a warning about single bit bitfields in structs,
which is triggered by a declaration in bsnmp's snmpd.h:

    contrib/bsnmp/snmpd/trans_lsock.c:271:21: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
            peer->input.stream = 1;
                               ^ ~

Signed one-bit bitfields can only have values -1 and 0, but the intent
here is to use the field as a boolean, so make it unsigned.

MFC after:	3 days

(cherry picked from commit b740e02500)
2023-04-22 11:00:07 +02:00
Dimitry Andric f65f23e90d libsa: make single bit bitfields unsigned to avoid clang 16 warning
Clang 16 introduced a warning about single bit bitfields in structs,
which is triggered by a declaration in libsa's tftp.c:

    stand/libsa/tftp.c:382:20: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                                    h->islastblock = 1;     /* very short file */
                                                   ^ ~
    stand/libsa/tftp.c:432:18: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                    h->islastblock = 1;     /* EOF */
                                   ^ ~

Signed one-bit bitfields can only have values -1 and 0, but the intent
here is to use the field as a boolean, so make it unsigned.

MFC after:	3 days

(cherry picked from commit 1a3ccb8f15)
2023-04-22 11:00:01 +02:00
Gordon Bergling 14089ff9c2 unionfs.5: Use '.An -nosplit' in the AUTHORS section
Use '.An -nosplit' in the AUTHORS section to prevent line breaks.

(cherry picked from commit 409731e7d7)
2023-04-22 06:44:24 +02:00
Zhenlei Huang 303d9a593b bridge: Log MAC address port flapping
MAC flapping occurs when a bridge receives packets with the same source MAC
address on different member interfaces. The common reasons are:
 - user roams from one bridge port to another
 - user has wrong network setup, bridge loops e.g.
 - someone set duplicated ethernet address on his/her nic
 - some bad guy / virus / trojan send spoofed packets

if_bridge currently updates the bridge routing entry silently hence it is hard
to diagnose.

Emit logs when MAC address port flapping occurs to make it easier to diagnose.

Reviewed by:	kp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D39375
Differential Revision:	https://reviews.freebsd.org/D39542

(cherry picked from commit 2d3614fb13)
(cherry picked from commit 9af6f4268a)
(cherry picked from commit de53ebb0f2)
2023-04-21 18:16:10 +08:00
Zhenlei Huang d26e62ad16 printf.9: Update the use example of the %D conversion specifier
The output of hexadecimal bytes are in lowercase. Update the example to
reflect the reality.

Reviewed by:	gbe (manpages)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39543

(cherry picked from commit 722b7589cc)
(cherry picked from commit ff7151058e)
2023-04-21 18:16:10 +08:00
Zhenlei Huang 673685a50a lagg(4): Correctly define some sysctl variables
939a050ad9 virtualized lagg(4), but the corresponding sysctl of some
virtualized global variables are not marked with CTLFLAG_VNET. A try to
operate on those variables via sysctl will effectively go to the 'master'
copies and the virtualized ones are not read or set accordingly. As a
side effect, on updating the 'master' copy, the virtualized global
variables of newly created vnets will have correct values.

PR:		270705
Reviewed by:	kp
Fixes:		939a050ad9 Virtualize lagg(4) cloner
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D39467

(cherry picked from commit 401f03445e)
(cherry picked from commit 774a2ee9ad)
2023-04-21 18:16:10 +08:00
Zhenlei Huang 109bea7ab8 vnet: Fix a typo in a source code comment
- s/form/from/

MFC after:	3 days

(cherry picked from commit a7acce3491)
(cherry picked from commit fd635d87ad)
2023-04-21 18:16:10 +08:00
Gordon Bergling b5a5ddaa4c grdc.6: Add an ENVIRONMENT section
- Add an ENVIRONMENT section

Obtained from:	OpenBSD

(cherry picked from commit 991360ba49)
2023-04-21 06:46:56 +02:00
Gordon Bergling 3c5b973955 morse.6: Mention to standards in the SEE ALSO section
Mention ITU-T Recommendation F.1 and ITU-R M.1677-1
in the SEE ALSO section.

Obtained from:	OpenBSD

(cherry picked from commit 82a036d86a)
2023-04-21 06:46:49 +02:00
Gordon Bergling b75fa8cba4 mount_nfs.8: Fix a mandoc warning
- sections out of conventional order: Sh IMPLEMENTATION NOTES

(cherry picked from commit c2a9d23736)
2023-04-21 06:46:40 +02:00
Gordon Bergling e04514c9aa arm: Remove a double word in a comment in setjmp
- s/number number/number/

(cherry picked from commit 26713ad9cf)
2023-04-18 06:11:19 +02:00
Ed Maste 40399b2a4a awk: errror on printf format strings lacking conversion specifier
Reported by:	phk
Reviewed by:	imp, markj
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D39573

(cherry picked from commit 5dbd073b04)
(cherry picked from commit 46529cb990)
2023-04-17 09:13:45 -04:00
Zhenlei Huang ae9a69acb1 iicbus(4): Use the existing CTLFLAG_RWTUN flag definition
Use it when possible, instead of separated flags.

No functional change intended.

Reviewed by:	hselasky, erj
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D39466

(cherry picked from commit deac4c7f07)
(cherry picked from commit 07bd2fc402)
2023-04-17 14:22:55 +08:00
Zhenlei Huang f6954802a8 bxe(4): Use CTLFLAG_RDTUN flag definition
sysctl variables rx_budget and max_aggregation_size are read-only loader
tunable. Mark them with CTLFLAG_RD flag.

No functional change intended.

Reviewed by:	hselasky, erj
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D39466

(cherry picked from commit 8bd9afe9e1)
(cherry picked from commit f500ecbeae)
2023-04-17 14:22:55 +08:00
Zhenlei Huang 5813a7c0e7 ice(4): Use the existing CTLFLAG_RWTUN flag definition
Use it when possible, instead of separated flags.

No functional change intended.

Reviewed by:	hselasky, erj
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D39466

(cherry picked from commit 5ff8018108)
(cherry picked from commit 60d6ed9cb8)
2023-04-17 14:22:55 +08:00
Zhenlei Huang 1fa6add287 cam iosched: Use the existing CTLFLAG_RDTUN and CTLFLAG_RWTUN flag definitions
Use them when possible, instead of separated flags.

No functional change intended.

Reviewed by:	hselasky, erj
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D39466

(cherry picked from commit 69cb72b872)
(cherry picked from commit 09f9dad465)
2023-04-17 14:22:55 +08:00
Zhenlei Huang f0274efa33 powerpc: Use the existing CTLFLAG_RDTUN and CTLFLAG_RWTUN flag definitions
Use them when possible, instead of separated flags.

No functional change intended.

Reviewed by:	hselasky, erj
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D39466

(cherry picked from commit dc1c5138c3)
(cherry picked from commit 7124e665da)
2023-04-17 14:22:55 +08:00
Gordon Bergling e7b8295e9c telnet.1: Fix a typo in the manual page
- s/addreess/address/

(cherry picked from commit d2e0204ec0)
2023-04-14 06:34:57 +02:00
Zhenlei Huang 59f3510ea7 ifconfig: Fix configuring if_bridge with additional operating parameters
For clone create and rename operations, the interface name get back can be
different from the one passed to ioctl(). Use the interface name we get back
so that ifconfig will not return unexpected ENXIO.

PR:		270618
Reviewed by:	kp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D39396

(cherry picked from commit 09e5e3d598)
(cherry picked from commit bab5ce8dea)
2023-04-10 13:06:22 +08:00
Zhenlei Huang 24069f0dc0 infiniband: Widen NET_EPOCH coverage
From static code analysis, some device drivers (cxgbe, mlx4, mthca, and qlnx)
do not enter net epoch before lagg_input_infiniband(). If IPoIB interface is a
member of lagg(4) interface, and after returning from lagg_input_infiniband()
the receiving interface of mbuf is set to lagg(4) interface, then when
concurrently destroying the lagg(4) interface, there is a small window that the
interface gets destroyed and becomes invalid before infiniband_input() re-enter
net epoch, thus leading use-after-free.

Widen NET_EPOCH coverage to prevent use-after-free.

Thanks hselasky@ for testing with mlx5 devices.

Reviewed by:	hselasky
Tested by:	hselasky
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39275

(cherry picked from commit 90820ef121)
(cherry picked from commit 5d45e09d50)
2023-04-10 13:06:22 +08:00
Zhenlei Huang 1141268256 lagg(4): Tap traffic after protocol processing
Different lagg protocols have different means and policies to process incoming
traffic. For example, for failover protocol, by default received traffic is only
accepted when they are received through the active port. For lacp protocol, LACP
control messages are tapped off, also traffic will be dropped if they are
received through the port which is not in collecting state or is not joined to
the active aggregator. It confuses if user dump and see inbound traffic on
lagg(4) interfaces but they are actually silently dropped and not passed into
the net stack.

Tap traffic after protocol processing so that user will have consistent view of
the inbound traffic, meanwhile mbuf is set with correct receiving interface and
bpf(4) will diagnose the right direction of inbound packets.

PR:		270417
Reviewed by:	melifaro (previous version)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39225

(cherry picked from commit 5f3d0399e9)
(cherry picked from commit ed44ba413c)
2023-04-10 13:06:22 +08:00
Zhenlei Huang d7dd3c8274 lacp: Use C99 bool for boolean return value
This improves readability.

No functional change intended.

MFC after:	1 week

(cherry picked from commit 5a8abd0a29)
(cherry picked from commit d1d5d8f696)
2023-04-10 13:06:22 +08:00
Zhenlei Huang cb7a77b8ba lagg(4): Refactor out some lagg protocol input routines into a default one
Those input routines are identical.

Also inline two fast paths.

No functional change intended.

MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39251

(cherry picked from commit dbe86dd5de)
(cherry picked from commit eeb96a7b91)
2023-04-10 13:06:21 +08:00
Zhenlei Huang f3493c8652 lagg(4): Make lagg_list and lagg_detach_cookie static
They are used internally only.

No functional change intended.

MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39250

(cherry picked from commit fcac5719a1)
(cherry picked from commit b452382e5c)
2023-04-10 13:06:21 +08:00
Zhenlei Huang 731e9e830f lagg: Various style fixes
MFC after:	1 week

(cherry picked from commit dcd7f0bd02)
(cherry picked from commit 9d1d0667c7)
2023-04-10 13:06:21 +08:00
Zhenlei Huang 78e05da5c2 xhci(4): Describe Fresco Logic FL1009 USB 3.0 controller
Reviewed by:	hselasky
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D38922

(cherry picked from commit 082895ebec)
(cherry picked from commit 298d6896b0)
2023-04-10 13:06:21 +08:00
Warner Losh b7768c8f25 times: Use modern function definitions
Use the modern ANSI function defition syntax rather than the old K&R
syntax for times.

Sponsored by:		Netflix

(cherry picked from commit aec9453fec)
2023-04-09 16:37:36 +02:00
Cy Schubert 6fb835f3b6 heimdal: Do not build a redundant source file
Heimdal's lib/hdb/db3.c is only built if DB3 is enabled, i.e. #if HAVE_DB3.
FreeBSD's bdb is DB1. Therefore the entire db3.c file is #ifdef'd out.
Let's avoid building a file that results in a useless object file.

(cherry picked from commit 7ee18f5aad)
2023-04-08 20:53:05 -07:00
Cy Schubert 4a99b85472 wpa_supplicant/hostapd: Fix uninitialized packet pointer on error
The packet pointer (called packet) will remain uninitialized when
pcap_next_ex() returns an error. This occurs when the wlan
interface is shut down using ifconfig destroy. Adding a NULL
assignment to packet duplicates what pcap_next() does.

The reason we use pcap_next_ex() in this instance is because with
pacp_next() when we receive a null pointer if there was an error
or if no packets were read. With pcap_next_ex() we can differentiate
between an error and legitimately no packets were received.

PR:		270649
Reported by:	Robert Morris <[email protected]>
Fixes:		6e5d01124f

(cherry picked from commit 953efa5b20)
2023-04-08 20:52:35 -07:00
Gordon Bergling 589b826624 devd.conf.5: Fix a typo in the manual page
- s/deteted/detected/

(cherry picked from commit 328ebd4680)
2023-03-31 09:50:11 +02:00
Gordon Bergling 95d0723eb3 rarpd(8): Fix a typo in a source code comment
- s/combinataion/combination/

Obtained from:	NetBSD

(cherry picked from commit 107597fbd4)
2023-03-30 08:31:10 +02:00
Kristof Provost 8d636e4d69 pf: remove pd_refs from pfsync
It only served to complicate cleanup, and added no value.

While here drop packets in pfsync_defer_tmo() if we don't have a syncif,
rather than just leaving them on the queue.

Reviewed by:	markj
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D39248

(cherry picked from commit 27b23cdec9)
2023-03-30 02:23:31 +02:00
Kristof Provost 5f74ed9afd pfsync: hold b_mtx for callout_stop(pd_tmo)
The pd_tmo callout has an associated mutex, which we must hold while
calling callout_stop().

Reported by:	markj
Reviewed by:	markj
MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D39223

(cherry picked from commit 01194da28a)
2023-03-30 02:23:09 +02:00
Philip Paeps 7da23e6521 contrib/tzdata: import tzdata 2023c
Changes: https://github.com/eggert/tz/blob/2023c/NEWS

The tzdata 2023c release reverts all changes made in 2023b other than
commentary, as that appears to be the best of a bad set of short-notice
choices for modeling this week's daylight saving chaos in Lebanon.

(cherry picked from commit 9fbeeb6e38)
2023-03-29 09:20:06 +08:00
Glen Barber d16d0db010 pkg-stage.sh: update port trailing version information
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit e4e139b828)
2023-03-27 10:14:20 -04:00
Alan Somers 81b340dd5b Replace subversion with git in the installation DVD
(cherry picked from commit 55c8093f73)
(cherry picked from commit 46856dbac6)
2023-03-27 10:14:06 -04:00
Kristof Provost 6b916bc91d pf tests: try to trigger locking issues in pfsync_timeout()
PR:		268246
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC (Netgate)

(cherry picked from commit a6719858a4)
2023-03-27 02:29:59 +02:00
Kristof Provost 1d6ece4351 pfsync: add missing unlock in pfsync_defer_tmo()
The callout for pfsync_defer_tmo() is created with
CALLOUT_RETURNUNLOCKED, because while the callout framework takes care
of taking the lock we want to run a few operations outside of the lock,
so we unlock ourselves.

However, if `sc->sc_sync_if == NULL` we return without releasing the
lock, and leak the lock, causing later deadlocks.
Ensure we always release the bucket lock when we exit pfsync_defer_tmo()

PR:		268246
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC (Netgate)

(cherry picked from commit 844ad2828a)
2023-03-27 02:28:37 +02:00
Kristof Provost 09b7cab88f pfsync: fix pfsync_undefer_state() locking
pfsync_undefer_state() takes the bucket lock, but could get called from
places (e.g. from pfsync_update_state() or pfsync_delete_state()) where
we already held the lock.

As it can also be called from places where we don't yet hold the lock
create new locked variant for use when the lock is already held. Keep
using pfsync_undefer_state() where the lock must still be taken.

PR:		268246
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC (Netgate)

(cherry picked from commit 53247cdf12)
2023-03-27 02:28:32 +02:00
Philip Paeps f0cea48cb7 contrib/tzdata: import tzdata 2023b
Changes: https://github.com/eggert/tz/blob/2023b/NEWS

(cherry picked from commit 2084f6a496)
2023-03-25 19:30:40 +08:00
Xin LI e68521de19 cap_*(2): Document ENOSYS behavior.
Summary:
All cap_* system calls would fail when capability mode support is
not present.

Reviewed by:	emaste, pauamma
Differential Revision: https://reviews.freebsd.org/D38976

(cherry picked from commit 75798f9b01)
2023-03-23 23:40:31 -07:00
Philip Paeps 9845906f02 contrib/tzdata: import tzdata 2023a
Changes: https://github.com/eggert/tz/blob/2023a/NEWS

(cherry picked from commit 259e2ad76d)
2023-03-24 09:16:03 +08:00
Ed Maste 81338b4213 ldd: clarify format options
-f may be specified zero, one, or two times.  Make this clear in the
usage.

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

(cherry picked from commit e9f8723c30)
(cherry picked from commit 7bc6ce41d8)
2023-03-23 08:49:44 -04:00
Ed Maste 12be1c744e gvinum: correct assertions
Pointer addresses are always >= 0.  Assert that the value is >= 0
instead.

PR:		207855, 207856
Reviewed by:	imp
Reported by:	David Binderman
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37677

(cherry picked from commit 87bb53cb53)
(cherry picked from commit 66f3ac8c66)
2023-03-23 08:49:43 -04:00
Ed Maste c68dc69680 lorder: add deprecation notice
lorder has not been used by the base system since 0e1e341b48 and
hasn't really been necessary for a very long time.

PR:		259254 [exp-run]
Reviewed by:	arichardson (earlier)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D30080

(cherry picked from commit 68a930d8ee)
(cherry picked from commit e26552c0d8)
2023-03-23 08:49:43 -04:00
Ed Maste dc3d0ff615 etdump: exit on error if section header or entry offset is OOB
PR:		263663
Reported by:	Robert Morris <[email protected]>
Reviewed by:	markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35868

(cherry picked from commit ddf77ec392)
2023-03-23 08:49:43 -04:00
Ed Maste 8ebda77aa1 mergemaster: add deprecation notice to man page
PR:		252417
Reviewed by:	bapt, gjb, kevans (all earlier)
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23327

(cherry picked from commit 398b12691b)
(cherry picked from commit ab53efd142)
2023-03-23 08:49:43 -04:00
John Baldwin 2daa63d80d mips: Add device random to two kernel configs.
Otherwise these kernels fail to link.  This is a direct commit to
stable/12 as device random isn't optional in 13.0 and later.
2023-03-22 21:17:03 -07:00
Hans Petter Selasky bde7b32c7c ibcore: Clean up INIT_UDATA() and INIT_UDATA_BUF_OR_NULL() macro usage.
We get a harmless warning about the fact that we use the result of a
multiplication as a condition in INIT_UDATA_BUF_OR_NULL():

uverbs_main.c: In function 'ib_uverbs_write':
error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]

This avoids the problem by using an inline function in place of
the macro.

After changing INIT_UDATA_BUF_OR_NULL() to an inline function,
do the same change to INIT_UDATA() for consistency.

Using an inline function gives us better type safety here among other
issues with macros. I'm using u64_to_user_ptr() to convert the user
pointer to simplify the logic rather than adding lots of new type casts.

Linux commit:
12f727721eee61b3d19dedb95cb893b2baa9fe41
40a203396cc1c239f2e71c47c66ed03097123d2c

MFC after:	1 week
Reviewed by:	kib
Sponsored by:	Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 05f4691919)
2023-03-22 15:27:19 -07:00
Ryan Libby 8f88432a1d ofed: quiet gcc -Wint-in-bool-context
The int in the argument to the ternary triggered -Wint-in-bool-context
from gcc.  Upstream linux has a larger and more entangled patch,
12f727721eee61b3d19dedb95cb893b2baa9fe41, which doesn't apply cleanly.
When we eventually sync that, we can just drop this change.

Reviewed by:	hselasky, imp, kib
MFC after:	3 days
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D28762

(cherry picked from commit bf667f282a)
2023-03-22 15:27:09 -07:00
Warner Losh f59113f9f6 smartpqi: Remove stray declaration
pqisrc_is_firmware_feature_enabled shouldn't be declared inline in a
header, and then static inline in the .c function. Remove this stray
declartion from the header. gcc6 complains, but clang does not.

Sponsored by:		Netflix

(cherry picked from commit eae2ef5a01)
2023-03-22 15:22:53 -07:00
John Baldwin 9d8607fa3f kernel: Disable errors for -Walloca-larger-than for GCC.
GCC complains about the use of alloca() with variable sizes (for XSAVE
state len) in sendsig() for i386.  Modern XSAVE state is probably
getting a bit large for the i386 kstack, but downgrade the error to a
warning.

Reviewed by:	kib, emaste
Differential Revision:	https://reviews.freebsd.org/D31934

(cherry picked from commit e72c7e2738)
2023-03-22 15:21:30 -07:00
Ryan Libby 2c91d5899a gcc9: quiet Waddress-of-packed-member for kernel build
This is lame, but it's what we already do for the clang build.  We take
misaligned pointers into network header structures in many places.

Reviewed by:	ian
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D22876

(cherry picked from commit 77acc3cfbc)
2023-03-22 15:21:11 -07:00
John Baldwin 429d956586 Stop adding -Wredundant-decls to CWARNFLAGS.
clang doesn't implement it, and Linux doesn't enforce it.  As a
result, new instances keep cropping up both in FreeBSD's code and in
upstream sources from vendors.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D34144

(cherry picked from commit c227269e2f)
2023-03-22 12:28:59 -07:00
John Baldwin d86f0502b1 Turn off errors for -Wmaybe-uninitialized in GCC 6+.
Recent changes to <sys/tree.h> trigger this warning and seem like a
false positive.

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

(cherry picked from commit a02fb76280)
2023-03-22 12:23:37 -07:00
Ryan Libby fd153a0a4c rtld-elf: link libcompiler_rt on all architectures
Statically link rtld-elf with libcompiler_rt on all architectures so
that we don't need to try to pick and choose the bits we need from it
for each architecture (we now leave that to the linker).  Compilers may
emit calls to support functions in this library, but because of the use
of the linker flag -nostdlib for rtld's special needs, the library is
not linked as normal.

Previously we had two different solutions.  On some architectures, we
were able to extract reimplementations of the necessary builtin
functions from our special build of libc.  On ARM, we just linked
libcompiler_rt.

This is motivated by the same issue as D26199 and D27665, but should be
a simpler solution that will apply to all architectures.

Reviewed by:	arichardson, kib
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D27736

(cherry picked from commit 63f93c7e11)
2023-03-22 12:22:25 -07:00
Li-Wen Hsu b43c3200a4 Properly fix GCC build in r357867
Submitted by:	kib
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c27ac74f9c)
2023-03-22 12:22:25 -07:00
Li-Wen Hsu 5bb9086254 Fix GCC build.
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 338450436d)
2023-03-22 12:22:25 -07:00
John Baldwin 51666ee966 Disable -Wreturn-type on GCC.
GCC is more pedantic than clang about warning when a function doesn't
handle undefined enum values (see GCC bug 87950).  Clang's warning
gives a more pragmatic coverage and should find any real bugs, so
disable the warning for GCC rather than adding __unreachable
annotations to appease GCC.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D34147

(cherry picked from commit 2f6a842484)
2023-03-22 12:22:23 -07:00
John Baldwin 11ab827a1c top: Remove a duplicate extern declaration for show_args.
This fixes a -Wnested-extern error with GCC 9.  There is an existing
extern declaration in top.h.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D31937

(cherry picked from commit 4c9cb057bd)
2023-03-22 11:47:15 -07:00
John Baldwin 8e7ba6eb44 stand/efi: Pass --no-dynamic-linker to ld.bfd >= 2.34.
ld.bfd in binutils 2.34+ now reports an error in more cases for custom
ldscripts that do not place PHDRs in a LOAD segment.  However, EFI
binaries are not dynamic binaries which need PHDRs, so pass
--no-dynamic-linker to disable this check.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D34124

(cherry picked from commit 8bd5e2f15c)
2023-03-22 11:23:00 -07:00
John Baldwin fbe7e06a3c libsa: Add missing GNU-stack annotations to _setjmp.S.
ld.bfd marks the stack as executable for the crt objects due to the
missing annotations which raises a fatal warning starting with version
2.39.

(cherry picked from commit 69f6399c37)
2023-03-22 11:16:20 -07:00
Ryan Libby df3d0c0d0d Declare packed struct ata_params as 2-byte-aligned
This avoids gcc9 warning about unaligned access to the structure when
casting to uint16_t pointer type.

Submitted by:	imp
Reviewed by:	imp
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D22888

(cherry picked from commit 36947e1f4d)
2023-03-22 08:12:16 -07:00
John Baldwin bc74e50cdf Revert "df: remove the unused fstype var"
This reverts commit 647f70e6bf.

fstype is used in a call to build_iovec_argf() in this branch, and the
reverted commit didn't remove the variable, just its initialization.

This is a direct commit to stable/12.

Reported by:	GCC -Wmaybe-uninitialized
2023-03-21 19:55:00 -07:00
Ryan Libby 0ae8e682d8 dtrace: avoid gcc9 Walloca-larger-than
gcc9 grew a new warning for unbounded allocas, such as the one in
dt_options_load.  Remove both uses of alloca in dt_options.c.

Reviewed by:	markj
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D22880

(cherry picked from commit fa19b250bd)
2023-03-21 19:18:22 -07:00
John Baldwin e0f29006d1 libcrypto padlock.so: Link with -z noexecstack for ld.bfd.
The assembly source files do not contain GNU-stack annotations, so
ld.bfd defaults to using an executable stack.

(cherry picked from commit 99df55bbb7)
2023-03-21 17:11:15 -07:00
Konstantin Belousov d53f977d52 amd64 libc: add missed GNU-stack annotation to memmove/memcpy
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week

(cherry picked from commit ae507c25de)
2023-03-21 17:03:08 -07:00
Ryan Libby 13ecd510de jemalloc: pick from upstream: Fix GCC-9.1 warning with macro GET_ARG_NUMERIC
Pick 2d6d099fed05b1509e81e54458516528bfbbf38d from upstream jemalloc:

    Fix GCC-9.1 warning with macro GET_ARG_NUMERIC

    GCC-9.1 reports following error when trying to compile file
    src/malloc_io.c and with CFLAGS='-Werror' :

    src/malloc_io.c: In function ‘malloc_vsnprintf’:
    src/malloc_io.c:369:2: error: case label value exceeds maximum value for type [-Werror]
      369 |  case '?' | 0x80:      \
          |  ^~~~
    src/malloc_io.c:581:5: note: in expansion of macro ‘GET_ARG_NUMERIC’
      581 |     GET_ARG_NUMERIC(val, 'p');
          |     ^~~~~~~~~~~~~~~
    ...
    <snip>
    cc1: all warnings being treated as errors
    make: *** [Makefile:388: src/malloc_io.sym.o] Error 1

    The warning is reported as by default the type 'char' is 'signed char'
    and or-ing 0x80 will turn the case label char negative which will be
    beyond the printable ascii range (0 - 127).

    The patch fixes this by explicitly casting the 'len' variable as
    unsigned char' inside the 'switch' statement so that value of
    expression " '?' | 0x80 " falls within the legal values of the
    variable 'len'.

Discussed with:	jasone (maintainer)
Sponsored by:	Dell EMC Isilon

(cherry picked from commit 79457a8ad1)
2023-03-21 17:00:51 -07:00
Gordon Bergling 7812b9ef0d smbfs.5: Us .An -nosplit for the AUTHORS section
Use .An -nosplit for the AUTHORS section, so that
it renders without an unnecessary newline.

No .Dd bump since it isn't a content change.

(cherry picked from commit ac6bc808f5)
2023-03-21 07:08:54 +01:00
Kristof Provost 4b77c46dc2 pf tests: test IPv6 fragmentation with link-local addresses
We've observed a panic after pf_refragment6() with link-local addresses,
because pf_refragment6() calls ip6_forward() even for a simple output
case.
That results in us entering ip6_forward() with an mbuf with a NULL
m->m_pkthdr.rcvif, which can cause a NULL deref (but seemingly not for
GUAs.

Test sending fragmented link-local packets to pf.

MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D39063

(cherry picked from commit 225e85513f)
2023-03-20 10:41:37 +01:00
Cy Schubert 7cca504c7a sqlite3: Vendor import of sqlite3 3.41.0
Release notes at https://www.sqlite.org/releaselog/3_41_0.html.

Obtained from:  https://www.sqlite.org/2023/sqlite-autoconf-3410000.tar.gz
MFC after:	2 weeks

Merge commit '615bd3eb2a2225e83e14d5b2a82649430889483c' into temp_merge

(cherry picked from commit 7bba9d9473)
2023-03-13 19:59:34 -07:00
Cy Schubert c4c0bd4d01 heimdal: Fix CVE-2022-4152, signature validation error
When CVE-2022-3437 was fixed by changing memcmp to be a constant
time and the workaround for th e compiler was to add "!=0". However
the logic implmented was inverted resulting in CVE-2022-4152.

Reported by:	Timothy E Zingelman <zingelman _AT_ fnal.gov>
Security:	CVE-2022-4152
Security:	https://www.cve.org/CVERecord?id=CVE-2022-45142
Security:	https://nvd.nist.gov/vuln/detail/CVE-2022-45142
Security:	https://security-tracker.debian.org/tracker/CVE-2022-45142
Security:	https://bugs.gentoo.org/show_bug.cgi?id=CVE-2022-45142
Security:	https://bugzilla.samba.org/show_bug.cgi?id=15296
Security:	https://www.openwall.com/lists/oss-security/2023/02/08/1

(cherry picked from commit 5abaf08664)
2023-03-09 20:07:43 -08:00
Cy Schubert 4e16ea3de7 usb: Add HID_IGNORE quirk for APC Smart-UPS1000
Without the HID_IGNORE quirk enabled it will appear to be a uhid device.

PR:		269729

(cherry picked from commit 8866ea619a)
2023-03-08 06:32:17 -08:00
Cy Schubert 9a5406cabc usbdevs: Add APC Smart-UPS1000
(cherry picked from commit 6f295aab80)
2023-03-08 06:32:03 -08:00
Cy Schubert bf04aa1701 usbdevs: Remove duplicate APC entries
(cherry picked from commit b1723f48d8)
2023-03-08 06:31:49 -08:00
Xin LI 2e12642a65 xz: Improve compatibility with systems without capability mode support
When the kernel is built without capability mode support, or when
using an emulator like qemu-user-static that does not translate
system calls, these calls will return a negative number and set
the errno to ENOSYS. However, this error does not indicate a
real programming or runtime error and is generally ignored by
base system applications built with capability mode sandboxing.

Match this behavior by making xz(1) to ignore ENOSYS errors
when calling capability mode system calls too.

PR:		269185
Reported by:	Dan Kotowski

(cherry picked from commit c237c10a23)
2023-03-06 22:56:18 -08:00
Brooks Davis 08325b2df4 ng_atmllc: deprecate
With the deprecation of NgATM, ng_atmllc is the last vestage of ATM
support so deprecate it too.

MFC after:	3 days
Relnotes:	yes

Reviewed by:	manu, emaste
Differential Revision:	https://reviews.freebsd.org/D38878

(cherry picked from commit c2285a7b09)
2023-03-06 18:57:31 +00:00
Brooks Davis a338a96efa NgATM: deprecate
Support for ATM NICs was removed prior to FreeBSD 12.  At the time it
was unclear if this code was still useful without it.  Now the time has
come to finish removing support.

Add DREPRECATION NOTICEs to the manpages and gone_in(14, ...) warnings
in the constructors (or module init for ngatmbase).

MFC after:	3 days
Relnotes:	yes

Reviewed by:	manu, emaste
Differential Revision:	https://reviews.freebsd.org/D38877

(cherry picked from commit 211c302f10)
2023-03-06 18:57:30 +00:00
Brooks Davis 7adbe9f763 NgATM: Remove useless NGATM_ATM option
MFC after:	3 days

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D38875

(cherry picked from commit bd32aedeee)
2023-03-06 18:57:30 +00:00
Brooks Davis 45fca9a779 NATM: Remove useless NETGRAPH_ATM_ATMPIF option
This code was removed as part of the NATM removal in 2017 and somehow
this option was missed.

MFC after:	3 days

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D38874

(cherry picked from commit 3746e90118)
2023-03-06 18:57:30 +00:00
Brooks Davis 8b12944886 netgraph.4: remove obsolete ng_atm.4 reference
MFC After:	3 days

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D38876

(cherry picked from commit 3518a5bbd9)
2023-03-06 18:57:29 +00:00
Richard Scheffenegger 9b3d612771 tcp: Make TCP PCAP buffer properly configurable.
Reviewed By:		tuexen, cc, #transport
MFC after:		3 days
Sponsored by:		NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D38824

(cherry picked from commit 399a5655e6)
2023-03-02 03:30:07 +01:00
Dmitry Chagin 3c4af6fe95 linprocfs(4): Fixup process size in the /proc/pid/stat file
According to the Linux sources the kernel exposes a proces virtual
memory size via proc filesystem into the three files - stat, status
and statm. This is the struct mm->total_vm value adjusted to the
corresponding units - bytes, kilobytes and pages.

The fix is based on a fernape@ analysis.

PR:		265937
Reported by:	Ray Bellis
MFC after:	3 days

(cherry picked from commit a55b5a9aed)
2023-03-02 21:59:19 +03:00
Colin Percival 7e8aaae6b8 Bump EC2 image size to 5 GB
The latest weekly snapshots failed to install mandatory packages due
to the snapshot disk running out of space.

Direct commit to stable/12.
2023-03-02 09:50:22 -08:00
Kristof Provost 7e2de012f3 pfsync: ensure 'error' is always initialised
Reported by:	Herbert J. Skuhra <[email protected]>
MFC after:	2 weeks

(cherry picked from commit f52ca3dfd5)
2023-03-02 12:15:28 +01:00
Kristof Provost dacffdd4dc pfsync: support deferring IPv6 packets
When we send out a deferred packet we must make sure to call
ip6_output() for IPv6 packets. If not we might end up attempting to
ip_fragment() an IPv6 packet, which could lead to us reading outside of
the mbuf.

PR:		268246
Reviewed by:	melifaro, zlei
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D38586

(cherry picked from commit 9a1cab6d79)
2023-03-02 12:15:28 +01:00
Zhenlei Huang 78c22dde83 vnet: Make vnet_sys[un]init() static
These two functions are intended to be used only when allocating or
destroying vnet instances.

No functional change intended.

Reviewed by:	kp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D37955

(cherry picked from commit fb9b76e052)
(cherry picked from commit 7b6d9cae97)
2023-02-28 10:02:17 +08:00
Cy Schubert 4cafd65c8f ping: Fix unsigned integer underflow resuling in a ping -R segfault
ping -R (F_RROUTE) will loop at ping.c:1381 until it segfaults or
the unsigned int hlen happens to be less than the size of an IP header:

slippy$ ping -R 192.168.0.101
PING 192.168.0.101 (192.168.0.101): 56 data bytes
64 bytes from 192.168.0.101: icmp_seq=0 ttl=63 time=1.081 ms
RR: 	192.168.0.1
	192.168.0.101
	192.168.0.101
	10.1.1.254
	10.1.1.91
unknown option bb
unknown option 32
unknown option 6
...
unknown option 96
unknown option 2d
Segmentation fault

The reason for this is while looping through loose source routing (LSRR)
and strict source routing (SSRR), hlen will become smaller than the IP
header. It may even become negative. This should terminate the loop.
However, when hlen is unsigned, an integer underflow occurs becoming a
large number causing the loop to continue virtually forever until hlen
is either by chance smaller than the lenghth of an IP header or it
segfaults.

Reviewed by:	asomers
Fixes:		46d7b45a26
Differential Revision:	https://reviews.freebsd.org/D38744

(cherry picked from commit 70960bb86a)
2023-02-26 20:32:59 -08:00
Zhenlei Huang 2bd7bd0bbe ctf: Remove unused function prototype for getpname()
This function prototype should have been removed along with the
implementation.

Fixes:		3dd5524264 ctfdump: Use getprogname()
MFC after:	1 day

(cherry picked from commit f8e1aa85fe)
(cherry picked from commit eba26d0ba3)
2023-02-27 11:15:00 +08:00
Joerg Wunsch 2178d68a54 MFC: ARM release build: enable IPv6 SLAAC by default
When building ARM release images, enable IPv6 SLAAC by default in
addition to IPv4 DHCP.

Unlike amd64 (and other desktop/server) releases, ARM releases on SoC
setups are usually deployed by just using the installation image, so
there is no interactive network configuration. Not having IPv6
included by default is kind of an anachronism these days, given that
FreeBSD with the KAME project once pioneered IPv6 technology.

(cherry picked from commit 57228a4933)
2023-02-26 23:24:17 +01:00
Mark Johnston fcacb96b34 ctfdump: Remove definitions of warn() and vwarn()
The presence of the latter causes a link error when building a
statically linked ctfdump(1) because libc defines the same symbol.
libc's warn() is defined as a weak symbol and so does not cause the same
problem, but let's just use libc's version.

Reported by:	stephane rochoy <[email protected]>
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 45dd2eaac3)
(cherry picked from commit 5def1805d1)
2023-02-26 13:26:17 +08:00
Zhenlei Huang 9620038522 ctfdump: Use getprogname()
Also remove no longer used function `getpname()`.

Reviewed by:	markj
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D38740

(cherry picked from commit 3dd5524264)
(cherry picked from commit 994eb2fb8a)
2023-02-26 09:55:23 +08:00
Xin LI fc9f471543 MFV: zlib 1.2.13.
Relnotes:	yes

(cherry picked from commit e37bb444aa)
2023-02-22 21:06:09 -08:00
Kevin Bowling e7de5b89b7 e1000: Fix packet loss on 11th gen and later
Ungate DMA clock on TGP and later to avoid packet loss.

A similar fix appears in Linux 639e298f432fb058a9496ea16863f53b1ce935fe

This may be needed as far back as SPT but no confirmation from intel or
other OS yet.

Obtained from:	OpenBSD (if_em_hw.c 1.116)
Sponsored by:	BBOX.io

(cherry picked from commit 5636590214)
2023-02-22 17:29:58 -07:00
Kevin Bowling 0aacd70843 e1000: Add support for future client platforms
Sponsored by:	BBOX.io

(cherry picked from commit 905ae5881b)
2023-02-22 17:28:49 -07:00
Kevin Bowling 15d2f480b6 e1000: Remove redundant disable_ulp for ich8lan
This call only makes sense for ich8lan, and the shared code does it in
e1000_setup_init_funcs() above this deletion.

Obtained from:	DPDK
Sponsored by:	BBOX.io
Pull Request:	https://github.com/freebsd/freebsd-src/pull/539

(cherry picked from commit d36fbdb08f)
2023-02-22 17:23:46 -07:00
Kevin Bowling 1fb11c84ca e1000: bump driver version
Incrementing these to avoid confusion in users; we are on par with these
out of tree versions.

Reviewed by:	erj
Sponsored by:	BBOX.io
Pull Request:	https://github.com/freebsd/freebsd-src/pull/540

(cherry picked from commit 647f2d2bc0)
2023-02-21 17:51:20 -07:00
Kevin Bowling e646dced59 e1000: fix I219 hang on reset
Clear the rings before reset to avoid a HW hang.

Inspired by em-7.7.8 and DPDK (1fc9701238edcf0541289b9ae15565b6d9d7ab30)

Reviewed by:	erj
Sponsored by:	BBOX.io
Pull Request:	https://github.com/freebsd/freebsd-src/pull/540

(cherry picked from commit ae1dca798e)
2023-02-21 17:49:29 -07:00
Xin LI 04b24c1069 cleanvar: Be more careful when cleaning up /var.
The cleanvar script uses find -delete to remove stale files under /var,
which could lead to unwanted removal of files in some unusual scenarios.
For example, when a mounted fdescfs(5) is present under /var/run/samba/fd,
find(1) could descend into a directory that is out of /var/run and remove
files that should not be removed.

To mitigate this, modify the script to use find -x, which restricts the
find scope to one file system only instead of descending into mounted
file systems.

PR:		269213

(cherry picked from commit 39e8c2a29a)
2023-02-19 23:18:06 -08:00
Zhenlei Huang 7d1f66652f usb: Remove unused member in struct mos_softc
Spotted by jhibbits in D37812.

Reviewed by:	#network, glebius
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D38581

(cherry picked from commit 3bafe73aff)
(cherry picked from commit 1ab8695033)
2023-02-18 14:07:48 +08:00
Kristof Provost bde407764a pf tests: improve pfsync:basic_defer test
Create state on output only, to ensure we trigger the defer code.

MFC after:	2 weeks

(cherry picked from commit afa77b6996)
2023-02-17 05:46:29 +01:00
Kristof Provost f56a39b5f1 pfsync: add missing bucket lock
pfsync_q_ins() expects us to hold the bucket lock, but when we enter it
from pfsync_state_import() we don't.

MFC after:	2 weeks

(cherry picked from commit 0ed5f66c5a)
2023-02-17 05:46:08 +01:00
Elliott Mitchell 82fd8caf6c Add ck.h userspace shims for CK_SLIST_
Differential Revision:	https://reviews.freebsd.org/D38471

(cherry picked from commit cd3193f640)
2023-02-16 03:54:52 -07:00
Kyle Evans 6431b5ab6b top: fix sorting by pid (-o pid)
The 'pid' order was added, but the equivalent comparator was not back in
8b800d3af2 ("Add the PID column to the list of sort keys.").
`ordernames` indices need to match `compares` indices in order for this
to work.

A future commit will restructure all of this to make it less error prone
going forward (see D37083).

MFC after:	3 days
Reviewed by:	pstef (D37083)

(cherry picked from commit deb63adf94)
2023-02-15 22:57:54 -06:00
Kyle Evans a80643d2a9 md5: fix *sum -c with missing files
If we fail to open one of the files in the file listing, we still need
to advance `rec` along with `argv` so that the checksum we're checking
against lines up with the file we're hashing.

Tests added both for the -c flag, as well as the -b and -t modes of
the *sum programs.

PR:		267722
Reviewed by:	emaste (earlier version)

(cherry picked from commit 8d78a0d331)
2023-02-15 22:57:49 -06:00
Juraj Lutter 98dce7bf87 unbound: Fix config file path
Commit 1838dec318 changed the
config file path to /usr/local/etc/unbound/unbound.conf which
is wrong for unbound in base.

Reported by:	Ihor Antonov <ihor_AT_antonovs_family>
Reviewed by:	zlei
Approved by:	zlei
Differential Revision: https://reviews.freebsd.org/D38106

Fixes:          1838dec318

(cherry picked from commit 1d577bedba)
2023-02-14 10:34:39 -08:00
Cy Schubert 389750e5fc unbound: Fix config.h
FreeBSD src does not support HAVE_DECL_EVSIGNAL_ASSIGN. While reviewing
the new config.h after regenerating it, this definition was not removed.

Updating config.h is a manual process of configuring the port and
copying/merging the generated config.h into src. This definition was
missed and not removed (#undef'd).

Fixes:		1838dec318

(cherry picked from commit 06b93ef8cd)
2023-02-14 10:34:39 -08:00
Cy Schubert 7c8cb91e00 unbound: Vendor import 1.17.1
Release notes at
    https://www.nlnetlabs.nl/news/2023/Jan/12/unbound-1.17.1-released/.

Merge commit '7699e1386a16236002b26107ffd2dcbde375e197' into main

(cherry picked from commit 1838dec318)
2023-02-14 10:34:39 -08:00
Cy Schubert 8d5dfe721e heimdal: Resolve hdb_free_entry() SIGSEGV/SIGILL
When the client sends kadmind a create principal (kadm_create) request
kadm_s_create_principal() returns an error before zeroing out ent (an
hdb entry structure wrapper -- hdb_entry_ex), resulting in a NULL
reference.

Fix obtained from upstream commit 35ea4955a.

PR:		268059
Reported by:	Robert Morris <[email protected]>
Obtained from:	Heimdal commit 35ea4955a

(cherry picked from commit 6a70e0b4cd)
2023-02-14 10:34:27 -08:00
Tijl Coosemans f73d4bfc13 local-unbound-setup: Use default root certificates
Don't force /etc/ssl/cert.pem.  It does not exist by default, only if
security/ca_root_nss is installed.  Just use the default OpenSSL search
locations which are /etc/ssl/cert.pem and /etc/ssl/certs/.

The tls-system-cert option was added in Unbound 1.16.0.

Reviewed by:	zlei
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D38243

(cherry picked from commit 8932f7ce17)
2023-02-13 12:40:50 +01:00
Ed Maste d795444930 ssh: fix SIZEOF_TIME_T #define on i386
Reported by:	imp
Reviewed by:	imp
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D38443

(cherry picked from commit 1aa9a35f63)
(cherry picked from commit 59ab4b9512)
2023-02-12 20:20:24 -05:00
John Grafton ffb598d095 rescue: Add fetch(1) to the rescue tool.
After a failed upgrade, having fetch(1) on a system that is
physically unnreachable would be very useful to download files
required to get the OS back up and functional.

On my system this adds 589,824 bytes (3.8%) to the binary size.

PR:		266224
Reported by:	Dan Mahoney
Differential Revision:	https://reviews.freebsd.org/D38193

(cherry picked from commit ea34aa4780)

rescue: Fix link order of SSL libraries and fetch.

ld.bfd requires libraries to be linked in order.  libssl requires
libcrypto.  libfetch requires libssl.  To fix the latter, move fetch
up above tar rather than listing the ssl libraries twice.

Reviewed by:	delphij
Fixes:		ea34aa4780 rescue: Add fetch(1) to the rescue tool.
Differential Revision:	https://reviews.freebsd.org/D38304

(cherry picked from commit 0f031350f3)
2023-02-11 23:58:55 -08:00
Sebastian Huber 316cf82382 sha512_224: Fix SHA512_224_Final() on little-endian machines.
PR:		266863
MFC after:	1 week
Reviewed by:	allanjude, cperciva, des
Differential Revision:	https://reviews.freebsd.org/D38372

(cherry picked from commit 6680cfe8e0)
2023-02-10 01:20:11 +01:00
Cy Schubert 351f2f6885 ipfilter: Fix use after free on packet with broken lengths
Under the scenario with a packet with length of 67 bytes, a header length
using the default of 20 bytes and a TCP data offset (th_off) of 48 will
cause m_pullup() to fail to make sure bytes are arragned contiguously.
m_pullup() will free the mbuf chain and return a null. ipfilter stores
the resultant mbuf address (or the resulting NULL) in its fr_info_t
structure. Unfortuntely the eroneous packet is not flagged for drop.
This results in a kernel page fault at line 410 of sys/netinet/ip_fastfwd.c
as it tries to use a now previously freed, by m_pullup(), mbuf.

PR:		266442
Reported by:	Robert Morris <[email protected]>

(cherry picked from commit 79f7745c09)
2023-02-09 13:20:51 -08:00
Cy Schubert 272b2e191e ipfilter: Correctly type ipf_pullup()
ipf_pullup() outputs a pointer to ip_t. Though returning a pointer to
void does work, it is imprecise and not completely correct.

(cherry picked from commit c941e8c65d)
2023-02-09 13:20:50 -08:00
Cy Schubert f26d90ba8b sqlite3: Vendor import of sqlite3 3.40.1
Release notes at https://www.sqlite.org/releaselog/3_40_1.html.

Obtained from:  https://www.sqlite.org/2022/sqlite-autoconf-3400100.tar.gz

Merge commit 'c728c97f5c838c9a873516c4499e4e1a41788ce7' into main

(cherry picked from commit 5ae830e9ba)
2023-02-09 13:20:50 -08:00
Ed Maste 6cf3164ff3 ssh: Be more paranoid with host/domain names coming from the
never write a name with bad characters to a known_hosts file.

replace recently-added valid_domain() check for hostnames going to
known_hosts with a more relaxed check for bad characters.

Obtained from:	OpenSSH-portable commit 445363433ba2
Obtained from:	OpenSSH-portable commit 3cae9f92a318
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 2e82822057)
(cherry picked from commit 6ad91c17b0)
2023-02-08 16:06:23 -05:00
Ed Maste d07cfacb67 ssh: fix bug in PermitRemoteOpen which caused it to ignore...
its first argument unless it was one of the special keywords "any" or
"none".

Obtained from:	OpenSSH-portable commit b3daa8dc5823
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 94e21add45)
(cherry picked from commit 375bb3704d)
2023-02-08 16:06:22 -05:00
Ed Maste 2caac96a66 ssh: fix double-free caused by compat_kex_proposal()
Security:	CVE-2023-25136
Obtained from:	OpenSSH-portable commit 12da78233364
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit fe1371e8f3)
(cherry picked from commit 296ec8eae0)
2023-02-08 16:06:22 -05:00
Mariusz Zaborski a5afaf4e9a geli: split the initalization of HMAC
GELI allows to read a user key from a standard input.
However if user initialize multiple providers at once, the standard
input will be empty for the second and next providers.
This caused GELI to encrypt a master key with an empty key file.

This commits initialize the HMAC with the key file, and then reuse the
finalized structure to generate different encryption keys for different
providers.

Reported by:	Nathan Dorfman
Tested by:	philip
Security:	FreeBSD-SA-23:01.geli
Security:	CVE-2023-0751

(cherry picked from commit 5fff09660e)
2023-02-08 10:04:14 -08:00
Jung-uk Kim 5983b92a92 OpenSSL: Regen manual pages for OpenSSL 1.1.1t 2023-02-07 18:07:12 -05:00
Jung-uk Kim 746c5cd56b OpenSSL: Regen assembly files for OpenSSL 1.1.1t
(cherry picked from commit f1cf49002d)
2023-02-07 18:04:45 -05:00
Jung-uk Kim 1bf57e058b OpenSSL: Merge OpenSSL 1.1.1t
(cherry picked from commit fb31345581)
2023-02-07 18:04:28 -05:00
Jung-uk Kim f86f992d43 OpenSSL: Merge OpenSSL 1.1.1t
(cherry picked from commit 0d51f65851)
2023-02-07 18:03:38 -05:00
Przemyslaw Lewandowski c907f13af0 iflib: Add null check to iflib_stop()
Ever since gtaskqueue_drain() was added to iflib_stop(), a kernel panic
occurs when the ice(4) driver is in recovery mode. Queues are not
initialized in this mode, so gt_taskqueue is not initialized, and
gtaskqueue_drain() will panic.

Fix this by only doing a drain if an RX queue's gt_taskqueue is
initialized.

Signed-off-by: Eric Joyner <[email protected]>

Reviewed by:	erj@
MFC after:	1 week
Sponsored by:	Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D37892

(cherry picked from commit 9147969bc2)
2023-02-06 16:24:10 -08:00
Eric Joyner b4e0be6df7 vtd: Increase DRHD_MAX_UNITS
Observed on a couple Ice Lake-SP platforms (Intel Coyote Pass, Dell
R750), there are more than 8 DRHD sections enumerated in the DMAR ACPI
section.  Since the previous limit was 8, this resulted in some of these
not being parsed by vtd when the iommu is initialized; in this case when
PCI devices are being passthru'd to a bhyve VM.

This omission later causes a kernel panic later in initialization when
devices could not be found in a valid DRHD scope because the DHRD
containing the device's scope was not added to vtd.

Signed-off-by: Eric Joyner <[email protected]>

PR:		268486
Sponsored by:	Intel Corporation
Reviewed by:	rew@, corvink@
Differential Revision:	https://reviews.freebsd.org/D38285

(cherry picked from commit 5354596764)
2023-02-06 14:52:10 -08:00
Piotr Kubaj 9fcc1b60b7 iwm(4), iwmfw(4): mention iwm7265Dfw
Correct documentation by mentioning iwm7265Dfw.

PR:	234584
Differential review:	https://reviews.freebsd.org/D38374
Approved by:	erj

(cherry picked from commit 29fa34aadb)
(cherry picked from commit 97ab40b1d7)
2023-02-04 18:01:44 +01:00
Xin LI a47e1bdf89 etcupdate: Chase test case after pwd_mkdb(8) no longer copies comments.
(cherry picked from commit 4bbf45cf56)
2023-02-03 16:28:12 -08:00
Andre Albsmeier b96684daa8 pwd_mkdb(8): Don't copy comments from /etc/master.passwd to /etc/passwd.
The intention of /etc/passwd was to support legacy applications that are
not yet converted to use modern API like getpwent(3). Comments are not
defined in the legacy format, so copying them could break these
applications. Plus, it could leak sensitive information (e.g. encrypted
form of password of an user that was commented out instead of deleted
or disabled).

PR:		bin/144652
(cherry picked from commit 0deb25bd9d)
2023-02-03 16:27:55 -08:00
Enji Cooper ac3223a57e sbin/devfs: Correct usage
The -s applies to rule keyword only and it follows the rule keyword.

PR:		263289
Submitted by:	Yuichiro NAITO <[email protected]>
Reviewed by:	ngie
Fixes:		c3e412c083 sbin/devfs: clarify usage
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D34934

(cherry picked from commit f9f42a709b)
(cherry picked from commit 66b8820789)
2023-02-03 23:59:18 +08:00
Gordon Bergling 35f4cc4354 umcs(4): Fix a typo in a kernel message
- s/confguration/configuration/
- s/nornal/normal/

Obtained from:	NetBSD

(cherry picked from commit ee27834d74)
2023-02-02 10:02:28 +01:00
Jamie Landeg-Jones b2ffd03bbb usr.bin/stat: Fix error message formatting.
PR:		bin/261657

(cherry picked from commit 37399d5bcf)
2023-01-31 23:25:36 -08:00
Gregory Neil Shapiro 46f35ff24f Note upgrade to sendmail 8.17.1 2023-02-01 03:21:35 +00:00
Gregory Neil Shapiro 909f90986e MFC: Minor changes to force commit these files so new freebsd*.cf files are
built to use the new sendmail-8.17.1/cf tree.

(cherry picked from commit 431d2a81d4)
2023-02-01 03:21:03 +00:00
Gregory Neil Shapiro 8d4a89c92f MFC: Sync with vendor sendmail 8.17.1 cf/cf/submit.mc
(cherry picked from commit 021562c502)
2023-02-01 03:20:51 +00:00
Gregory Neil Shapiro 1b51c714b0 MFC: sendmail 8.17.1 included this fix, though in a different location so
removing the FreeBSD local code in favor of the vendor branch version

(cherry picked from commit f97a19ecb9)
2023-02-01 03:20:25 +00:00
Gregory Neil Shapiro a7ce4a2953 MFC: Add -DSTARTTLS CFLAG in order to enable DANE in sendmail builds
(cherry picked from commit 3413ee88c3)
2023-02-01 03:20:12 +00:00
Gregory Neil Shapiro b8d63afff5 MFC: Update for new library files in sendmail 8.17.1
(cherry picked from commit d89513ed20)
2023-02-01 03:19:59 +00:00
Gregory Neil Shapiro 08ca3eb6db MFC: Merge commit '28fbd2825d216dafca4d991ad96d05b312f4f9a3'
Merge vendor sendmail 8.17.1 into HEAD

(cherry picked from commit 2fb4f839f3)
2023-02-01 03:19:44 +00:00
Cy Schubert 3512eda8e0 network.subr: Fix infinite loop
When setting up carp tunnel, using a password consisting of only the
characters used as hexadecimal characters, i.e. abc-def, there will be
an infinite loop in the shell function ifalias_af_common_handler().
To circumvent this we test for " pass ".

PR:		268378
Reported by:	[email protected]
Differential Revision:	https://reviews.freebsd.org/D37748

(cherry picked from commit e3e57edf4a)
2023-01-31 18:55:19 -08:00
Cy Schubert 82de173cbc network.subr: Replace "\ " with "[[:space:]]"
"[[:space:]]" is easier to read than "\ " and is conisitent with
clone_up().

Reported by:	eugen
Differential Revision:	https://reviews.freebsd.org/D37748

(cherry picked from commit fef0e429f1)
2023-01-31 18:55:19 -08:00
Arthur Kiyanovski 00a6bb16fb ena: Update driver version to v2.6.2
Bug Fixes:
* Remove timer service re-arm on ena_restore_device failure.
* Re-Enable per-packet missing tx completion print

Minor Changes:
* Switch driver owners from Semihalf to Amazon in man file.

MFC after: 2 weeks
Sponsored by: Amazon, Inc.
Pull Request: https://github.com/freebsd/freebsd-src/pull/637

(cherry picked from commit e5de1d8dad)
2023-01-31 13:46:50 +01:00
Arthur Kiyanovski 235f2ddf9d ena: Switch driver owners from semihalf to amazon in man file
1. Update ena.4 manual file to include amazon owner emails.
2. State that the driver is developed by amazon but leave
that it was originally written by Semihalf, similarly to other
drivers in the /share/man/ directory of the FreeBSD source code.
3. Advance year in copyright notice to 2022.

MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit fb47286c38)
2023-01-31 13:46:50 +01:00
David Arinzon b1f4275bfe ena: Remove timer service re-arm on ena_restore_device failure
In case the reset sequence fails (ena_destroy_device() followed by
ena_restore_device() calls) during ena_restore_device(), the driver
resources are being freed. After the clean-up, the timer service is
re-armed in order to try and re-initialize the driver state.
But, such an attempt would fail given that the resources are freed.
Moreover, this would actually cause either the system to fail or a
panic.
When the driver fails in ena_restore_device() procedure, the only
recovery is either unloading and loading the driver or instance
reboot.

This change removes the timer service re-arm in case of failure
in ena_restore_device().

MFC after: 2 weeks
Sponsored by: Amazon, Inc.
Fixes: 78554d0c70 ("ena: start timer service on attach")

(cherry picked from commit c4a85b8d68)
2023-01-31 13:46:50 +01:00
Arthur Kiyanovski 113c730edc ena: Re-Enable per-packet missing tx completion print
Commit [1] first added the ena_tx_buffer.print_once member,
so that a message about a missing tx completion is printed only
once per packet (and not every second when the watchdog runs).
In this commit print_once is initialized to true, and is set back
to false after detecting a missing tx completion and printing
a warning about it to dmesg.

Commit [2] incorrectly reverses the values assigned to print_once.
The variable is initialized to be true but is checked to be false
when a missing tx completion is detected. This is never true, and
therefore the warning print for each missing tx completion is never
printed since this commit.

Commit [3] added time passed since last TX cleanup to the missing
tx completions per-packet print. However, due to the issue in commit
[2], this time is never printed.

This commit reverses back the values assigned to ena_tx_buffer.print_once
erroneously by commit [2], bringing back to life the missing tx
completion per-packet print.

Also add a space after "." in the missing tx completion print.

[1] - 9b8d05b8ac ("Add support for Amazon Elastic Network Adapter (ENA) NIC")
[2] - 74dba3ad78 ("Split function checking for missing TX completion in ENA driver")
[3] - d8aba82b5c ("ena: Store ticks of last Tx cleanup")

Fixes: 74dba3ad78 ("Split function checking for missing TX completion in ENA driver")
Fixes: d8aba82b5c ("ena: Store ticks of last Tx cleanup")
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit f01b2cd98e)
2023-01-31 13:46:50 +01:00
Warner Losh ffcc58a767 ena: Remove write only variables
Sponsored by:		Netflix

(cherry picked from commit 094b2a2379)
2023-01-31 13:46:49 +01:00
John Baldwin 98091db83d ena: Remove unused variable.
(cherry picked from commit 4dab99b936)
2023-01-31 13:46:49 +01:00
Kristof Provost 5a0cbbcaca pfctl: rule.label is a two-dimensional array
Fix checking for a non-empty first string.

PR:		269075
MFC after:	1 week
Reported by:	[email protected]

(cherry picked from commit cd80c52cad)
2023-01-31 04:29:52 +01:00
Mark Johnston 870464f11f kvmclock: Fix initialization when EARLY_AP_STARTUP is not defined
To attach to the hypervisor, kvmclock needs to write a per-CPU MSR.
When EARLY_AP_STARTUP is not defined, device attach happens too early:
APs are not yet spun up, so smp_rendezvous only runs the callback on the
local CPU.  As a result, the timecounter only gets initialized on the
BSP, and then timekeeping is broken on SMP systems.

Implement handling for !EARLY_AP_STARTUP kernels: keep track of the CPU
on which device attach ran, and then use a SI_SUB_SMP SYSINIT to
register the rest of the CPUs with the hypervisor.

Reported by:	Shrikanth R Kamath <[email protected]>
Reviewed by:	kib, jhb (earlier versions)
Sponsored by:	Klara, Inc.
Sponsored by:	Juniper Networks, Inc.
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D37705

(cherry picked from commit 568f552b04)
2023-01-29 13:56:06 -05:00
Kajetan Staszkiewicz 668a32ab23 netpfil tests: improve pfsync_defer.py
Return different exit code depending on which failure was encountered.
The pfsync test expect a very particular failure, not just any.

MFC after:	1 week
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D38123

(cherry picked from commit 06012728be)
2023-01-29 03:34:56 +01:00
Kajetan Staszkiewicz e2be74cff3 netpfil tests: improve sniffer.py
Multiple improvements to sniffer.py:

* Remove ambiguity of configuring recvif, it must be now explicitly specified.
* Don't catch exceptions around creating the sniffer, let it properly
  fail and display the whole stack trace.
* Count correct packets so that duplicates can be found.

MFC after:	1 week
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D38120

(cherry picked from commit a39dedeb31)
2023-01-29 02:47:18 +01:00
Kristof Provost 1279c260c0 pf tests: test fast port re-use with syncookies
When a src/dst ip/port tuple is re-used before the pf state fully
expires we clean up the state and create a new one, unless syncookies
are enabled.

Test this, by running two back-to-back nc sessions, with a fixed source
port. Move the interface and IP to a different (vnet) jail, to trick the
network stack into letting us do this.

MFC after:      2 weeks
Event:          Aberdeen hackathon 2022
Differential Revision:  https://reviews.freebsd.org/D36886

(cherry picked from commit dc698b2cd5)
2023-01-27 10:50:40 +01:00
Kristof Provost 8f22dbcf0f pf: fix syncookies in conjunction with tcp fast port reuse
Basic scenario: we have a closed connection (In TCPS_FIN_WAIT_2), and
get a new connection (i.e. SYN) re-using the tuple.

Without syncookies we look at the SYN, and completely unlink the old,
closed state on the SYN.
With syncookies we send a generated SYN|ACK back, and drop the SYN,
never looking at the state table.

So when the ACK (i.e. the third step in the three way handshake for
connection setup) turns up, we’ve not actually removed the old state, so
we find it, and don’t do the syncookie dance, or allow the new
connection to get set up.

Explicitly check for this in pf_test_state_tcp(). If we find a state in
TCPS_FIN_WAIT_2 and the syncookie is valid we delete the existing state
so we can set up the new state.
Note that when we verify the syncookie in pf_test_state_tcp() we don't
decrement the number of half-open connections to avoid an incorrect
double decrement.

MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D37919

(cherry picked from commit 9c041b450d)
2023-01-27 04:17:06 +01:00
Kristof Provost 76e1ec4e10 pf: fix panic on deferred packets
The pfsync_defer_tmo() callout needs to set the correct vnet before it
can transmit packets. It used the rcvif in the mbuf to get this vnet,
but that doesn't work for locally originated traffic. In that case the
rcvif pointer is NULL, and the dereference leads to a panic.

Instead use the sc_sync_if, which is always set (if pfsync is enabled,
at least).

PR:		268246
MFC after:	2 weeks

(cherry picked from commit fd02192c3a)
2023-01-27 04:16:43 +01:00
Gordon Bergling c82fcdc3b4 ath(4): Fix a sysctl description and a typo in a comment
- s/delimeter/delimiter/

(cherry picked from commit e4b7980c5c)
2023-01-26 11:49:40 +01:00
Rick Macklem 9d35b4b38e kgssapi: Increase timeout for kernel to gssd(8) upcalls
It turns out that the underlying problem that caused
a Kerberized NFS mount with the "gssname" option to
fail was that the kernel upcall to the gssd(8) daemon
would time out prematurely after 25 seconds.  The
gss_acquire_cred() GSSAPI library call
takes about 27 seconds for the case where a desired_name
argument is specified.  A similarly long delay occurs
when the gss_init_sec_context() call is made and the
user principal's TGT has expired.

Once the upcall timed out, the kernel code assumed that
the gssd(8) daemon had died and closed the socket.
Ironically, closing the socket did cause the gssd(8)
daemon to terminate via a SIGPIPE signal.

This patch increases the timeout to 5 minutes.  Since
a timeout should only occur when the gssd(8) daemon
has died, a long timeout should be ok and seems to fix this
problem.

I still think that commit c33509d49a should remain in the
system, since it allows the mount to complete quickly
and not take nearly 30 seconds.

PR:	268823

(cherry picked from commit e3c26ce5cb)
2023-01-25 19:07:41 -08:00
Gordon Bergling 71315f1556 cxgbetool(8): Fix common typos in sysctl descriptions
- s/addres/address/

(cherry picked from commit 74d2a3c16d)
2023-01-24 09:04:13 +01:00
Gordon Bergling 2a811ae423 rc.initdiskless: Fix a typo in a comment
- s/attemping/attempting/

(cherry picked from commit 30985d19b0)
2023-01-24 09:04:02 +01:00
Mark Johnston f2dc387443 vm_object: Fix a kernel memory disclosure via the vm_object list sysctl
Reported by:	Chris J-D <[email protected]>
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit b050ee6c97)
2023-01-23 08:51:57 -05:00
Kajetan Staszkiewicz 56a80affe4 pf tests: properly destroy renamed interfaces
The pfsync:pbr tests leaves  lot of interfaces when they finish, making
other tests slower due to long time of loading scapy from pft_ping.py
when more interfaces are present. When both sides of epair are assigned
to jails, they are both removed from created_interfaces.lst and thus
won't be removed during cleanup from this file. An interface assigned to
jail is stored in created_jails.lst but if it is renamed, it won't be
cleaned up either. Furthermore this test uses identical names for
multiple interfaces across multiple jails which after destroying those
jails adds to overall confusion.

To address this issue a new function is provided for renaming interfaces
in jails and storing their new names in created_jails.lst for deletion
during cleanup.

MFC after:	1 week
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D38024

(cherry picked from commit ddcdb534b7)
2023-01-23 03:26:26 +01:00
Yoshihiro Takahashi 9c9e31b9ac unzip: Document optional member list
Submitted by:	Pat Maddox (man page)
PR:		267426

(cherry picked from commit a1f28ec729)
2023-01-22 19:48:17 +09:00
Gordon Bergling bcb9c005b7 mountd(8): Fix a typo in a source code comment
- s/ingore/ignore/

(cherry picked from commit afc55510b1)
2023-01-22 10:11:17 +01:00
Gordon Bergling 6b88ab194e bsnmpget.1: Fix a typo in the man page
- s/ingore/ignore/

(cherry picked from commit 7a184a41c6)
2023-01-22 10:10:51 +01:00
Gordon Bergling 8989ea93ff nfs: Fix a common typo in source code comments
- s/ingore/ignore/

(cherry picked from commit 72e709040f)
2023-01-22 10:10:37 +01:00
Gordon Bergling 977add957e ip_gre: Fix a common typo in source code comments
- s/addres/address/

(cherry picked from commit fa7de6dcb9)
2023-01-22 10:10:13 +01:00
Chuck Tuffli d4e643f6a5 bhyve nvme: Fix uninitialized pointer
The Dataset Management code could free an uninitialized pointer if the
device doesn't support the Dataset Management command.

PR:		264548
Reported by:	Robert Morris <[email protected]>

(cherry picked from commit 7376c08cc6)
(cherry picked from commit c84ec3076e)
2023-01-20 16:08:28 -05:00
Zhenlei Huang d89fd4115e lio: Remove unneeded include
Reviewed by:		adiran, imp
Differential Revision:	https://reviews.freebsd.org/D36501

(cherry picked from commit d819ddba9a)
(cherry picked from commit 0d44c5ae37)
2023-01-19 23:47:14 +08:00
Zhenlei Huang 4d8dd8c294 devfs.rules: Do not expose "log" in the default devfs rules
/etc/rc.d/jail no longer creates /dev/log as a symbolic link since
commit 84b354cb9a.

PR:		228351
Reviewed by:	jamie, markj
Differential Revision:	https://reviews.freebsd.org/D34563

(cherry picked from commit 2670ea8a07)
(cherry picked from commit 02fe448437)
2023-01-19 23:01:00 +08:00
Brooks Davis ad23377e24 xdr: store chars consistently
Cast char's through unsigned char before storing as an integer in
xdr_char(), this ensures that the encoded form is consistently not
sign-extended following Open Solaris's example.

Prior to this change, platforms with signed chars would sign extend
values with the high bit set but ones with unsigned chars would not
so 0xff would be stored as 0x000000ff on unsigned char platforms and
0xffffffff on signed char platforms.  Decoding has the same
result for either form so this is a largely cosmetic change, but it
seems best to produce consistent output.

For more discussion, see https://github.com/openzfs/zfs/issues/14173

Reviewed by:	mav, imp
Differential Revision:	https://reviews.freebsd.org/D37992

(cherry picked from commit a872c37054)
2023-01-18 23:48:18 +00:00
Gordon Bergling 1a27768e01 iwmbtfw(8): Fix a typo in a kernel message
- s/succesful/successful/

(cherry picked from commit 40bb52c89b)
2023-01-16 07:27:45 +01:00
Gordon Bergling 3958005e5a libiscsiutil: Fix a typo in a source code comment
- s/sesion/session/

(cherry picked from commit 29b36af998)
2023-01-14 10:35:58 +01:00
Gordon Bergling 4b2bf618bb mvs(4): Fix a typo in a source code comment
- s/reqests/requests/

(cherry picked from commit f272a059a4)
2023-01-14 10:35:24 +01:00
Gordon Bergling cdae020d11 cxgbe(4): Fix a few common typos in source code comments
- s/Reqests/Requests/

(cherry picked from commit f273b45613)
2023-01-14 10:35:09 +01:00
Gordon Bergling b058f18ecc ahci(4): Fix a typo in a source code comment
- s/reqests/requests/

(cherry picked from commit bc9228749c)
2023-01-14 10:34:49 +01:00
Gordon Bergling d7c0432456 tcp_hpts: Fix a typo in a source code comment
- s/subract/subtract/

(cherry picked from commit d68f154205)
2023-01-14 10:34:27 +01:00
Gordon Bergling 582ee5dc75 i386: Fix a typo in a source code comment
- s/betwen/between/

(cherry picked from commit 77a863b6c2)
2023-01-14 10:34:04 +01:00
Gordon Bergling fb5eeed105 ice: Fix a typo in a source code comment
- s/reqest/requests/

(cherry picked from commit b6f9c6aadc)
2023-01-14 10:33:21 +01:00
Gordon Bergling 729a000162 vr(4): Fix a typo in a source code comment
- s/reuqest/request/

(cherry picked from commit 70182a0cfb)
2023-01-14 10:33:01 +01:00
Gordon Bergling 32fdfa7fd8 libthr(3): Fix a typo in a source code comment
- s/extentions/extensions/

(cherry picked from commit 085a77a677)
2023-01-14 10:32:44 +01:00
Gordon Bergling 2e060234b8 tty(4): Fix a typo in a source code comment
- s/charaters/characters/

(cherry picked from commit a74be23c6e)
2023-01-14 10:32:26 +01:00
Gordon Bergling bae5008728 isci(4): Fix common typos in source code comments
- s/reuqest/request/
- s/requst/request/

(cherry picked from commit be51810f8d)
2023-01-14 10:32:09 +01:00
Gordon Bergling d7a8aaea36 mrsas(4): Fix a typo in a source code comment
- s/reqest/request/

(cherry picked from commit e018483b10)
2023-01-14 10:31:26 +01:00
Zhenlei Huang 92de6be41e if_me: Use dedicated network privilege
Separate if_me privileges from if_gif.

Reviewed by:	kp
Approved by:	kp (mentor)
Differential Revision:	https://reviews.freebsd.org/D36691

(cherry picked from commit 43f8c763cd)
(cherry picked from commit 310f6f2448)
2023-01-13 12:30:21 +08:00
Zhenlei Huang b16d7d17d1 if_vxlan(4): Correct the statistic for output bytes
The vxlan interface encapsulates the Ethernet frame by prepending IP/UDP
and vxlan headers. For statistics, only the payload, i.e. the
encapsulated (inner) frame should be counted.

Event:		Aberdeen Hackathon 2022
Reviewed by:	kp
Approved by:	kp (mentor)
Differential Revision:	https://reviews.freebsd.org/D36855

(cherry picked from commit de1ea2d517)
(cherry picked from commit faa7d6c2f9)
2023-01-13 12:30:20 +08:00
Zhenlei Huang fcc7231213 if_vxlan(4): Add missing statistic for input packets
Event:		Aberdeen hackathon 2022
Reviewed by:	bryanv, kp
Approved by:	kp (mentor)
Differential Revision:	https://reviews.freebsd.org/D36841

(cherry picked from commit 1fc839f489)
(cherry picked from commit 00399a54c5)
2023-01-13 12:30:20 +08:00
Zhenlei Huang 40beb4ae59 vxlan: Add support for socket ioctls SIOC[SG]TUNFIB
Submitted by: Luiz Amaral <[email protected]>
PR:	244004
Reviewed by:	gbe (manpages), melifaro, pauamma (manpages)
Approved by:	kp (mentor)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D32820

(cherry picked from commit 7f7a804ae0)
(cherry picked from commit 8819353dd0)
2023-01-13 12:30:20 +08:00
Ed Maste 33724b67e6 readelf: match GNU readelf formatting
GNU readelf emits a blank line before, and uses single quotes around the
symbol table name, in each "Symbol table 'name' contains ## entries"
header.

Reviewed by:	markj
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37746

(cherry picked from commit 766145637d)
2023-01-09 12:25:02 -05:00
Eugene Grosbein 14814ff45b syslog: fix PID of forking process
Do not cache PID for a process that does not fabricate it,
calls openlog() before forking and does not call exec() thereafter.

PR:		268666
Fixes:		e9ae9fa937
Tested by:	kp

(cherry picked from commit 2ce3ef5503)
2023-01-06 11:46:33 +07:00
Cy Schubert 8c7c23a6e0 network.subr: Add missing brace
PR:		268378
Submitted by:	[email protected]
Reported by:	[email protected]

(cherry picked from commit 87061d3bff)
2023-01-04 16:35:59 -08:00
Cy Schubert 13202ee5cc sqlite3: Vendor import of sqlite3 3.40.0
Changes at https://www.sqlite.org/releaselog/3_40_0.html

Obtained from:  https://www.sqlite.org/2022/sqlite-autoconf-3400000.tar.gz

(cherry picked from commit ac50343d44)
2023-01-04 07:29:13 -08:00
Vincenzo Maffione b4f8bd4de9 libnetmap: reset errno in nmreq_register_decode()
The reset is necessary at the beginning of the function, because of
the errno logic in the error path (set errno to EINVAL if not set).
If errno is already set when calling the function, and the function
fails, the previous errno value will be inherited.

(cherry picked from commit ab639bb287)
2022-12-31 12:43:08 +00:00
Vincenzo Maffione a95578c87c nemtap: lb app: Validate ihl field when hashing packet
MFC after:	1 week

(cherry picked from commit f7cef43aa9)
2022-12-31 12:41:42 +00:00
Vincenzo Maffione e93766bcd4 netmap: don't use linux type struct device *
Such type cannot be used in code that is in common between
FreeBSD and Linux. Use the FreeBSD type instead.

MFC after:	3 days
Reported by:	markj
Differential Revision:	https://reviews.freebsd.org/D29677

(cherry picked from commit 70275a6735)
2022-12-31 12:38:43 +00:00
Vincenzo Maffione f7691b18b7 netmap: vale: fix disabled logs
MFC after:	1 week

(cherry picked from commit 06f6997eb5)
2022-12-31 12:33:11 +00:00
Vincenzo Maffione 87c145309e netmap: monitor: add a flag to distinguish packet direction
The netmap monitor intercepts any TX/RX packets on the monitored
port. However, before this change there was no way to tell
whether an intercepted packet was being transmitted or received
on the monitored port.
A TXMON flag in the netmap slot has been added for this purpose.

(cherry picked from commit 660a47cb99)
2022-12-31 12:24:22 +00:00
Vincenzo Maffione 7a1e0af7d0 netmap: pkt-gen: fix ifname before cmp in source_hwaddr
In source_hwaddr(), the configured ifname is compared against all
interfaces. However, in main(), the string 'netmap:' is prepended to the
interface string if no explicit type is given. Therefore the ifname will
not match any system interface and the source MAC address is always
empty.

Check for the leading 'netmap:' string and skip past it to match against
system interfaces. Note that 'tap:' and 'pcap:' devices strip the type
string from the ifname in main() so no further work is needed.

MFC after:	7 days
Submitted by:	Brian Poole <[email protected]>

(cherry picked from commit eda8251188)
2022-12-31 12:14:49 +00:00
Vincenzo Maffione 79a1edf21e netmap: monitor: add missing netmap_adapter_put()
MFC after:	7 days

(cherry picked from commit 95fc11577d)
2022-12-31 12:14:38 +00:00
Vincenzo Maffione 6e23ef9c57 debug_put_get: don't crash on null pointers
MFC after:	7 days

(cherry picked from commit 92e8b4a630)
2022-12-31 12:14:25 +00:00
Vincenzo Maffione a74ed14423 monitor: fix cb restore when monitored adapter unregisters
netmap_monitor_stop() called nm_monitor_none() after the head of
the zero-copy monitors had been reset, thus thinking that there
was nothing left to do.

MFC after:	7 days

(cherry picked from commit b41818a28a)
2022-12-31 12:14:13 +00:00
Vincenzo Maffione 82e3b96039 netmap: drop compatibility FreeBSD code
Netmap users on FreeBSD are not supposed to import code from the
github netmap repository anymore. They should use the code that
is available in the src repo. We can therefore drop the compatibility
code.

MFC after:	7 days

(cherry picked from commit 3da494d324)
2022-12-31 12:13:55 +00:00
Vincenzo Maffione b0491d5a73 netmap_update_config: update na->name to cope with reconfigurations
MFC after:	1 week

(cherry picked from commit 4ad57c7afa)
2022-12-31 12:13:55 +00:00
Vincenzo Maffione 77cef5fee7 pkt-gen: flip IPv4 address in ping-pong mode
MFC after:	7 days

(cherry picked from commit 9a7abd9327)
2022-12-31 12:13:55 +00:00
Rene Ladan bcd2206644 gpioevents: add support for pull-down and floating input pins.
The pin-mode (ft, pd, pu for floating, pull-down, pull-up) is
specified after the intr-config (no, eb, ef, er) for each pin.

Tested on my Raspberry Pi 1B.

PR:		268504
Approved by:	manu
MFC after:      1 week

(cherry picked from commit 453db42291)

gpioevents: fix some white-space errors

Fixes:		453db42291 - gpioevents: add support for pull-down and floating input pins.
Approved by:	manu (implicit)
MFC after:	1 week

(cherry picked from commit e2f3742ab8)
2022-12-29 18:01:36 +01:00
Martin Matuska f75477035d libarchive: merge from vendor branch
Libarchive 3.6.2

Important bug fixes:
  rar5 reader: fix possible garbled output with bsdtar -O (#1745)
  mtree reader: support reading mtree files with tabs (#1783)
  various small fixes for issues found by CodeQL

Relnotes:	yes

(cherry picked from commit bd5e624a86)
2022-12-28 22:57:50 +01:00
Dag-Erling Smørgrav 187905a0cc libarchive: Add missing MLINK.
Differential Revision: https://reviews.freebsd.org/D37398

(cherry picked from commit f1ad5e3931)
2022-12-28 22:57:28 +01:00
Martin Matuska d43d863bc8 libarchive: import changes from upstream
Libarchive 3.6.1

Bug fixes:
  PR #1549: archive_digest: check return value of EVP_DigestInit()

Relnotes:	yes

(cherry picked from commit 7ec51a3e2b)
2022-12-28 22:57:11 +01:00
Kristof Provost e0724177b5 pf tests: check that we clean up unused kifs
The previous commit fixed a memory leak, where we'd fail to clean up
removed groups (and interfaces).
Check that we now clean those up as expected.

MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D37570

(cherry picked from commit 654e8d84ec)
2022-12-28 06:06:13 +01:00
Nick Reilly 5f7454d890 pf: fix pfi_ifnet leak on interface removal
The detach of the interface and group were leaving pfi_ifnet memory
behind. Check if the kif still has references, and clean it up if it
doesn't

On interface detach, the group deletion was notified first and then a
change notification was sent. This would recreate the group in the kif
layer. Reorder the change to before the delete.

PR:		257218
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D37569

(cherry picked from commit bfeef0d32a)
2022-12-28 05:56:08 +01:00
Mike Karels 83dd527646 bspatch.1: fix missing argument
Fix typo

Reviewed by:	gbe
Differential Revision:	https://reviews.freebsd.org/D37727

(cherry picked from commit c7a0637417)
2022-12-26 09:01:33 -06:00
Dimitry Andric c517ef0589 Apply llvm fix for crash building julia on PowerPC64
Merge commit 6710b21d4698 from llvm git (by Kai Luo):

  [PowerPC] Allow llvm.ppc.cfence to accept pointer types

  In the context of atomic load, integer, pointer and float point types are allowed, thus we should allow llvm.ppc.cfence to accept any type mentioned.

  Fixes https://github.com/llvm/llvm-project/issues/55983.

  Reviewed By: shchenz, vchuravy

  Differential Revision: https://reviews.llvm.org/D127554

Requested by:	jhibbits
MFC after:	3 days

(cherry picked from commit 4589169768)
2022-12-25 12:41:43 +01:00
Xin LI f336845eb4 MFV: xz 5.2.9
(cherry picked from commit 0ca90ed42a)
2022-12-23 20:44:21 -08:00
Ed Maste 491ebfc123 Add deprecation notices to ce,cp sync serial drivers
And the related sconfig utility.  Sync serial (e.g. E1/T1) interfaces
are obsolete, and nobody responded to several inquires on the mailing
lists about use of these drivers.

Relnotes:	Yes
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23928

(cherry picked from commit 20dfe27b2d)
(cherry picked from commit b813115682)
2022-12-22 10:48:47 -05:00
Mark Johnston 0b56e82a40 libdtrace: Change the binding of USDT probe symbols to STB_WEAK
Otherwise, if multiple object files contain references to the same
probe, newish lld will refuse to link them by default, raising a
duplicate global symbol definition error.  Previously, duplicate global
symbols with identical absolute st_values were permitted by both lld and
GNU ld.

Since dtrace has no use for probe function symbols after the relocation
performed by dtrace -G, make the symbols weak as well, following a
suggestion from MaskRay.

Reported by:	dim
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit be39466a10)
2022-12-19 10:43:15 -05:00
Jamie Gritton 561dcc7f37 jail: fix a NULL pointer derefence in parsing ip6.addr settings.
This is the counterpart to bd24e861b4, which did the same for ip4.
PR:		268377
Reported by:	ahkithaama at proton.me

(cherry picked from commit e8d7ae918a)
2022-12-17 16:33:04 -08:00
Cy Schubert 30584910c3 heimdal: kadm5_c_get_principal() should check return code
kadm5_c_get_principal() should check the return code from
kadm5_ret_principal_ent(). As it doesn't it assumes success when
there is none and can lead to potential vulnerability. Fix this.

Reported by:	[email protected]

(cherry picked from commit f6d5d31cd5)
2022-12-12 06:41:21 -08:00
Cy Schubert a8970f585c heimdal: Properly ix bus fault when zero-length request received
Zero length client requests result in a bus fault when attempting to
free malloc()ed pointers within the requests softc. Return an error
when the request is zero length.

This properly fixes PR/268062 without regressions.

PR:		268062
Reported by:	Robert Morris <[email protected]>

(cherry picked from commit 3deefb0d14)
2022-12-12 06:41:17 -08:00
Eugene Grosbein af95979290 MFC: pw(8): fix combination of modes -N and -w random
The command "pw usermod nobody -Nw random" (or useradd)
generates random password and prints it in encrypted form
but skips choosen random string that makes not much sense
and contradicts the manual page pw.8

Fix it by showing random password in plain text with -N and
without it equally. Add yet another example of how to generate
pw-style random password.

(cherry picked from commit 1cbe5012cf)
2022-12-12 10:42:14 +07:00
Gordon Bergling 91d69de840 getservent.3: Mention the service.db
- reference /var/db/services.db
- reference services_mkdb(8)

Obtained from:	NetBSD

(cherry picked from commit 0393604aa8)
2022-12-10 06:06:42 +01:00
Gordon Bergling 3968b98c47 protocols.5: Update the description of /etc/protocols
The reference to the "DARPA Internet" seems not quite
up to date in 2022, so move that to the HISTORY section.

Mention RFC 2780 and RFC 5237.

Obtained from:	NetBSD

(cherry picked from commit 899edecdbe)
2022-12-10 06:06:28 +01:00
Cy Schubert 4ed9d88da4 Revert "heimdal: Fix bus fault when zero-length request received"
This is the wrong fix for PR/268062.

This reverts commit 6742ff42ab.

(cherry picked from commit 5319949668)
2022-12-09 06:13:09 -08:00
Cy Schubert 78d44cb4b5 heimdal: Fix bus fault when zero-length request received
Zero length client requests result in a bus fault when attempting to
free malloc()ed pointers within the requests softc. Return an error
when the request is zero length.

PR:		268062
Reported by:	Robert Morris <[email protected]>

(cherry picked from commit 6742ff42ab)
2022-12-05 13:50:44 -08:00
Cy Schubert e7d6b2cd43 heimdal: Add additional checks for bad kadmind input
Check return codes for bad input.

(cherry picked from commit d24b272832)
2022-12-05 13:50:43 -08:00
Mateusz Guzik 577214cb0a pf: make pfsync_state_import appease an assert in pf_free_state
The newly created state failed to be inserted anywhere. This follows
other places.

Reviewed by:	kp
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 69ce6ae21a)
2022-12-05 22:10:15 +01:00
Mitchell Horne 29ab4e9d8e development(7): redirect users from hier(7)
The layout of the source tree is now only described in README.md. Retain
the cross-reference to hier(7) in SEE ALSO; it is still useful to
readers.

Reviewed by:	imp, emaste
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37136

(cherry picked from commit 6028a56562)
2022-12-05 12:53:01 -04:00
Mitchell Horne 1be2773e63 hier(7): remove text describing /usr/src layout
It poses a maintenance burden, since much of the information is
duplicated in the src tree's README.md file. Readers who are interested
enough in learning about the structure of the src tree can download it,
or browse the README online. Have hier(7) just point them there instead.

PR:		261349
Discussed with:	freebsd-arch@, freebsd-doc@ lists
Reviewed by:	imp, emaste
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37135

(cherry picked from commit f0e4e02110)
2022-12-05 12:53:00 -04:00
Mitchell Horne 1dd8aef572 README.md: shift description of kernel config files
Document it in sys/README.md instead. Describe the purpose of LINT
config files as well.

Reviewed by:	imp
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37134

(cherry picked from commit 9e0dcd0ab2)
2022-12-05 12:50:59 -04:00
Mitchell Horne bb010ef56c sys/README.md: source roadmap improvements
Tweak the existing descriptions slightly. Add entries for several
directories which are not yet documented, but not exhaustively.

Reviewed by:	imp (previous version), emaste
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37133

(cherry picked from commit 397013385d)
2022-12-05 12:50:59 -04:00
Mitchell Horne f030a8320c Create sys/README.md
Add this primarily to document the sys/ subdirectories of the source tree.

This is a straight copy from the contents of hier(7). Improvements will
follow in other changes.

Reviewed by:	imp, emaste
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37132

(cherry picked from commit d1087fe843)
2022-12-05 12:50:59 -04:00
Xin LI f303007032 MFV: expat 2.5.0
(cherry picked from commit dc58b3fca5)
2022-12-01 22:08:41 -08:00
Xin LI 72fa82168f MFV: xz-embedded 3f438e15109229bb14ab45f285f4bff5412a9542
(cherry picked from commit cd3a777bca)
2022-12-01 22:07:56 -08:00
Xin LI 9d8cc82cf6 MFV: Merge xz 5.2.8
Relnotes:	yes
(cherry picked from commit 9e6bbe47a5)
2022-12-01 22:07:12 -08:00
Cy Schubert 2fd1b21c9c heimdal: Check return code from _hdb_fetch_kvno()
A malformed principal will cause kadmind to segfault. The PR
addresses only when chpass is requested but delete is also affected.
Fix both.

PR:		268002
Reported by:	Robert Morris <[email protected]>

(cherry picked from commit 671f55828d)
2022-12-01 06:25:53 -08:00
Cy Schubert 593699ac64 heimdal: Add missing iprop error checks.
Inspired by upstream 9d6dd21256f87988605fa75172be9cc92535064c.

Obtained from:	Heimdal 9d6dd21256f87988605fa75172be9cc92535064c

(cherry picked from commit 5040a7a9aa)
2022-12-01 06:25:53 -08:00
Cy Schubert 942281f6e2 heimdal: Add missing kadmind error checks
Inspired by:	Heimdal commmit 1b213c1082be4ef5a1c23928d614c762f837dbe7

(cherry picked from commit 80999dcd5b)
2022-12-01 06:25:53 -08:00
Cy Schubert ca2e0c6b4a heimdal: Add missing kadm5 error checks
Obtained from:	Heimdal commit 4a0e01f9edabe36d0f2cab188078dd29fa5aaf02

(cherry picked from commit 879b0e9cd2)
2022-12-01 06:25:53 -08:00
Cy Schubert f3dc873719 heimdal: Add missing kadm5 error checks
Generally obtained from upstream 655c057769f56bd8cdb7d16e93f1e7a7cb260342.

PR:		267944, 267972
Obtained from:	Heimdal commit 655c057769f56bd8cdb7d16e93f1e7a7cb260342

(cherry picked from commit 780f663df3)
2022-12-01 06:25:53 -08:00
Cy Schubert 9258693043 heimdal: Fix uninitialized pointer dereference
krb5_ret_preincipal() returns a non-zero return code when
a garbage principal is passed to it. Unfortunately ret_principal_ent()
does not check the return code, with garbage pointing to what would
have been the principal. This results in a segfault when free() is
called.

PR:		267944, 267972
Reported by:	Robert Morris <[email protected]>

(cherry picked from commit e13150e28c)
2022-12-01 06:25:52 -08:00
Cy Schubert 7b07c9924f heimdal: Handle other types of garbage data
In addition to garbage realm data, also handle garbage dbname, acl_file,
stash_file, and invalid bitmask garbage data.

PR:		267912
Reported by:	Robert Morris <[email protected]>

(cherry picked from commit 91db848212)
2022-12-01 06:25:52 -08:00
Cy Schubert 709a426717 heimdal: Fix NULL dereference when mangled realm message
Fix a NULL dereference in _kadm5_s_init_context() when the client
sends a mangled realm message.

PR:		267912
Reported by:	Robert Morris <[email protected]>

(cherry picked from commit 05bc50bdb1)
2022-12-01 06:25:52 -08:00
Cy Schubert 8d3c6e82cd heimdal: The version string must always contain a terminating NUL
Should the sender send a string without a terminating NUL, ensure that
the NUL terminates the string regardless.

And while at it only process the version string when bytes are returned.

PR:		267884
Reported by:	Robert Morris <[email protected]>
Differential Revision:	https://reviews.freebsd.org/D37471

(cherry picked from commit d7e8666ffb)
2022-12-01 06:25:52 -08:00
Philip Paeps e2861c40b1 contrib/tzdata: import tzdata 2022g
Changes: https://github.com/eggert/tz/blob/2022g/NEWS

tzdata 2022g and later split America/Ciudad_Juarez from America/Ojinaga.
Ensure this file is removed in builds WITHOUT_ZONEINFO.

(cherry picked from commit cf1ad53510)
(cherry picked from commit 821549a9df)
2022-12-01 09:38:24 +08:00
Pau Amma 1288a10af6 Update resolv.conf(5) "not necessary" language.
While there, fix mandoc -T lint warnings.

PR:		262492
Differential Revision:	https://reviews.freebsd.org/D37449
MFC after:	1 week
Reviewed by:	gjb
Approved by:	gjb (mentor)

(cherry picked from commit e8261bba4e)

Clarify what's normally not required.

Reported by:	karels
Reviewed by:	carlavilla, karels (informally)
Approved by:	carlavilla (mentor), gjb (mentor, implicitly)
Differential Revision: https://reviews.freebsd.org/D37483

(cherry picked from commit 06703946d0)
2022-11-30 20:09:32 +01:00
Tom Jones 94395be05c ping: Fix handling of IP packet sizes
Ping reads raw IP packets to parse ICMP responses. When reading the
IP Header Len (IHL) ping was was taking the value from the provided
packet without any validation. This could lead to remotely triggerable
stack corruption.

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

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

(cherry picked from commit 46d7b45a26)
2022-11-29 14:55:55 -08:00
Pau Amma adc86a2c1c Remove disused /cdrom toplevel dir from hier(7).
While here, fix igor and mandoc -T lint low-hanging fruit in hier(7)

Reviewed by:	danfe (D37473), gjb (mentor)
Approved by:	gjb (mentor)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D37472
Differential Revision:	https://reviews.freebsd.org/D37473

(cherry picked from commit 720e0e0ff1)
(cherry picked from commit 88be8b8e54)
2022-11-27 01:30:33 +01:00
Vladimir Kondratyev d95de59e94 iwmbtfw(8): Improve Intel 7260/7265 adaptors handling
- Allow firmware downloading for hw_variant #8;
- Enter manufacturer mode for setting of event mask;
- Handle multi-event response on HCI commands for 7260;
  This allows to remove kludge with skipping of 0xfc2f opcode.
- Disable patch and exit manufacturer mode on downloading failure;
- Use default firmware if correct firmware file is not found;

Reviewed by:	Philippe Michaud-Boudreault <pitwuu_AT_gmail_DOT_com>
MFC after:	1 week
Tested by:	arrowd
Differential revision:	https://reviews.freebsd.org/D30543

(cherry picked from commit da93a73f83)
2022-11-25 02:16:08 +03:00
Philippe Michaud-Boudreault f16c39e7fe iwmbtfw(8): Add support for Intel 7260/7265 bluetooth adapter firmwares
To use it comms/iwmbt-firmware port should be updated to 20210315 version.

Submitted by:	Philippe Michaud-Boudreault <[email protected]>
Tested by:	Helge Oldach <[email protected]>
Reviewed by:	wulf
PR:		228787
MFC after:	2 weeks

(cherry picked from commit fe70d7b26d)
2022-11-25 02:15:54 +03:00
Vladimir Kondratyev 6477a1fe96 ng_ubt: Block attachment of uninitialized Intel Wireless 7265
As this controller requires firmware patch downloading to operate.
"Intel Wireless 7265" support in iwmbtfw(8) is yet to be done.

Tested by:	arrowd et al
PR:		228787
MFC after:	2 weeks

(cherry picked from commit 788a171c77)
2022-11-25 02:15:48 +03:00
Vladimir Kondratyev 7048e1da51 ng_ubt: Use DEFINE_CLASS_1 macro for kobj inheritance.
MFC after:	2 weeks

(cherry picked from commit d605d72948)
2022-11-25 02:13:28 +03:00
Vladimir Kondratyev 03357811de ng_ubt: Do not clear stall before receiving of HCI command response.
Unconditional execution of "clear feature" request at SETUP stage was
workaround for probe failures on ng_ubt.ko re-kldloading which is
unnecessary now.

Reviewed by:	hselasky
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D29775

(cherry picked from commit 52489f2a55)
2022-11-25 02:13:13 +03:00
Hans Petter Selasky 56bfa62faa dhclient(8): Verify lease-, renewal- and rebinding-time option sizes.
Else out-of-bound reads and undefined behaviour may happen.
The current code only checked for the presence of the first of four bytes.
Make sure the fields in question have the minium size required.

No functional change intended.

Reviewed by:	rrs@
Sponsored by:	NVIDIA Networking

(cherry picked from commit 3492caf512)
2022-11-21 21:41:07 +01:00
Ed Maste de0b782545 dma: restore addition of newline when missing from input
If input mail does not have a newline on the last line dma must add
one.  This was broken by the addition of long-line splitting, with the
switch from strlen(line) to linelen returned by getline().

PR:		266629
Reviewed by:	bapt, Mikko Lehto
Tested by:	Mikko Lehto
MFC after:	1 week
Fixes:		b0b2d05fd0 ("Split body of mails not respecting...")
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36763

(cherry picked from commit 1694872231)
(cherry picked from commit bd3d597a6b)
2022-11-18 15:57:45 -05:00
Ed Maste 166551aa4d dma: use canonical getline() loop
getline() returns -1 on erorr or EOF, so use that condition instead of
feof() and check that there was no error after the loop exits.

Reviewed by:	bapt, kevans (both earlier)
MFC after:	3 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D34159

(cherry picked from commit d21e71efce)
(cherry picked from commit 2e8403e021)
2022-11-18 15:57:45 -05:00
Michal Meloun e5c0e6d781 arm: Fix handling of undefined instruction aborts in THUMB2 mode.
Correctly recognize NEON/SIMD and VFP instructions in THUMB2 mode and pass
these to the appropriate handler. Note that it is not necessary to filter
all undefined instruction variant or register combinations, this is a job
for given handler.

Reported by:	Robert Clausecker <[email protected]>
PR:		259187
MFC after:	2 weks

(cherry picked from commit a670e1c13a)
Signed-off-by: Olivier Houchard <[email protected]>
2022-11-18 10:45:31 +01:00
Jung-uk Kim c74589394d OpenSSL: Regen manual pages for OpenSSL 1.1.1s 2022-11-17 22:20:10 -05:00
Jung-uk Kim 3beee54141 OpenSSL: Regen assembly file for OpenSSSL 1.1.1s
(cherry picked from commit f443d0802a)
2022-11-17 22:16:20 -05:00
Jung-uk Kim 84e736e322 Import OpenSSL 1.1.1s
(cherry picked from commit b6b67f23b8)
2022-11-17 22:15:25 -05:00
Cy Schubert 5afe36c8b7 heimdal: Fix: Too large time skew, client time 1970-01-01T01:00:00
Part of ed549cb0c5 zeroed out a data structure in the resulting code-file
when a TUTCTime type was freed. This part of the patch applies to Heimdal
7.1+ and not our Heimdal 1.5.2.

PR:		267827
Reported by:	Peter Much <[email protected]>
Tested by:	Peter Much <[email protected]>
Fixes:		ed549cb0c5

(cherry picked from commit f556a05c49)
2022-11-17 17:10:53 -08:00
Cy Schubert 4d44715e08 ipfilter: Document count_mask_bits() arguments
Document arguments input to count_mask_bits().

(cherry picked from commit 1ffab636da)
2022-11-17 16:27:46 -08:00
Andrey V. Elsukov fe9c4deda9 ixgbe: workaround errata about UDP frames with zero checksum
Intel 82599 has errata related to IPv4 UDP frames with zero checksum.
It reports such datagrams with L4 integrity errors in IXGBE_XEC
register. And after afb1aa4e6d commit such errors are reported
via IFCOUNTER_IERRORS. This confuses users, since actually all frames
are handled correctly by the system.
To workaround the problem, let's ignore the XEC register value for
82599 cards for now.

PR:		266048
Discussed with:	erj
Sponsored by:	Yandex LLC

(cherry picked from commit 8526120ad4)
2022-11-17 23:16:15 +03:00
Cy Schubert f8a825bde7 heimdal: Fix multiple security vulnerabilities
The following issues are patched:

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

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

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

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

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

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

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

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

(cherry picked from commit ed549cb0c5)
2022-11-15 13:16:56 -08:00
Glen Barber f398c2d832 release: fix on-disc pkg binary symbolic links
PR:		263574
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 68b0a79b7c)
2022-11-15 14:06:02 -05:00
Gordon Bergling 9f560b00e2 ascii.7: Add full names of the control character set
Extent the manual page by the full names of the
control character set.

Obtained from:	NetBSD

(cherry picked from commit b6d1ac7f01)
2022-11-15 07:59:44 +01:00
Gordon Bergling 88e1fa97b0 vipw.8: Add a FILES section
Mention passwd related files in the FILES section
of vipw(8).

Obtained from:	OpenBSD

(cherry picked from commit 30a6c8a3a8)
2022-11-15 07:59:34 +01:00
Gordon Bergling 8548689c5b resolver.5: Add an EXAMPLES section
In case local-unbound(8) fails for some reason, it could be useful
to have a basic resolv.conf(5) example in the manual page.

Reviewed by:	karels, pauamma
Differential Revision:	https://reviews.freebsd.org/D37183

(cherry picked from commit 4d00d772e9)
2022-11-14 09:28:53 +01:00
Gordon Bergling 5ed391a2a8 Update SEE ALSO sections for resolver.{3,5} and hosts.5
The mentioned document "Name Server Operations Guide for BIND" is
outdated, so remove it from the SEE ALSO section of hosts.5
and resolver.{3,5}.

PR:		266360
Reported by:	Graham Perrin <grahamperrin at FreeBSD dot org>
Reviewed by:	karels
Differential Revision:	https://reviews.freebsd.org/D36557

(cherry picked from commit 0090d18235)
2022-11-14 09:28:30 +01:00
Mike Karels 457c0c0b07 man pages: deprecate Internet Class A/B/C
Mark functions inet_netof(), inet_lnaof(), and inet_makeaddr() as
deprecated, as they assume Class A/B/C.  inet_makeaddr() mostly works
when networks are a multiple of 8 bits, but warn for anything other
than historical classes.  Reduce other mentions of network classes.

Reviewed by:	bcr, #manpages
Differential Revision: https://reviews.freebsd.org/D32711

(cherry picked from commit 12bd931d8c)
2022-11-14 09:17:16 +01:00
Ceri Davies 6d105d73ca man5/{hosts,resolver}.5: note that IPv6 addresses are allowed.
The patch in the PR largely no longer applied due to age, but
thanks to Evgeniy Khramtsov for the patches in the PR.

PR:		120024
Reported by:	bcran
Approved by:	blackend (mentor)
Obtained from:	Evgeniy Khramtsov <[email protected]> (partly)

(cherry picked from commit a23b08cf98)
2022-11-14 09:16:46 +01:00
Warner Losh 9400d17e9a man: Remove obsolete info from hosts man page
The NIC no longer provides a host database, and hasn't for quite some
time. Remove that paragraph, it's not been relevant for many years. Also, hosts
appeared in 4.1c, not 4.2, so correct that too.

Noticed by: Henry Bent

(cherry picked from commit c22076b528)
2022-11-14 09:16:23 +01:00
Gordon Bergling 572cb0ae46 shutdown.8: Add a note about needed priviledges to run the command
In order to use the shutdown command, the user must
have root privileges or be a member of the operator group.

PR:		266525
Reported by:	Zsolt Udvari <uzsolt at uzsolt hu>
Reviewed by:	pauamma
Differential Revision:	https://reviews.freebsd.org/D36688

(cherry picked from commit e0dfa1c4c4)
2022-11-14 08:58:20 +01:00
Gordon Bergling cad5dc040f Update HISTORY and AUTHORS sections for cut(1) and paste(1)
In an e-mail Brian Walden wrote that:

"GWRL stands for Gottfried W. R. Luderer, the author of cut(1) and
paste(1), probably around 1978. Those came either from PWB or USG,
as he worked with, or for, Berkley Tague. Thus they made their way
into AT&T commercial UNIX, first into System III and the into System
V, and that's why they are missing from early BSD releases as they
didn't get into Research UNIX until the 8th Edition."

So update the HISTORY and AUTHORS sections for cut(1) and paste(1).

[1] https://minnie.tuhs.org/pipermail/tuhs/2020-January/019955.html

Reviewed by:	pauamma, imp
Obtained from:	OpenBSD (in partial)
Differential Revision:	https://reviews.freebsd.org/D36048

(cherry picked from commit 9bdb5158d6)
2022-11-14 08:54:20 +01:00
Oskar Holmlund 558694f970 dts: Revert DTS for OMAP family
In DTS import from Linux 5.5 the ti,hwmods were deprecated in favor of
using ti-sysc interconnect target module to identify the IP blocks.

Direct commit to stable/12, since stable/13 and later have an updated
ti-sysc driver.

Approved by: manu (mentor)
Differential revision: https://reviews.freebsd.org/D26552
2022-11-14 07:26:00 +01:00
Warner Losh f04c625605 Remove README in favor of README.md
Complete the transition to README.md I started 3 years ago. Remove the
now-redundant README file. It's currently just README.md w/o the light markup
and adds no real value. This also allows us to use additional MarkDown
markup as we see fit w/o worrying about keeping things in sync.

(cherry picked from commit 8a157722e9)
2022-11-12 15:09:20 -04:00
Li-Wen Hsu 01ae8c8771 Whitespace cleanup
(cherry picked from commit aaf998056e)
2022-11-12 15:09:20 -04:00
Li-Wen Hsu 77721aadea Update doc links in README
(cherry picked from commit cada2b74b8)
2022-11-12 15:09:20 -04:00
Warner Losh 14b7ad0749 readme: Link to COPYRIGHT file
(cherry picked from commit e75eac2cb8)
2022-11-12 15:09:20 -04:00
Warner Losh 90d19a534a Fix arch rendering
(cherry picked from commit dbd92cc2a4)
2022-11-12 15:09:20 -04:00
Warner Losh 8497a86e83 readme: update style
Update the style to one sentence per line, as is currently used in the FreeBSD
document project. Make the links to the handbook clickable.

(cherry picked from commit 2918e9fdb8)
2022-11-12 15:09:20 -04:00
John Baldwin 0702f3c446 ktrace.2: Document KTRFAC_STRUCT_ARRAY.
Sponsored by:	DARPA

(cherry picked from commit c9c9057c77)
2022-11-11 08:46:36 -08:00
Gordon Bergling 0090b035f4 pnfs.4: Fix a typo
- s/attrbute/attribute/

(cherry picked from commit 40b245af0f)
2022-11-11 05:35:35 +01:00
Gordon Bergling 22d04fc263 nfs: Fix common typos in source code comments
- s/attrbute/attribute/

(cherry picked from commit bf31248287)
2022-11-11 05:35:22 +01:00
Vitaliy Gusev c54f01a0cb vmm: Cherry pick illumos commit '13361 bhyve should mask RDT cpuid info'
Summary:
    commit  1a5f1879be09d3de900b2510692dd12003784d84
    Author: Patrick Mooney <[email protected]>
    Date:   2020-12-16T20:02:23.000Z

        13361 bhyve should mask RDT cpuid info
        Reviewed by: Andy Fiddaman <[email protected]>
        Reviewed by: Toomas Soome <[email protected]>
        Approved by: Robert Mustacchi <[email protected]>

    https://github.com/illumos/illumos-gate/commit/1a5f1879be09d3de900b2510692dd12003784d8

----

We saw similar warning of GP (on Intel Xeon CPU E5-2630 v4 and VM with Ubuntu 20.04 5.4.0-113-generic)  until this commit is applied:

```
[    1.658880] kernel: unchecked MSR access error: WRMSR to 0xc8f (tried to write 0x0000000000000000) at rIP: 0xffffffffacc735b4 (native_write_msr+0x4/0x30)
[    1.662734] kernel: Call Trace:
[    1.663885] kernel:  ? clear_closid_rmid.isra.0+0x36/0x40
[    1.665501] kernel:  resctrl_online_cpu+0xdc/0x3f0
[    1.666952] kernel:  ? __switch_to_asm+0x40/0x70
[    1.668358] kernel:  ? __switch_to+0x7f/0x480
[    1.669693] kernel:  ? cat_wrmsr+0x70/0x70
[    1.670970] kernel:  cpuhp_invoke_callback+0x9b/0x580
[    1.672541] kernel:  ? __schedule+0x2eb/0x740
[    1.673893] kernel:  cpuhp_thread_fun+0xb8/0x120
[    1.675304] kernel:  smpboot_thread_fn+0xd0/0x170
[    1.676685] kernel:  kthread+0x104/0x140
[    1.677948] kernel:  ? sort_range+0x30/0x30
[    1.679299] kernel:  ? kthread_park+0x90/0x90
[    1.680570] kernel:  ret_from_fork+0x35/0x40
[    1.682000] kernel: *** VALIDATE rdt ***
[    1.683454] kernel: resctrl: L3 monitoring detected
```

Reviewed by:	markj, jhb
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D35442

(cherry picked from commit 5afcca138f)
2022-11-10 17:49:05 -08:00
John Baldwin 1282bf40f7 bhyve virtio-scsi: Avoid out of bounds accesses to guest requests.
- Ignore I/O requests with insufficiently sized input or output
  buffers (those not containing compete request headers).

- Ignore control requests with improperly sized buffers.

- While here, explicitly zero the output header of an I/O request to
  avoid leaking malloc garbage from the host if the header is not
  fully populated.

PR:		264521
Reported by:	Robert Morris <[email protected]>
Reviewed by:	mav, emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36271

(cherry picked from commit bb31aee26b)
2022-11-10 17:13:19 -08:00
John Baldwin ffbe54c217 bhyve virtio-scsi: Tidy warning and debug prints.
Use a consistent prefix ("virtio-scsi: ") similar to the e1000 device
model.

Reviewed by:	mav, emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36270

(cherry picked from commit 62806a7f31)
2022-11-10 17:13:13 -08:00
John Baldwin 93eafd4479 bhyve e1000: Sanitize transmit ring indices.
When preparing to transmit pending packets, ensure that the head (TDH)
and tail (TDT) indices are in bounds.  Note that validating values
when they are written is not sufficient along as the transmit length
(TDLEN) could be changed turning a value that was valid when written
into an out of bounds value.

While here, add further restrictions to the head register (TDH).  The
manual states that writing to this value while transmit is enabled can
cause unexpected behavior and that it should only be written after a
reset.  As such, ignore attempts to write while transmit is active,
and also ignore writes of non-zero values.  Later e1000 chipsets have
this register as read-only.

Also ignore any attempts to transmit packets if the transmit ring's
size is zero.

PR:		264567
Reported by:	Robert Morris <[email protected]>
Reviewed by:	emaste
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36269

(cherry picked from commit 7afe342dcb)
2022-11-10 17:10:45 -08:00
liu-du 2abbb9dd78 xargs: fix exit code when using -P
currently when xargs runs in parallel mode (e.g. -P2), it somtimes
incorrectly returns zero exit code.  this commit fix it and also adds
tests.

Reviewed by:	mjg
PR:	267110

(cherry picked from commit 0ca740d9a6)
2022-11-10 22:45:24 +00:00
Richard Scheffenegger 9839a5ad3a ipfw: Have NAT steal the TH_RES1 bit, instead of the TH_AE bit
The NAT module use of the tcphdr.th_x2 field now collides with the
use of this TCP header flag as AccECN (AE) bit. Use the topmost
bit instead to allow negotiation of AccECN across a NAT device.

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

(cherry picked from commit 0b00b80149)
2022-11-09 23:33:41 +01:00
Gordon Bergling d96d13cfa5 intro.3: Document 'libstdthreads' (the ISO C11 '<threads.h>' library).
It's still relatively uncommon to see C11 '<threads.h>' being used,
but it's worth documenting, especially since FreeBSD requires a
different library for C11 threads  compared to glibc (part of '-lpthread')
or musl libc  (included by default).

PR:	267551
Submitted by:	Alois Klink <alois plus freebsd at aloisklink dot com>
Reviewed by:	pauamma
Differential Revision:	https://reviews.freebsd.org/D37284

(cherry picked from commit 8a220816c7)
2022-11-10 07:09:32 +01:00
Edward Tomasz Napierala 8a564a3194 intro(3): Fix formatting
This makes the left column narrower, leaving more space for the text.

Reviewed By:	debdrup, 0mp
Differential Revision:	https://reviews.freebsd.org/D33385

(cherry picked from commit e522571b79)
2022-11-10 07:09:14 +01:00
Johannes Totz 11358dec2d re.4: Mention vendor driver for if_re(4)
If this if_re(4) is causing problems then an updated driver from
the vendor can be found in the ports tree under net/realtek-re-kmod.

Reviewed by:	debdrup, koobs, emaste
Differential Revision:	https://reviews.freebsd.org/D33677

(cherry picked from commit a9a35c9e35)
2022-11-10 07:06:37 +01:00
Kristof Provost 3ef5d1f82c bridge tests: re-enable span test
The root cause of the intermittent span test failures has been
identified as a race between sending the packet and starting the bpf
capture.
This is now resolved, so the test can be re-enabled.

PR:		260461
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit e1274b5b26)
2022-11-09 09:17:08 +01:00
Kristof Provost 97967fc8e6 tests: make sniffer more robust
The Sniffer class is often used by test tools such as pft_ping to verify
that packets actually get sent where they're expected.

It starts a background thread to capture packets, but this thread needs
some time to start, leading to intermittent test failures when the
capture doesn't start before the relevant packet is sent.

Add a semaphore to ensure the Sniffer constructor doesn't return until
the capture is actually running.

PR:		260461
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 67557372df)
2022-11-09 09:16:57 +01:00
Kristof Provost f2a6d07a4e netgraph/ng_bridge: add missing array terminator
PR:		267457
Reported by:	Robert Morris <[email protected]>
MFC after:	1 week

(cherry picked from commit 23559c9d0d)
2022-11-08 13:43:45 +01:00
Gordon Bergling 902fd6fd5e smartpqi(4): Fix two typos in kernel error messages
- s/runnning/running/

(cherry picked from commit d53e97bb54)
2022-11-08 08:06:50 +01:00
Pau Amma a9bcf856df Make SYNOPSIS match DESCRIPTION.
While there, fix nits reported by igor and mandoc -T lint.

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

Reviewed by:	debdrup, gbe, gjb

Approved by:	gjb (mentor)

MFC after:	3 days

(cherry picked from commit 5cc5c9254d)
2022-11-08 05:06:03 +01:00
Ed Maste a841c0c240 ssh: correct parse_cert_times case for hex "to" time
This appeared to be a copy-paste error from the "from" time case above.

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

(cherry picked from commit 0657b2325d)
(cherry picked from commit 4718d86b3b)
2022-11-06 09:20:04 -05:00
Gordon Bergling 7763610055 tee.1: Add a HISTORY section
The most accurate information I have found is that
tee(1) first appeared in Version 7 AT&T UNIX.

Reviewed by:	pauamma
Differential Revision:	https://reviews.freebsd.org/D37206

(cherry picked from commit 514df63539)
2022-11-06 09:00:22 +01:00
Mateusz Piotrowski 00b6644ab5 tee.1: Add a missing article
(cherry picked from commit 9ec571021d)
2022-11-06 08:59:32 +01:00
Fernando Apesteguía 120e13d6c7 tee(1): Add EXAMPLES section
Add one simple example

Approved by:	bcr@
Differential Revision:	https://reviews.freebsd.org/D25337

(cherry picked from commit fcc879ad25)
2022-11-06 08:59:06 +01:00
Fernando Apesteguía 251ae6c761 tee(1): Add EXAMPLES section
Probably the simplest one ever.

Approved by:	gbe@, 0mp@
Differential Revision:	https://reviews.freebsd.org/D25206

(cherry picked from commit d70bfedd08)
2022-11-06 08:58:35 +01:00
Zhenlei Huang 639aebb2aa if_vxlan(4): Check the size of data available in mbuf before using them
PR:		261711
Reviewed by:	kp
Tested by:	Alfa (burak.sn at outlook.com)
Approved by:	kp (mentor)
Differential Revision:	https://reviews.freebsd.org/D36794

(cherry picked from commit 8707cb19e6)
2022-11-04 18:57:23 +08:00
Gordon Bergling fb7823f55c xilinx: Fix a typo in a source code comment
- s/interrut/interrupt/

(cherry picked from commit 34fcce0087)
2022-11-04 06:07:30 +01:00
Gordon Bergling 00d6089a7b isci(4): Fix a typo in a source code comment
- s/interrutp/interrupt/

(cherry picked from commit 5014dc958f)
2022-11-04 06:07:20 +01:00
Gordon Bergling 4598cbd8dd isci(4): Fix common typos in source code comments
- s/assinged/assigned/

(cherry picked from commit 816d5c1e98)
2022-11-04 06:07:10 +01:00
Gordon Bergling e2d9e51c4b bxe(4): Fix a typo in a source code comment
- s/interrutps/interrupts/

(cherry picked from commit e902e62644)
2022-11-04 06:07:01 +01:00
Piotr Kubaj a43afddd43 ofed: allow using IPv6 address in rc_pingpong server
Summary:
The current OFED code allows binding server to IPv6 address. It was added back in https://github.com/linux-rdma/rdma-core/commit/91fc39561d04903cd5b1665d9215a184baa66ba9

Sponsored by:	Intel Corporation
MFC after:	3 days

Reviewers: hselasky

Subscribers: imp

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

(cherry picked from commit 35c87c070a)
(cherry picked from commit a8c06a9de0)
2022-11-02 17:35:40 +01:00
Dag-Erling Smørgrav 4ea49af3af sh: read more profile files.
Differential Revision: https://reviews.freebsd.org/D36505
MFC after:	1 month

(cherry picked from commit 497cdf9673)

sh: when loading profile, skip obvious scratch files.

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

(cherry picked from commit d3890a547d)

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

Reviewers: jilles, eugen_grosbein.net, cy

Subscribers: imp

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

(cherry picked from commit 8d7221ca2d)
2022-11-02 13:42:02 +01:00
Gordon Bergling 157983169e net8021: Fix a typo in a kernel error message
- s/missmatch/mismatch/

(cherry picked from commit 156ce1e51c)
2022-11-01 07:03:46 +01:00
Gordon Bergling ab8d31d7ee dconschat(8): Fix a typo in an error message
- s/faild/failed/

(cherry picked from commit 7bef61eef3)
2022-11-01 07:03:36 +01:00
Gordon Bergling 0bca01eae7 zfsd(8): Fix a typo in an error message
- s/faild/failed/

(cherry picked from commit 4bd5e6221e)
2022-11-01 07:03:26 +01:00
Philip Paeps 6f2acba996 contrib/tzdata: import tzdata 2022f
Changes: https://github.com/eggert/tz/blob/2022f/NEWS

(cherry picked from commit 9142a2a37b)
2022-11-01 09:07:17 +08:00
Cy Schubert 7f742baa9e unbound: Reapply Vendor import 1.17.0
Reapply 643f9a0581. 64d318ea98 was a
mismerge during fake rebase. Let's reapply it.

Changes include: Added ACL per interface, proxy protocol and bug fixes.

Announcement:   https://nlnetlabs.nl/news/2022/Oct/13/unbound-1.17.0-released/

Merge commit '643f9a0581e8aac7eb790ced1164748939829826' into main

(cherry picked from commit 865f46b255)
2022-10-31 16:24:21 -07:00
Kirk McKusick b06a5f6f5e Add a description of soft updates journaling to newfs(8).
Requested by: Graham Perrin
PR:           261944
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 0929a153fc)
2022-10-30 20:53:19 -07:00
Kirk McKusick 1639fa2cd5 Update date in tunefs(8) manual page.
PR:           261944
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 128b0398a1)
2022-10-30 20:50:07 -07:00
Kirk McKusick de1f80e4c1 Add a description of soft updates journaling to tunefs(8).
Requested by: Graham Perrin
PR:           261944
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 82493ff700)
2022-10-30 20:49:17 -07:00
Xin LI 0e0f48e453 file: fix test case for gpkg by removing the extra \n.
(cherry picked from commit c5e957ad4f)
2022-10-29 21:44:32 -07:00
Xin LI 97a6bb4a3f MFV: Restore the ability to process files from stdin immediately.
PR:		bin/267221

(cherry picked from commit 07dfb236c8)
2022-10-29 21:42:45 -07:00
Gordon Bergling ae3b32779b ocs_fc(4): Fix a typo in an error message
- s/faild/failed/

(cherry picked from commit dabebd0ba2)
2022-10-30 04:41:56 +01:00
Gordon Bergling 649524301d firewire(4): Fix a typo in an error message
- s/faild/failed/

(cherry picked from commit c03e35accc)
2022-10-30 04:41:46 +01:00
Gordon Bergling 85c519385c qlnxe(4): Fix a typo in a source code comment
- s/defult/default/

(cherry picked from commit 5daf88ea5e)
2022-10-29 07:05:16 +02:00
Ed Maste 7dfe3b0981 sendmail: fix auth with cyrus-sasl-2.1.28
Apply patch extracted from sendmail-8-17.1.9 snapshot by dinoex@.

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

(cherry picked from commit c898b54aff)
(cherry picked from commit 2123b467b4)
2022-10-28 21:46:12 -04:00
Gordon Bergling 258e9dcf53 run.4: Fix a typo in the DIAGNOSTICS section
- s/faild/failed/

(cherry picked from commit 1cc4c2f90f)
2022-10-28 10:59:28 +02:00
Gordon Bergling 0b3e2585dc netpfil: Fix two typos in source code comments
- s/missmatch/mismatch/

(cherry picked from commit 558ec54da3)
2022-10-28 10:59:17 +02:00
Gordon Bergling 50006d5205 CMSG_DATA.3: Fix a typo in the EXAMPLES section
- s/faild/failed/

(cherry picked from commit 31c472b8a6)
2022-10-28 10:59:05 +02:00
Gordon Bergling 3e2704c8ee netmap(4): Fix a typo in a source code comment
- s/microsconds/microseconds/

(cherry picked from commit 8ba2beacfd)
2022-10-28 10:58:52 +02:00
Gordon Bergling 5f88cea99d arcmsr(4): Fix a typo in a source code comment
- s/faild/failed/

(cherry picked from commit 24a630de81)
2022-10-28 10:58:41 +02:00
Sergey A. Osokin fc46468995 bsd-family-tree: OpenBSD 7.2 and DragonFly BSD 6.0.1
Add two releases to the tree.

While I'm here correct DragonFly BSD 6.2.1 position, it's
been released after FreeBSD 12.3.

MFC after:	3 days

(cherry picked from commit 7322a6bcac)
2022-10-27 11:52:44 -04:00
Ed Maste 2b25564af6 OpenBSM: fix free() in au_read_rec error case
buf is a char ** and *buf is the allocated buffer.

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

(cherry picked from commit c61b3f7de9)
(cherry picked from commit 889dcb5e9b)
2022-10-26 20:25:33 -04:00
Ed Maste 4aee71578a ssh: update to OpenSSH 9.1p1
Release notes are available at https://www.openssh.com/txt/release-9.1

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

Some highlights copied from the release notes:

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

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

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

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

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

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

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

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

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

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

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

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

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

(cherry picked from commit 38a52bd3b5)
(cherry picked from commit ac5c465b9fdff74d1a73f63d157820887ff1787f)
2022-10-26 12:47:14 -04:00
Mitchell Horne 0f7f0ed943 getpagesize(3): cross-reference getpagesizes(3)
MFC after:	3 days

(cherry picked from commit 4a9b1a1463)
2022-10-24 12:56:13 -03:00
Ali Abdallah a55b3c12a8 ksched: correct return code for invalid priority
By convention, EINVAL is returned when validating arguments, not EPERM.
This matches the documented behaviour of sched_setscheduler(3), and that
of SCHED_OTHER.

PR:		227735
MFC after:	1 week
Reviewed by:	kib, markj
Differential Revision:	https://reviews.freebsd.org/D37021

(cherry picked from commit ba4782022a)
2022-10-24 12:56:13 -03:00
Mitchell Horne f18e56c17a pthread_setschedparam(3): document EPERM return
In kern_sched_setparam(), before setting any parameters, p_cansched() is
called to check that the thread has appropriate privileges.

PR:		175687
Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D37020

(cherry picked from commit 04620006b9)
2022-10-24 12:56:13 -03:00
Sreekanth Reddy 959c2e5a52 mpr(4): Add Aero/Sea devices to supported hardware list
Add Aero/Sea devices to supported hardware list in mpr man page.

PR:		267172
MFC after:	3 days

(cherry picked from commit 751ec8af5e)
2022-10-22 16:14:26 +08:00
Glen Barber 6a9031c5e2 Rename to STABLE and bump __FreeBSD_version
Approved by:	re (implicit)
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-10-20 13:57:27 -04:00
3582 changed files with 187468 additions and 124602 deletions

No files matched your search

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