| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
| |
This enables additional searching the manual by sysctl variable.
This syntax is standardized in style.mdoc(5).
Reported by: bapt
MFC after: 3 days
(cherry picked from commit 75866d71e8d93fe1a1ff469b8a9c6c6c9908a6c8)
|
| |
|
|
|
|
|
|
|
|
|
| |
Mainly, avoid reusing the name of one of the functions we should be
testing (but aren't) for local variables.
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D55054
(cherry picked from commit d70b9eb74fc4aa430bd2ff4bca37e6a9b6c8004f)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
POSIX states that dirfd() should set errno to EINVAL and return -1 if
dirp does not refer to a valid directory stream. Our interpretation is
that this applies if dirp is null or the file descriptor associated
with it is negative.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D55025
(cherry picked from commit 5074d5c9845e142883cdbb9ad212be66e57615d0)
libc: Fix missing include
Although not needed on FreeBSD due to namespace pollution, we should
technically #include <stddef.h> to secure a definition of NULL.
Fixes: 5074d5c9845e ("libc: Improve POSIX conformance of dirfd()")
(cherry picked from commit 1c00d5a3b234ef937d848956027e9de5ea8010f9)
|
| |
|
|
|
|
|
|
|
|
|
| |
Fix style nits (mostly whitespace issues) and clean up the manual page.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D55024
(cherry picked from commit 387ae6390534b6e9b48931840e7bc76eeb0b258d)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Use either size_t or off_t (as appropriate) instead of long.
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D51210
(cherry picked from commit 42e613018da50ee6877d24815c7626d79629e707)
readdir: Fix error check.
Now that dd_size is unsigned, we need to check if the return value from
getdirentries() was negative before assigning it to dd_size.
While here, simplify the scandir_error test case slightly, and verify
that calling readdir() again after EOF still returns NULL.
Fixes: 42e613018da5
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D51266
(cherry picked from commit 920b2183919e430cf85c4aa1fa337bfded12aee5)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Add test cases for opendir() and fdopendir().
* Drop O_NONBLOCK from opendir(); it was added a long time ago to avoid
blocking if given a closed named pipe, but now we use O_DIRECTORY,
which ensures that we get ENOTDIR in that case.
* While here, remove unused #includes left over from the split.
Sponsored by: Klara, Inc.
Reviewed by: kevans, markj
Differential Revision: https://reviews.freebsd.org/D51126
(cherry picked from commit c08e019c6ce4fc637b195f1bb0878763c3fefe9e)
|
| |
|
|
|
|
|
|
| |
Sponsored by: Klara, Inc.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D51118
(cherry picked from commit 5e96f4006d2e5f165531a53b6c1393a1c7604f42)
|
| |
|
|
|
|
|
|
| |
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D51050
(cherry picked from commit 8ebc0768663b0ea9f78a0b8cffb93ee1684a9b08)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently, if `readdir()` fails, `scandir()` simply returns a partial
result (or a null result if it fails before any entries were selected).
There is no way within the current API design to return both a partial
result and an error indicator, so err on the side of caution: if an
error occurs, discard any partial result and return the error instead.
MFC after: 1 week
Reported by: Maxim Suhanov <dfirblog@gmail.com>
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D51046
(cherry picked from commit 62e0f12f5104585b7346fee183e5c667b39ddbad)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This seems to fit the pattern better (e.g. fdopendir()).
I've added weak references to ease the transition, but since it's only
been a few days, we can remove them (and the ObsoleteFiles entries for
the manual pages) before we branch stable/15.
Fixes: deeebfdecab5
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D50980
(cherry picked from commit 0a5b763d98b921f921243525ff25a70bbe00cfaa)
libc: Finish removing fscandir{,_b}().
These only existed for a few days before being renamed, so there's no
reason to continue to carry compatibility shims for them.
Fixes: deeebfdecab5
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D50981
(cherry picked from commit ccf937320a1a7383a2c33698007b7244f66dc022)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
In the previous commit, I removed the initial initialization of the
`names` array, not realizing that `scandir()` is expected to return
a non-null (but empty) array of entries if no entries matched.
Restore the historical behavior, document it, and add a test.
Fixes: deeebfdecab5
Sponsored by: Klara, Inc.
Reviewed by: kevans, allanjude, markj
Differential Revision: https://reviews.freebsd.org/D50949
(cherry picked from commit c187b673bb79905b5d5db1eb34d5a893c4464eeb)
|
| |
|
|
|
|
|
|
|
|
|
| |
While here, clean up scandir() a bit and improve the documentation.
MFC after: never
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D50935
(cherry picked from commit deeebfdecab56729fa898271ae53d01c8e156302)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If no resolver configuration was found, we would fall back to INADDR_ANY
and IN6ADDR_ANY. This made sense when it was first written thirty or
forty years ago but not today, especially since connecting to INADDR_ANY
or IN6ADDR_ANY is no longer supported. Switch to the loopback address
and simplify the code.
Note that (as the pre-existing comment in the code states) running
without a resolver configuration is not really supported. Still, if
we're going to have a hardcoded fallback, it might as well work.
PR: 291790
MFC after: 1 week
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D55011
(cherry picked from commit 1538284a5fddfce546db678cb873b7edc6adb9ed)
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
To facilitate comparison with mtree -C generated output, keep the
keywords ordered.
No functional change intended.
Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D54872
(cherry picked from commit fe962e33d86f888b496b17251c8bedebf92be8ee)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If net is all-zero, the loop to extract all leading non-zero octets will
iterate zero times and leave nn with the value 4, which the following
switch statement to initialise qbuf does not handle. As a result,
_dns_getnetbyaddr will look up the PTR record for this uninitialised
string, which will leak the pre-existing contents of that stack memory
to the DNS resolver and, if remote and not otherwise protected, network.
Note that _dns_getnetbyaddr is only used if nsswitch.conf is configured
to enable the "dns" source for the "networks" database, which is not the
default configuration in FreeBSD.
For glibc this same bug, in code also derived from BIND's, was issued
CVE-2026-0915. This commit adopts the same behaviour as glibc's fix,
which is to regard a net of 0 as being for 0.0.0.0. Apparently NetBSD
will return NS_UNAVAIL instead, which may or may not make more sense,
but in general glibc compatibility tends to cause less friction when
there's not a good reason to avoid it.
Reviewed by: markj (secteam)
Fixes: 1363f04ce1b8 ("get* rework and new bind code")
MFC after: 1 day
Security: Same bug as glibc's CVE-2026-0915
(cherry picked from commit 331316b073505e4794754af1cd0c5ccc578a2bde)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We don't support CPU hotplug, but we do support cpuset(8) restrictions
on jails (including prison0, which uses cpuset 1). The process cannot
widen its cpuset beyond its root set, so it makes sense to instead
report the number of cpus enabled there rather than the total number
in the system.
This change is effectively a nop for the majority of systems and jails
in the wild, though it does reduce the performance of this query now
that we can't take advantage of AT_NCPUS being provided in the auxinfo.
The implementation here is notably different than Linux, which would not
take cgroups into account. They do, however, take CPU hotplug into
account, so the possibility for it to diverge from (and be lower than)
the # configured count to reflect what the process can actually be
scheduled on doesn't really diverge in semantics.
Reviewed by: kib
(cherry picked from commit d617806aac1469319970e3551656e9deabb98a35)
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
mac_text(3) as-written would seem to indicate that a `mac_t` should be
freed with free(3), but this isn't the case. One can derive from
context from when the change was introduced and COMPATIBILITY that this
was intended to talk about *text in `mac_to_text`, so move the comment
there.
PR: 179832
Co-authored-by: Priit Järv <priit cc ttu ee>
(cherry picked from commit 081218b7a2006e5b6783e51f66fd751871ac1272)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The previous fix introduced a regression on machines without the BMI1
instruction set extension. The TZCNT instruction used in this function
behaves different on old machines when the source operand is zero, but
the code was originally designed to never trigger this case. The bug
fix caused this case to be possible, leading to a regression on
sufficiently old hardware.
Fix the code by messing with things such that the source operand is
never zero.
PR: 291720
Fixes: 66eb78377bf109af1d9e25626bf254b4369436ec
Tested by: cy
Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D54303
(cherry picked from commit 2f83319214d9adb8ab7a77e35d1014658b3f9cae)
|
| |
|
|
|
|
|
|
|
|
| |
This implementation appears to be broken on some CPUs. Disable it
until the issue can be investigated and fixed.
PR: 291720
Fixes: 66eb78377bf1 ("libc/amd64: fix overread conditions in stpncpy()")
Fixes: 90253d49db09 ("lib/libc/amd64/string: add stpncpy scalar, baseline implementation")
(cherry picked from commit ce9557d4ee174267504a63b2c8f6009be27368c9)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Due to incorrect unit test design, two overread conditions went
undetected in the amd64 baseline stpncpy() implementation.
For buffers of 1--16 and 32 bytes that do not contain nul bytes
and end exactly at a page boundary, the code would incorrectly
read 16 bytes from the next page, possibly crossing into an
unmapped page and crashing the program. If the next page was
mapped, the code would then proceed with the expected behaviour
of the stpncpy() function.
Three changes were made to fix the bug:
- an off-by-one error is fixed in the code deciding whether to
enter the runt case or not, entering it for 0<n<=32 bytes
instead of 0<n<32 bytes as it was before.
- in the runt case, the logic to skip reading a second 16-byte
chunk if the buffer ends in the first chunk was fixed to
account for buffers that end at a 16-byte boundary but do not
hold a nul byte.
- in the runt case, the logic to transform the location of the
end of the input buffer into a bit mask was fixed to allow
the case of n==32, which was previously impossible due to the
incorrect logic for entering said case.
The performance impact should be minimal.
PR: 291359
See also: D54169
Reported by: Collin Funk <collin.funk1@gmail.com>
Reviewed by: getz
Approved by: markj (mentor)
MFC after: 1 week
Fixes: 90253d49db09a9b1490c448d05314f3e4bbfa468 (D42519)
Differential Revision: https://reviews.freebsd.org/D54170
(cherry picked from commit 66eb78377bf109af1d9e25626bf254b4369436ec)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The test is extended the same way I previously extended the memccpy()
test to fix what is probably the same kind of bug.
PR: 291359
Reported by: Collin Funk <collin.funk1@gmail.com>
Reviewed by: ngie
Approved by: markj (mentor)
Fixes: 6fa9e7d8737548ef93c573387ce62402c368d486 (D42519)
See also: 61ed5748e4e9c7397fcb2638b442f46ac5c9e7c5 (D46051)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D54169
lib/libc/tests/string/stpncpy_test.c: apply ngie's fixes
(cherry picked from commit 123c086200491819595abc271d360e605288fd18)
(cherry picked from commit 8be8642826099368208efb2c1222f2a102cc5b08)
|
| |
|
|
|
|
|
|
|
|
|
|
| |
ioctls can fail with EACCES, see sys/kern/tty.c
PR: 239504
MFC after: 3 days
Reviewed by: ziaee
Reported by: Brennan Vincent <brennan@umanwizard.com>
Differential Revision: https://reviews.freebsd.org/D49072
(cherry picked from commit e2afbc45258f2fa4bdcf126e959ac660e76fc802)
|
| |
|
|
| |
(cherry picked from commit a98e5d78500193dc7aa352e1f60ac2c6529e2c38)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The offset here is relative to the TCB, not whatever the thread pointer
points to, so as with powerpc and powerpc64 we need to account for that.
However, rather than using hard-coded offsets as they did, due to
predating machine/tls.h, we can just re-use _tcb_get().
Note that if libthr is used, and its initialiser has been called, it
will take a different path that uses _get_static_tls_base, which works
just fine on riscv (adding the offset to thr->tcb). This only affects
programs that aren't linked against libthr (or that are but manage to
dlopen before the initialiser is called, if that's even possible).
In future this code should be made MI by just reusing _tcb_get() and
checking the TLS variant (since the offset here is positive even for
variant II, where it should be subtracted), but this is a targeted fix
that makes it clear what's changing.
Reviewed by: kib
Fixes: 5d00c5a6571c ("Fix initial exec TLS mode for dynamically loaded shared objects.")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D50564
(cherry picked from commit 0e3dbc64d9f6c95cbb16dba60a32136ae116dada)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The implementation of dl_iterate_phdr for statically-linked binaries
abuses __tls_get_addr to get to the start of the TLS block. For most
architectures, tls_index's ti_offset (relocated by DTPOFF/DTPREL for GOT
entries) is just the offset within that module's TLS block. However, for
PowerPC and RISC-V, which have a non-zero TLS_DTV_OFFSET and thus are
designed assuming DTV entries are biased by that value, ti_offset
normally has TLS_DTV_OFFSET pre-subtracted. By using an offset of zero
here we end up getting a pointer TLS_DTV_OFFSET past what __tls_get_addr
would return for the first TLS variable.
Fix this by using -TLS_DTV_OFFSET to mirror what the General Dynamic GOT
entry for the first TLS variable would be.
(Note this also applies to MIPS on stable/13)
Reviewed by: kib
Fixes: dbd2053026a6 ("libc dl_iterate_phdr(): dlpi_tls_data is wrong")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D50182
(cherry picked from commit 78b99f369f75f5df49b506ae750659b07ab34362)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
PowerPC and RISC-V have a non-zero TLS_DTV_OFFSET. The intent behind
this in the design is that DTV entries are biased by this, as are (in
the other direction) the DTPOFF/DTPREL entries in the GOT. However, this
is pretty pointless in practice, and both FreeBSD and glibc's run-time
linkers don't bother to bias DTV entries, instead just adding the bias
back on at the end in __tls_get_addr. In libc we also have a minimal
implementation of this for statically-linked binaries, which is only in
practice used for code compiled with -fPIC (not -fPIE) that is also
linked without TLS relaxation support. PowerPC supports linker
relaxation for TLS sequences, so this likely never gets hit there, but
RISC-V does not, and so easily does if you compile an executable with
-fPIC. In this implementation we add TLS_DTV_OFFSET both to the DTV
entries in __libc_allocate_tls and to the result of __tls_get_addr,
meaning that any TLS accesses using the General Dynamic model in static
binaries on RISC-V end up off by 0x800.
Historically this also did not matter as __tls_get_addr was a stub that
always returned NULL, so although 6e16d0bc4376 ("Rework alignment
handling in __libc_allocate_tls() for Variant I of TLS layout.") added
this DTV implementation, nothing actually read the entries. However, now
it's a real implementation, and dl_iterate_phdr also now relies on it,
it does matter.
Fix this by not biasing the DTV entries, just like RTLD. We could
instead stop adding TLS_DTV_OFFSET in __tls_get_addr, but being
consistent between libc and RTLD seems better.
(Note this also applies to MIPS on stable/13)
Reviewed by: kib
Fixes: ca46b5698e8a ("libc: implement __tls_get_addr() for static binaries")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D50181
(cherry picked from commit d04c93a2adccb4c3a17f7391126a9246326e3fea)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Some architectures don't need any arguments, whilst others need auxargs,
which they get by passing in env thanks to INIT_RELOCS referencing the
local variable in __libc_start1(_gcrt) by name. This is unnecessarily
confusing, fragile (one has to look at INIT_IRELOCS's definition to see
that it uses env) and duplicates code between architectures.
Instead, implement it more like rtld-elf. Each architecture provides an
ifunc_init that takes the auxargs directly, and those that don't need it
can just ignore it.
Reviewed by: kib
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D47188
(cherry picked from commit 9684658e35ab033c79e0519e3681d9a194976b71)
|
| |
|
|
|
|
|
|
|
|
| |
When adding support to rtld-elf I neglected the fact that static
binaries can have IFUNCs. Add support for this too.
Fixes: 729d2b16b74f ("rtld-elf: Support IFUNCs on riscv")
MFC after: 1 week
(cherry picked from commit 1363acbf25de4c36e183cfa0b0e801d4dd9bf2ad)
|
| |
|
|
|
|
|
|
|
| |
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: fuz
Differential Revision: https://reviews.freebsd.org/D53908
(cherry picked from commit 5af240c54bd2d9548536c904e841499e1651bcc8)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If the locale's positive_sign and negative_sign values would both be
returned by localeconv() as empty strings, strfmon() shall behave as if
the negative_sign value was the string "-".
This occurs with the C locale. The implementation previously assigned
"0" to sign_posn (parentheses around the entire string); now it assigns
it to "1" (sign before the string) when it is undefined (CHAR_MAX).
Austin Group Defect 1199[1] is applied, changing the requirements for
the '+' and '(' flags.
[1]: https://www.austingroupbugs.net/view.php?id=1199
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D53913
(cherry picked from commit cf85e7034ad5640b18a3b68d6b291b7bf89bfc80)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
According to the Open Group Base Specifications Issue 8[1], strfmon(3)
should return EINVAL when the '+' flag was included in a conversion
specification and the locale's positive_sign and negative_sign values
would both be returned by localeconv(3) as empty strings.
Austin Group Defect 1199[2] is applied, adding the [EINVAL] error.
[1]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/strfmon.html
[2]: https://www.austingroupbugs.net/view.php?id=1199
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D53912
(cherry picked from commit 1fd018972a18b682521bb8f004dfd162327e5db2)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Add tests for The Open Group Base Specifications Issue 8[1], Austin
Group Defect 1199[2].
Items marked with XXX represent an invalid output. These items will be
fixed in subsequent commits.
Notice that an existing test is now considered invalid.
Our locale definitions do not include int_p_sep_by_space nor
int_n_sep_by_space[3]. Those will be addressed in a subsequent commit.
However, the CLDR project defines them as "0", which causes the output
to appear as "USD123.45". If our locale definitions were to set the
international {n,p}_sep_by_space to "1", the output would display as the
expected "USD 123.45".
While here, use the SPDX license identifier and add my name to the
file.
[1]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/strfmon.html
[2]: https://www.austingroupbugs.net/view.php?id=1199
[3]: https://unicode-org.atlassian.net/browse/CLDR-237
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D53911
(cherry picked from commit 19e153004fb63c32eba0ef40249f5ede61a93170)
|
| |
|
|
|
|
| |
MFC after: 1 week
(cherry picked from commit 91e7f19ec4056587a85c1461a4f34a6d5d4b7b52)
|
| |
|
|
|
|
| |
- s/cacheing/caching/
(cherry picked from commit d76ea20f99965e8f3b9dbfcb41ca148711d528bb)
|
| |
|
|
|
|
| |
- s/avaliable/available/
(cherry picked from commit 9334fa3ef5e19de7d3dcdbefdaa3f6b6b653475a)
|
| |
|
|
|
|
| |
fchroot does not exist in stable/14.
Sponsored by: The FreeBSD Foundation
|
| |
|
|
|
|
|
|
| |
PR: 286064
MFC after: 3 days
Reviewed by: mckusick
(cherry picked from commit 26069bca2d64a76cfafb92d61d58c90140c1b28f)
|
| |
|
|
|
|
|
|
| |
Block devices are a thing of a past in FreeBSD.
Reviewed by: ziaee
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D53332
|
| |
|
|
| |
(cherry picked from commit 1c8d7bb4cf7a6b19262333b2a9b1dacf3094b938)
|
| |
|
|
|
|
|
|
| |
MFC after: 3 days
Reviewed by: ziaee
Differential Revision: https://reviews.freebsd.org/D53411
(cherry picked from commit cb1315c15acf7d3fae66b2c5631e076776683f96)
|
| |
|
|
|
|
| |
Fix an accidentally committed merge left over.
Fixes: 38a172d3c6b7 ("ffs.3: Add a STANDARDS section to the manual page")
|
| |
|
|
|
|
|
|
|
|
| |
The ffs() function conforms to IEEE Std 1003.1-2008 ("POSIX.1").
The ffsl() and ffsll() functions conform to IEEE Std 1003.1-2024 ("POSIX.1").
Reviewed by: ziaee
Differential Revision: https://reviews.freebsd.org/D53352
(cherry picked from commit f1cb4e9962d715ec85ba26d7019ab83adea1ffb7)
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Add 14.2, as this was cherry-picked prior to release.
Reported by: Harald Eilertsen
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53320
(cherry picked from commit 2387a51af235e4304c63f95465a569c878f49dcd)
(cherry picked from commit 87795ea45407355de4e36388ed6c02ef70b9241a)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Our versions of these functions (originally taken from BIND) simply
don't work correctly for AF_INET6. These were removed from BIND itself
quite a while ago, but OpenBSD has made several fixes in the mean time,
so import their code.
Add tests for both functions.
PR: 289198
Reported by: Nico Sonack <nsonack@herrhotzenplotz.de>
MFC after: 1 week
Reviewed by: des
Obtained from: OpenBSD (lib/libc/net)
Sponsored by: https://www.patreon.com/bsdivy
Differential Revision: https://reviews.freebsd.org/D52629
(cherry picked from commit 8f4a0d2f7b96099001dbc51e06114df1a0e6d291)
inet_net_test: Compare pointers against nullptr
GCC does not like passing NULL (__null) to std::ostringstream::operator<<
inside of ATF_REQUIRE_EQ:
lib/libc/tests/net/inet_net_test.cc: In member function 'virtual void {anonymous}::atfu_tc_inet_net_ntop_invalid::body() const':
lib/libc/tests/net/inet_net_test.cc:306:9: error: passing NULL to non-pointer argument 1 of 'std::__1::basic_ostream<_CharT, _Traits>& std::__1::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::__1::char_traits<char>]' [-Werror=conversion-null]
306 | ATF_REQUIRE_EQ(ret, NULL);
| ^~~~~~~~~~~~~~
In file included from /usr/obj/.../amd64.amd64/tmp/usr/include/c++/v1/sstream:317,
from /usr/obj/.../amd64.amd64/tmp/usr/include/atf-c++/macros.hpp:29,
from /usr/obj/.../amd64.amd64/tmp/usr/include/atf-c++.hpp:29,
from lib/libc/tests/net/inet_net_test.cc:33:
/usr/obj/.../amd64.amd64/tmp/usr/include/c++/v1/__ostream/basic_ostream.h:338:81: note: declared here
338 | basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long __n) {
| ~~~~~^~~
...
Fixes: 8f4a0d2f7b96 ("libc: Import OpenBSD's inet_net_{ntop,pton}")
(cherry picked from commit aa358ce3ca8e1fcfb305025fd00beb2a119c7c77)
inet_net_test: Use int to hold expected return values from inet_net_pton
GCC warns about the sign mismatch in comparisons:
lib/libc/tests/net/inet_net_test.cc: In member function 'virtual void {anonymous}::atfu_tc_inet_net_inet4::body() const':
lib/libc/tests/net/inet_net_test.cc:86:17: error: comparison of integer expressions of different signedness: 'int' and 'const unsigned int' [-Werror=sign-compare]
86 | ATF_REQUIRE_EQ(bits, addr.bits);
| ^~~~~~~~~~~~~~
lib/libc/tests/net/inet_net_test.cc: In member function 'virtual void {anonymous}::atfu_tc_inet_net_inet6::body() const':
lib/libc/tests/net/inet_net_test.cc:205:17: error: comparison of integer expressions of different signedness: 'int' and 'const unsigned int' [-Werror=sign-compare]
205 | ATF_REQUIRE_EQ(bits, addr.bits);
| ^~~~~~~~~~~~~~
Fixes: 8f4a0d2f7b96 ("libc: Import OpenBSD's inet_net_{ntop,pton}")
(cherry picked from commit e1aeb58cbbc3839db93ec38ce491b7b9383d5649)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
ISO 8601 allows use of "Z" as the time zone designator. Update the
strptime parser to allow this usage.
While we are at it, update the manpage to reflect that both UTC and Z
are now valid options.
Reviewed by: des
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D53083
(cherry picked from commit 79e57ea662d92ffcbe7d65854a284aefac6a332d)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Commit a34940a9756a ("timezone: Move to the XSI/POSIX definition for
timezone") was not merged to stable/14. The MFC of 29810aa6ae70
("libc: Move tzset.3 to stdtime") didn't take this into account and
ended up installing two different versions of timezone.3 over top of
each other.
This is a direcct commit to stable/14 as the issue is not present in
main. If a34940a9756a gets merged in the future the reverted part of
29810aa6ae70 will need to be reapplied.
Fixes: 29810aa6ae70 ("libc: Move tzset.3 to stdtime")
Sponsored by: The FreeBSD Foundation
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
We've been mostly POSIX-conforming since r236400 and fully since r240410,
which fixed a corner case where a missing non-leaf directory would be
reported as ENOTDIR instead of ENOENT.
Sponsored by: Klara, Inc.
Fixes: 7877ed7ce33e ("Avoid mapping ENOENT to ENOTDIR for non-existent path components.")
Reviewed by: ziaee, markj
Differential Revision: https://reviews.freebsd.org/D53027
(cherry picked from commit 7c66667d45e95af59f59e41ef169119a974a6be1)
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
If lstat() fails with EACCES or ENOTDIR, the path we need to return in
the caller-provided buffer is that of the parent directory (which is
either unreadable or not a directory; the latter can only happen in the
case of a race) rather than that of the child we attempted to stat.
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D53025
(cherry picked from commit 1406de21e176d8700240ac9e473df007cd41eec1)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Passing NULL should result in EINVAL
* Passing an empty path should result in ENOENT
* Failure with a non-null buffer should leave a partial result. As
pointed out in a comment in the test case, this reveals a discrepancy
between the documentation and reality.
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D53024
(cherry picked from commit f3386dfeb429faaa30a915a4a422a25e07c8bf39)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The current phrasing could be interpreted as meaning that initgroups(3)
could return ENOMEM instead of -1, which it actually did until I fixed
it in commit 0b018cfd81d8 ("initgroups(3): Fix return value on
allocation failure").
While here, mention setgroups(2) as a system call rather than a library
function.
MFC with: 0b018cfd81d8 ("initgroups(3): Fix return value on allocation failure")
Sponsored by: The FreeBSD Foundation
(cherry picked from commit c36a44e1cdab1c67a98132676818f473cc4e5c03)
|