]> git.ipfire.org Git - thirdparty/libbsd.git/log
thirdparty/libbsd.git
2 weeks agoman: Improve wording for discouraged and optional features in libbsd(7) main
Guillem Jover [Sun, 10 May 2026 02:16:06 +0000 (04:16 +0200)] 
man: Improve wording for discouraged and optional features in libbsd(7)

2 weeks agoman: Document uclibc and uclibc-ng interfaces in libbsd(7)
Guillem Jover [Sun, 10 May 2026 02:16:06 +0000 (04:16 +0200)] 
man: Document uclibc and uclibc-ng interfaces in libbsd(7)

2 weeks agoman: Disable hyphenation globally for all man pages
Guillem Jover [Sun, 17 May 2026 21:01:52 +0000 (23:01 +0200)] 
man: Disable hyphenation globally for all man pages

There is no place for hyphenation in a technical document. Unfortunately
groff insists on hyphenating words that are known to be technical terms
such as in .Xr, or .Fn, etc. Where groff upstream suggests that those
words need to be marked up with things like \%, which looks like
unnecessary busy work.

The current workaround requires to use low-level troff markup to
globally disable hyphenation with groff, which is less than ideal, but
the best known option available.

2 weeks agoman: Document functions that are part of C23 and POSIX 2024
Guillem Jover [Sat, 16 May 2026 21:25:02 +0000 (23:25 +0200)] 
man: Document functions that are part of C23 and POSIX 2024

2 weeks agobuild: Check sanitize argument value
Sven Püschel [Tue, 28 Oct 2025 11:11:36 +0000 (12:11 +0100)] 
build: Check sanitize argument value

Check the value of the sanitize argument to determine if sanitize should
be enabled. This fixes that sanitize is enabled when --disable-sanitize
is passed to the configure script.

The third AC_ARG_ENABLE parameter defines an action, if the parameter is
present, but doesn't check its value. Therefore it is also invoked if the
parameter is disabled or --enable-foo=no is set. Therefore don't define
these actions and instead check the value with an AS_IF statement
afterwards, as shown in [1].

  [1] https://autotools.info/autoconf/arguments.html

[guillem@hadrons.org:
 - Minor coding style fixes.
 - Minor wording fixes in commit message. ]

Fixes: 257800a03c6b ("build: Add support for sanitizer compiler flags")
Closes: !31
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2 weeks agobuild: Switch to debian:unstable Docker image
Guillem Jover [Mon, 18 May 2026 02:55:05 +0000 (04:55 +0200)] 
build: Switch to debian:unstable Docker image

We have a restricted enough amount of dependencies that relying on
Debian unstable seems safe. More than using debian:testing which might
end up stuck with problems for some time until packages migrate from
unstable.

2 weeks agoAdd consttime_memequal() function
Guillem Jover [Fri, 17 Oct 2025 21:47:55 +0000 (23:47 +0200)] 
Add consttime_memequal() function

Import from NetBSD.

2 weeks agoAdd explicit_memset() function
Guillem Jover [Fri, 17 Oct 2025 21:46:49 +0000 (23:46 +0200)] 
Add explicit_memset() function

Import from NetBSD.

2 weeks agoman: Add err(3bsd) man pages for systems where we enable the functions
Guillem Jover [Wed, 15 Oct 2025 03:22:09 +0000 (05:22 +0200)] 
man: Add err(3bsd) man pages for systems where we enable the functions

Reported-by: Alejandro Colomar <alx@kernel.org>
2 weeks agobuild: Sort Files field in COPYING file
Guillem Jover [Sun, 10 May 2026 02:35:33 +0000 (04:35 +0200)] 
build: Sort Files field in COPYING file

2 weeks agobuild: Add Maintainer and License fields to pkg-config files
Guillem Jover [Mon, 9 Feb 2026 01:32:48 +0000 (02:32 +0100)] 
build: Add Maintainer and License fields to pkg-config files

2 weeks agobuild: Request tar-ustar format for distribution
Guillem Jover [Fri, 8 May 2026 03:41:14 +0000 (05:41 +0200)] 
build: Request tar-ustar format for distribution

Even though this is the default starting with automake 1.18, we should
be explicit to get uniform behavior.

2 weeks agobuild: Set TAR_OPTIONS to avoid leaking maintainer information on dist
Guillem Jover [Fri, 8 May 2026 03:40:20 +0000 (05:40 +0200)] 
build: Set TAR_OPTIONS to avoid leaking maintainer information on dist

The default tar invocation by automake leaks the user and group IDs and
names into the tarball. And while those are probably going to be easy to
infer, it is unnecessary to expose them. With the automake switch from
tar format v7 to ustar this is now worse as it used to only leak the
IDs, not the names.

We set and export TAR_OPTIONS with --owner=0 and --group=0 to neuter the
information leak. Although ideally automake would set those by default.

2 weeks agodoc: Use SPDX identifier for libutil-David-Nugent license in COPYING
Guillem Jover [Sat, 16 May 2026 15:00:58 +0000 (17:00 +0200)] 
doc: Use SPDX identifier for libutil-David-Nugent license in COPYING

The current name (BSD-5-clause-Peter-Wemm) is very confusing as it gives
it legitimacy as one of the recognized BSD-N-clause licenses, and it
also makes it seem more restrictive than a BSD-4-clause license, which
it does not appear to be. The license seems to originate from libutil
files by David Nugent, and that's the name that it got when being added
into SPDX. We switch to use that as a known registered name instead of
making it up ourselves.

Ref: https://spdx.org/licenses/libutil-David-Nugent.html

2 weeks agodoc: Coalesce copyright years into ranges in COPYING file
Guillem Jover [Sat, 16 May 2026 15:29:58 +0000 (17:29 +0200)] 
doc: Coalesce copyright years into ranges in COPYING file

For copyright, the important dates are the first date of publication,
and the last date of publication. The latter for anonymous and
pseudonymous authors where there's a fixed time after last publication
(usually at least 50 years or more), and the former for known authors
where there's a fixed time after first publication or author's death
(usually at least 50 years or more).

It seems fine to coalesce the copyright years in the COPYING file, as
this is a summary of the original statements found in the actual source
files, were we are here already inserting the different years or ranges,
so making it a single range preserves the important information that
might be relevant for compliance purposes.

2 weeks agodoc: Sort and make copyright statements unique in COPYING file
Guillem Jover [Sun, 10 May 2026 03:13:33 +0000 (05:13 +0200)] 
doc: Sort and make copyright statements unique in COPYING file

2 weeks agodoc: Remove spurious text from copyright statements in COPYING file
Guillem Jover [Sun, 10 May 2026 03:13:33 +0000 (05:13 +0200)] 
doc: Remove spurious text from copyright statements in COPYING file

Remove «,» and «by» after copyright years, and trailing «.» after
copyright statements.

2 weeks agodoc: Remove redundant «Copyright ©» from COPYING file
Guillem Jover [Sun, 10 May 2026 03:13:33 +0000 (05:13 +0200)] 
doc: Remove redundant «Copyright ©» from COPYING file

This is implied by the field name this text is a value for.

2 weeks agodoc: Split «code is derived from» into Comments fields in COPYING file
Guillem Jover [Sun, 10 May 2026 03:13:33 +0000 (05:13 +0200)] 
doc: Split «code is derived from» into Comments fields in COPYING file

These are not copyright statements, they are provenance or authorship
statements.

3 weeks agodoc: Remove «All rights reserved»
Guillem Jover [Mon, 13 Mar 2023 23:58:45 +0000 (00:58 +0100)] 
doc: Remove «All rights reserved»

This has no legal weight, and was needed due to the Buenos Aires
Convention requiring it. Since all members of the Buenos Aires
Convention are now part of the Berne Convention, there is no need
anymore for this phrasing. And while the original statement must not
be touched, we do not need to replicate this in the COPYING file when
it is legally pointless.

10 months agoMark tau and sigma Chacha variables as nonstring
Guillem Jover [Sat, 26 Jul 2025 10:41:23 +0000 (12:41 +0200)] 
Mark tau and sigma Chacha variables as nonstring

These contain a sequence of bytes, and are not a NUL-terminated string.
Help the compiler understand the intent of the code.

10 months agoinclude: Switch from __unused to new LIBBSD_UNUSED
Guillem Jover [Sat, 2 Nov 2024 22:14:11 +0000 (23:14 +0100)] 
include: Switch from __unused to new LIBBSD_UNUSED

Because we do not define __unused, as on GNU systems Linux and glibc
providing conflicting symbols, declarations for imported functions that
use that attribute cause build failures when used.

Ref: https://bugs.debian.org/1083196
Fixes: #34
10 months agoinclude: Refactor «unused» attribute into new LIBBSD_UNUSED macro
Guillem Jover [Sat, 2 Nov 2024 22:12:40 +0000 (23:12 +0100)] 
include: Refactor «unused» attribute into new LIBBSD_UNUSED macro

This make it possible to declare function arguments in headers as
potentially unused, so that they do not emit warnings. We will use this
instead of the BSD __unused, which we cannot currently enable on GNU
systems due to Linux and glibc having conflicting symbols.

19 months agodoc: Update anongit & cgit URLs to use gitlab instead
Alan Coopersmith [Sat, 7 Sep 2024 20:19:35 +0000 (13:19 -0700)] 
doc: Update anongit & cgit URLs to use gitlab instead

Closes: !30
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2 years agoRelease libbsd 0.12.2 0.12.2
Guillem Jover [Mon, 18 Mar 2024 02:17:06 +0000 (03:17 +0100)] 
Release libbsd 0.12.2

2 years agotest: nlist: make resilient against -Wl,--gc-sections
Sam James [Wed, 13 Mar 2024 23:34:55 +0000 (23:34 +0000)] 
test: nlist: make resilient against -Wl,--gc-sections

With linker sections GC enabled, we get a test failure in `nlist.c`:
```
nlist: nlist.c:72: main: Assertion `rc == 0' failed.
```

This turns out to be because several sections used by the test can be discarded:
```
ld: removing unused section '.text.func_pub' in file 'nlist.o'
ld: removing unused section '.bss.data_pub_uninit' in file 'nlist.o'
ld: removing unused section '.data.data_pub_init' in file 'nlist.o'
```

Reproduced with `CFLAGS="-Og -fdata-sections -ffunction-sections"` and
`LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--gc-sections -Wl,-z,start-stop-gc"`.

Additionally, `LDFLAGS="... -Wl,--print-gc-sections"` can help with diagnosing
which sections get removed.

We already mark these symbols as `used`, but we need `retain` [0] for them
to survive linker GC too.

[0] https://releases.llvm.org/18.1.0/tools/lld/docs/ELF/start-stop-gc.html#annotate-c-identifier-name-sections

Closes: !29
Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2 years agobuild: Do not rely on internal autoconf ac_cv_sys_file_offset_bits variable
Guillem Jover [Thu, 14 Mar 2024 00:56:36 +0000 (01:56 +0100)] 
build: Do not rely on internal autoconf ac_cv_sys_file_offset_bits variable

This is an internal implementation detail from AC_SYS_LARGEFILE, which
happened to change with autoconf 2.72. Instead compute our own size
for off_t.

Closes: #28
2 years agobuild: Use -eq instead of = as test operators for arithmetic tests
Guillem Jover [Thu, 14 Mar 2024 00:59:19 +0000 (01:59 +0100)] 
build: Use -eq instead of = as test operators for arithmetic tests

2 years agobuild: Fix typo in ABI selection description
Guillem Jover [Tue, 12 Mar 2024 23:56:59 +0000 (00:56 +0100)] 
build: Fix typo in ABI selection description

2 years agobuild: Only install time struct conversion macros where missing
Guillem Jover [Tue, 12 Mar 2024 23:56:07 +0000 (00:56 +0100)] 
build: Only install time struct conversion macros where missing

These macros are available in several systems, and we should not install
the man pages for them, otherwise we might end up shadowing the system
man pages if present.

2 years agoman: Add links for errc module functions
Guillem Jover [Sun, 10 Mar 2024 17:01:02 +0000 (18:01 +0100)] 
man: Add links for errc module functions

Reported-by: Alejandro Colomar <alx@kernel.org>
2 years agoman: Do not install timeval(3bsd) nor timespec(3bsd)
Guillem Jover [Fri, 8 Mar 2024 02:05:24 +0000 (03:05 +0100)] 
man: Do not install timeval(3bsd) nor timespec(3bsd)

These are system types, which we should not be documenting. Rewrite the
man pages around the TIMEVAL_TO_TIMESPEC and TIMESPEC_TO_TIMEVAL macros.

2 years agostrtonum: Do not abort on EINVAL from strtoi()
Duncan Overbruck [Tue, 5 Mar 2024 16:02:32 +0000 (17:02 +0100)] 
strtonum: Do not abort on EINVAL from strtoi()

With musl libc strtoimax(".", ...) returns EINVAL.

Closes: !28
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2 years agoclosefrom: Ignore files starting with dot when scanning /proc/self/fd
Duncan Overbruck [Tue, 5 Mar 2024 16:01:29 +0000 (17:01 +0100)] 
closefrom: Ignore files starting with dot when scanning /proc/self/fd

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2 years agobuild: Match also gnu* for GNU/Hurd on the glibc ABI selection
Guillem Jover [Wed, 6 Mar 2024 01:12:56 +0000 (02:12 +0100)] 
build: Match also gnu* for GNU/Hurd on the glibc ABI selection

The GNU/Hurd system does not specify a kernel part, so we need to match
on both *-gnu* and gnu* (to avoid overmatching with just *gnu*).

2 years agoRelease libbsd 0.12.1 0.12.1
Guillem Jover [Wed, 28 Feb 2024 03:50:34 +0000 (04:50 +0100)] 
Release libbsd 0.12.1

2 years agobuild: Add a comment to libbsd-overlay.pc about -isystem usage
Guillem Jover [Wed, 28 Feb 2024 03:44:02 +0000 (04:44 +0100)] 
build: Add a comment to libbsd-overlay.pc about -isystem usage

Add the reasoning for why we use -isystem instead of -I, to avoid
confusing unsuspecting readers of the file.

Prompted-by: Alejandro Colomar <alx@kernel.org>
2 years agobuild: Install err.h if either of the err or errc modules are built
Guillem Jover [Wed, 28 Feb 2024 03:37:44 +0000 (04:37 +0100)] 
build: Install err.h if either of the err or errc modules are built

Both modules expose their functions in err.h, so we need to install it
whenever any of them is being built.

Reported-by: Alejandro Colomar <alx@kernel.org>
2 years agoRelease libbsd 0.12.0 0.12.0
Guillem Jover [Tue, 27 Feb 2024 04:52:53 +0000 (05:52 +0100)] 
Release libbsd 0.12.0

2 years agoAdd explicit time32 and time64 support
Guillem Jover [Fri, 9 Feb 2024 03:32:12 +0000 (04:32 +0100)] 
Add explicit time32 and time64 support

Handle the three potential system scenarios:

 - system time_t is time64
 - system time_t is time32 and supports time64
 - system time_t is time32 and does not support time64

Add the explicit time32 and time64 functions when necessary and map
them accordingly for each of these cases.

2 years agobuild: Add support for AIX
Guillem Jover [Mon, 12 Feb 2024 02:00:06 +0000 (03:00 +0100)] 
build: Add support for AIX

2 years agoAdd vasprintf() and asprintf() functions missing on AIX
Guillem Jover [Mon, 12 Feb 2024 00:04:37 +0000 (01:04 +0100)] 
Add vasprintf() and asprintf() functions missing on AIX

These functions are used by code in the library, even though these
functions started as GNU extensions, they are present in all BSDs,
so we expose them as part of our interface on AIX.

2 years agobuild: Add support for Solaris
Guillem Jover [Mon, 12 Feb 2024 01:55:08 +0000 (02:55 +0100)] 
build: Add support for Solaris

2 years agobuild: Make almost all exposed interfaces use the new ABI selection
Guillem Jover [Sun, 11 Feb 2024 22:55:40 +0000 (23:55 +0100)] 
build: Make almost all exposed interfaces use the new ABI selection

Explicitly select what to include as part of the target ABI, instead of
letting autoconfiguration potentially break ABI if the system grows
functionality provided by the library.

Make almost all the library selectable per target. Do not install manual
pages for interfaces not included in the library. Control inclusion of
symbols in map file via pre-processor macros, and move the comments
describing the ABI selection to configure.ac.

For now the header files are included as is and filtered through
pre-processor conditionals. Eventually they might get switched to be
autogenerated at build time.

2 years agobuild: Rework ABI selection logic
Guillem Jover [Wed, 14 Feb 2024 03:59:44 +0000 (04:59 +0100)] 
build: Rework ABI selection logic

Add a new LIBBSD_SELECT_ABI m4 macro, and use it to setup the ABI
interfaces to expose and the various variables and conditionals
to be used by the build system.

Switch to set the initial values to unknown and then set every one
of the selections explicitly by supported target.

Update comments for rationale for things to DROP, or for why some
selections are enabled.

2 years agobuild: Rename ABI selection variables from need_ to abi_
Guillem Jover [Wed, 14 Feb 2024 03:59:44 +0000 (04:59 +0100)] 
build: Rename ABI selection variables from need_ to abi_

This should make the purpose of these variables more clear.

2 years agobuild: Revert accidental testing aid change
Guillem Jover [Wed, 21 Feb 2024 01:29:15 +0000 (02:29 +0100)] 
build: Revert accidental testing aid change

This was accidentally included in the commit, but should have only been
used during development.

Fixes: commit de124dcafac678351366b0572938398ea7ae93e4
Changelog: silent

2 years agobuild: Make digest function checks conditional on their use
Guillem Jover [Tue, 20 Feb 2024 03:28:01 +0000 (04:28 +0100)] 
build: Make digest function checks conditional on their use

The digest function checks where unconditionally requiring the functions
to exist or they would error out. But these functions are not required
on all systems, they depend on the ABI to be exposed.

2 years agobuild: Move ABI selection at the top of configure.ac
Guillem Jover [Tue, 20 Feb 2024 03:13:59 +0000 (04:13 +0100)] 
build: Move ABI selection at the top of configure.ac

Merge the existing host_os block for the OS detection with the ABI
selection one, as these are related. This way we will be able to make
some of the latter checks conditional on the selected ABI.

2 years agobuild: Sort variables and their contents in automake files
Guillem Jover [Sun, 11 Feb 2024 22:55:40 +0000 (23:55 +0100)] 
build: Sort variables and their contents in automake files

This should make it easier to add new entries, and find them afterwards.

2 years agobuild: Rename LIBBSD_ABI to SOVERSION
Guillem Jover [Wed, 21 Feb 2024 01:05:57 +0000 (02:05 +0100)] 
build: Rename LIBBSD_ABI to SOVERSION

This matches the semantics of the variable, and makes it independent of
the project, just as the package variables.

2 years agobuild: Refactor function checks into a new libbsd-funcs.m4 file
Guillem Jover [Tue, 20 Feb 2024 03:40:32 +0000 (04:40 +0100)] 
build: Refactor function checks into a new libbsd-funcs.m4 file

These are complex enough to clutter the main configure.ac. Move them
into their own file.

2 years agobuild: Remove space before shell redirection
Guillem Jover [Tue, 20 Feb 2024 02:57:37 +0000 (03:57 +0100)] 
build: Remove space before shell redirection

This makes it more clear what the redirection applies to.

2 years agobuild: Add support for silent rules for the libbsd.map generation
Guillem Jover [Sun, 18 Feb 2024 19:40:24 +0000 (20:40 +0100)] 
build: Add support for silent rules for the libbsd.map generation

The new rule was introduced w/o silent rule support.

Fixes: commit 19e06407eb365a2bedc9bdd29a83c1e1803e3f92
2 years agoSplit errc family of functions from err ones
Guillem Jover [Sat, 17 Feb 2024 04:25:01 +0000 (05:25 +0100)] 
Split errc family of functions from err ones

On most systems the err family of functions is already present, but are
missing the errc family of functions, which are also present on some
other systems. Splitting them into separate files will make it easer to
conditionally include one or the other.

2 years agoSync strtoi()/strtou() implementations from NetBSD
Guillem Jover [Sat, 17 Feb 2024 02:07:58 +0000 (03:07 +0100)] 
Sync strtoi()/strtou() implementations from NetBSD

These contain the fixes to the error handling logic.

In NetBSD the manual page for strtou.3 is generated from the strtoi.3
manual page applying some substitutions, the problem is that the
cross-references are then lost. We will still keep them separate.

Reported-by: Alejandro Colomar <alx@kernel.org>
2 years agobuild: Swap symbol and alias arguments order in macros creating aliases
Guillem Jover [Wed, 14 Feb 2024 02:39:16 +0000 (03:39 +0100)] 
build: Swap symbol and alias arguments order in macros creating aliases

The current order is rather confusing, pass the real symbol first
and the alias we want to create next.

2 years agobuild: Generate the map file from the configured ABI
Guillem Jover [Sun, 11 Feb 2024 18:35:05 +0000 (19:35 +0100)] 
build: Generate the map file from the configured ABI

Some linkers require the map file definitions to contain only symbols
that are present on the linked object, either in the map file or in the
sym file we generate from the map file.

This is preparatory work to be able to conditionally include symbols
in the man and sym files depending on the ABI definitions.

2 years agobuild: Make name_from_id man pages conditional instead of id_from_name
Guillem Jover [Sun, 11 Feb 2024 23:06:56 +0000 (00:06 +0100)] 
build: Make name_from_id man pages conditional instead of id_from_name

The code is only making the name_from_id function conditional, and
assumes id_from_name are always to be included, so we need to match
the logic for the man page inclusion.

2 years agoman: Mention that funopen() can be made available on musl
Guillem Jover [Mon, 8 Jan 2024 22:57:45 +0000 (23:57 +0100)] 
man: Mention that funopen() can be made available on musl

As musl got fopencookie() implemented in 1.1.19, the funopen() function
can also be provided there. Note this in the documentation.

2 years agoman: Fix manual page references
Guillem Jover [Mon, 8 Jan 2024 22:40:31 +0000 (23:40 +0100)] 
man: Fix manual page references

When referring to another manual page and their section number, we need
to use Xr instead of Fn, otherwise the section number is interpreted as
a function argument. For functions provided by libbsd itself we should
be using the 3bsd section instead of 3.

2 years agoman: Add closefrom(), strlcpy() and strlcat() as superseded functions
Guillem Jover [Mon, 8 Jan 2024 22:39:19 +0000 (23:39 +0100)] 
man: Add closefrom(), strlcpy() and strlcat() as superseded functions

These were missing from the list of functions provided by some libc
implementation.

2 years agodoc: Use macOS to refer to the operating system
Guillem Jover [Mon, 8 Jan 2024 22:37:43 +0000 (23:37 +0100)] 
doc: Use macOS to refer to the operating system

This is the correct spelling, instead of capitalizing it.

2 years agoRelease libbsd 0.11.8 0.11.8
Guillem Jover [Mon, 8 Jan 2024 01:16:12 +0000 (02:16 +0100)] 
Release libbsd 0.11.8

2 years agotest: Close all descriptors before initializing them for closefrom()
Guillem Jover [Mon, 8 Jan 2024 00:58:54 +0000 (01:58 +0100)] 
test: Close all descriptors before initializing them for closefrom()

On macOS, closefrom() only sets the close-on-exec flag, so we cannot
check whether all file descriptors were closed, which means that if
on entry our file descriptor table was filled after the 4th file
descriptor, then we might fail the assertions for the flags for odd
file descriptors which we expect to be closed.

This can easily happen when running the test suite in parallel mode
with «make -j8 check» for example.

Closes: #23
2 years agobuild: Check out-of-tree builds in CI
Guillem Jover [Fri, 27 Oct 2023 22:52:31 +0000 (00:52 +0200)] 
build: Check out-of-tree builds in CI

Make sure the out-of-tree builds do not regress.

2 years agoAdjust strlcpy() and strlcat() per glibc adoption
Guillem Jover [Sun, 7 Jan 2024 16:43:12 +0000 (17:43 +0100)] 
Adjust strlcpy() and strlcat() per glibc adoption

These functions were added in glibc 2.38, in anticipation of POSIX
adopting them too.

Closes: #26
2 years agoDo not add a pointer to the NULL constant
Guillem Jover [Tue, 14 Nov 2023 18:15:11 +0000 (19:15 +0100)] 
Do not add a pointer to the NULL constant

Warned-by: cppcheck (nullPointerArithmetic)
2 years agoDo not confuse code analyzers with out-of-bounds array access look alike
Guillem Jover [Tue, 14 Nov 2023 18:09:25 +0000 (19:09 +0100)] 
Do not confuse code analyzers with out-of-bounds array access look alike

The code is only getting the address, but we might be performing an
addressing that is out-of-bounds. Avoid it and use the address form
instead.

Warned-by: cppcheck (objectIndex)
2 years agotest: Fix short-lived memory leak
Guillem Jover [Tue, 14 Nov 2023 18:08:15 +0000 (19:08 +0100)] 
test: Fix short-lived memory leak

Warned-by: cppcheck
2 years agobuild: Add a coverage regex to the CI job
Guillem Jover [Fri, 27 Oct 2023 22:47:26 +0000 (00:47 +0200)] 
build: Add a coverage regex to the CI job

This is needed so that gitlab can know where to extract the coverage
percentage from in the output, to be able to track and report it.

2 years agoman: Use VARIANTS instead of ALTERNATIVES in libbsd(7)
Guillem Jover [Mon, 9 Oct 2023 23:53:32 +0000 (01:53 +0200)] 
man: Use VARIANTS instead of ALTERNATIVES in libbsd(7)

Using alternatives seems confusing in this context.

2 years agoman: Markup function references with Xr instead of Fn
Guillem Jover [Mon, 9 Oct 2023 23:52:37 +0000 (01:52 +0200)] 
man: Markup function references with Xr instead of Fn

These references had man page sections in them, so using Fn meant that
these appeared as function arguments.

2 years agobuild: Add missing dash to macro title bar
Guillem Jover [Tue, 5 Sep 2023 01:02:44 +0000 (03:02 +0200)] 
build: Add missing dash to macro title bar

2 years agopwcache: Do not declare uidtb and gidtb when not used
Guillem Jover [Thu, 27 Jul 2023 11:57:51 +0000 (13:57 +0200)] 
pwcache: Do not declare uidtb and gidtb when not used

When the system provides implementations for user_from_uid() or
group_from_gid() we are not using these variables, so better not declare
them.

Fixes: commit 21d12b02112097f0c195dceb1892c95b7b957b36
2 years agofgetln: Include <stdio.h> after <sys/*>
Guillem Jover [Thu, 27 Jul 2023 11:39:00 +0000 (13:39 +0200)] 
fgetln: Include <stdio.h> after <sys/*>

The <sys/*> headers tend to define things that might be used by other
headers, so while they should be self-contained, it is better to simply
include them first.

2 years agobuild: Refactor GNU .init_array support check into a new m4 function
Guillem Jover [Fri, 26 May 2023 21:55:40 +0000 (23:55 +0200)] 
build: Refactor GNU .init_array support check into a new m4 function

2 years agobuild: Refactor linker script detection into a new m4 function
Guillem Jover [Fri, 26 May 2023 21:50:10 +0000 (23:50 +0200)] 
build: Refactor linker script detection into a new m4 function

2 years agobuild: Do not provide prototypes for arc4random() on Solaris
Guillem Jover [Thu, 27 Jul 2023 11:51:36 +0000 (13:51 +0200)] 
build: Do not provide prototypes for arc4random() on Solaris

These functions are provided by the system.

2 years agobuild: Do not build the progname module if it is not needed
Guillem Jover [Sat, 22 Apr 2023 18:47:20 +0000 (20:47 +0200)] 
build: Do not build the progname module if it is not needed

This was made conditional, but the code part was accidentally left
untouched due to having ported it locally to use __progname, which
caused build failures on the stock repo.

Fixes: commit 046621d7967e7a0f08ae988bcf7e4cd1b6cf204c
3 years agobuild: Sort entries alphabetically
Guillem Jover [Sun, 23 Apr 2023 00:04:47 +0000 (02:04 +0200)] 
build: Sort entries alphabetically

3 years agobuild: Conditionalize wcslcpy() and wcslcat() functions on macOS
Guillem Jover [Sun, 23 Apr 2023 00:05:04 +0000 (02:05 +0200)] 
build: Conditionalize wcslcpy() and wcslcat() functions on macOS

These functions are provided by the system libc.

3 years agobuild: Conditionalize only id-from-name functions not the entire pwcache
Guillem Jover [Sun, 23 Apr 2023 00:00:10 +0000 (02:00 +0200)] 
build: Conditionalize only id-from-name functions not the entire pwcache

On macOS the name-from-id functions are present, but not the
id-from-name ones, so we want to provide those instead of suppressing
the entire file.

3 years agobuild: Conditionalize getprogname()/setprogname on macOS
Guillem Jover [Sat, 22 Apr 2023 20:47:10 +0000 (22:47 +0200)] 
build: Conditionalize getprogname()/setprogname on macOS

These functions are provided by the system libc, so there is no need for
us to provide them.

3 years agoprogname: Include <procinfo.h> if available
Guillem Jover [Sat, 22 Apr 2023 18:23:08 +0000 (20:23 +0200)] 
progname: Include <procinfo.h> if available

We need this header on AIX. Missed transplanting the code from the AIX
porting system.

Fixes: commit 9fa06763a1afe0946a3a20e5bbdba72885cbade5
3 years agobuild: Check whether we need libperfstat on AIX
Guillem Jover [Tue, 18 Apr 2023 01:56:16 +0000 (03:56 +0200)] 
build: Check whether we need libperfstat on AIX

The getentropy() implementation makes use of this library on AIX.

3 years agobuild: Annotate droppable functions for musl on next SOVERSION bump
Guillem Jover [Tue, 18 Apr 2023 01:59:17 +0000 (03:59 +0200)] 
build: Annotate droppable functions for musl on next SOVERSION bump

These are already provided by the musl libc, and can thus be dropped on
the next SOVERSION bump.

3 years agobuild: Conditionalize bsd_getopt() on macOS
Guillem Jover [Tue, 18 Apr 2023 01:58:24 +0000 (03:58 +0200)] 
build: Conditionalize bsd_getopt() on macOS

The system library provides a getopt() with BSD semantics.

3 years agoMove the version script comments before the symbols
Guillem Jover [Mon, 17 Apr 2023 22:47:12 +0000 (00:47 +0200)] 
Move the version script comments before the symbols

When generating the .sym export file from the .map file, we are not
stripping these comments that are part of the same line as the symbol,
which causes ld(1) implementations to error out. Moving them before
the symbols avoids the need to strip them, as we are only keeping
actual symbol lines.

3 years agoPort getprogname() to AIX
Guillem Jover [Mon, 17 Apr 2023 22:44:49 +0000 (00:44 +0200)] 
Port getprogname() to AIX

Get the program name from the COMM field from the proc filesystem.

We could use instead the information from the psinfo binary file under
/proc, but that seems to have a shorter string limit.

3 years agoMake getprogname() porting mandatory
Guillem Jover [Mon, 17 Apr 2023 21:59:03 +0000 (23:59 +0200)] 
Make getprogname() porting mandatory

Although the function is documented as possibly returning NULL if it
cannot find a known source of information, we should still at least
attempt to port it to any supported system, and otherwise explicitly
mark it as not implementable for such systems if that was to be the
case.

3 years agotest: Do not use /dev/null as compiler output file
Guillem Jover [Mon, 17 Apr 2023 21:59:19 +0000 (23:59 +0200)] 
test: Do not use /dev/null as compiler output file

Some ld(1) implementations, such as the one on AIX, do not support using
/dev/null as the output filename for the compiled object.

Use an actual filename that we will then clean up.

3 years agobuild: Add generated *.sym files to .gitignore
Guillem Jover [Mon, 17 Apr 2023 22:49:09 +0000 (00:49 +0200)] 
build: Add generated *.sym files to .gitignore

3 years agobuild: On macOS do not build functions provided by the system
Guillem Jover [Tue, 4 Apr 2023 21:59:05 +0000 (23:59 +0200)] 
build: On macOS do not build functions provided by the system

We have never built before on macOS, so we can exclude all the functions
that are currently provided in the system.

Closes: #1
Closes: !3
3 years agobuild: Select whether to include funopen() in the build system
Guillem Jover [Thu, 6 Apr 2023 21:05:27 +0000 (23:05 +0200)] 
build: Select whether to include funopen() in the build system

This makes sure we include it when expected, alongside the man pages,
and the test cases, and do not accidentally break the ABI if the system
starts providing such interface.

3 years agobuild: Move Windows OS detection to the OS features section
Guillem Jover [Fri, 7 Apr 2023 21:43:55 +0000 (23:43 +0200)] 
build: Move Windows OS detection to the OS features section

This was placed here to make use of the same AS_CASE, but it does not
really fit with the section. Move it to the more appropriate place, and
detangle the AS_CASE.

3 years agobuild: Remove __MUSL__ definition from configure
Guillem Jover [Fri, 7 Apr 2023 21:40:22 +0000 (23:40 +0200)] 
build: Remove __MUSL__ definition from configure

We stopped relying on this macro when we turned the funopen() cpp error
into a warning in commit e50896286cc5718898194edb73fa7262ad9a22db.

3 years agobuild: Add a new libbsd_strong_alias() macro and switch users to it
Guillem Jover [Sun, 2 Apr 2023 20:33:25 +0000 (22:33 +0200)] 
build: Add a new libbsd_strong_alias() macro and switch users to it

We had several cases of code needing a strong alias, so we switch those
to use the new macro. This covers systems that support the alias
attribute and others such as macOS where we need to use assembler
directives to add the alias as the attribute is not supported.

3 years agobuild: Only emit link warnings for ELF objects
Guillem Jover [Sun, 2 Apr 2023 20:32:11 +0000 (22:32 +0200)] 
build: Only emit link warnings for ELF objects

3 years agobuild: Use an export symbols file if there is no version script support
Guillem Jover [Mon, 10 Apr 2023 22:24:13 +0000 (00:24 +0200)] 
build: Use an export symbols file if there is no version script support

We generate the symbol list from the version script to avoid repeating
ourselves and potentially getting the lists out-of-sync.