]> git.ipfire.org Git - thirdparty/libbsd.git/log
thirdparty/libbsd.git
2 years agoinclude: Use __has_builtin to detect __builtin_offsetof support
Guillem Jover [Tue, 20 Dec 2022 21:47:02 +0000 (22:47 +0100)] 
include: Use __has_builtin to detect __builtin_offsetof support

The __has_builtin operator is more specific and is supported by GCC
and Clang, while __is_identifier() is less specific and only supported
by Clang, so we should prefer the former whenever it is available, and
only fallback to use the latter when the former is missing and the
latter.

2 years agofunopen: Replace off64_t with off_t in funopen_seek()
Khem Raj [Thu, 15 Dec 2022 17:02:22 +0000 (09:02 -0800)] 
funopen: Replace off64_t with off_t in funopen_seek()

AC_SYS_LARGEFILE in configure.ac is setting needed defines to make
64bit off_t on relevant platforms.

Fixes build on musl:

| src/funopen.c:68:28: error: unknown type name 'off64_t'; did you mean 'off_t'?
| funopen_seek(void *cookie, off64_t *offset, int whence)
|                            ^~~~~~~
|                            off_t

Closes: !24
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2 years agoman: Prune unneeded <sys/types.h> include in setproctitle(3)
Guilherme Janczak [Wed, 7 Dec 2022 04:06:37 +0000 (04:06 +0000)] 
man: Prune unneeded <sys/types.h> include in setproctitle(3)

FreeBSD first declared the function in unistd.h in 2000:
https://cgit.freebsd.org/src/commit/include/unistd.h?id=9feac5c21886
No other #include line was needed to use the function, but the man page
unnecessarily instructed users to include sys/types.h until 2022-11-29:
https://cgit.freebsd.org/src/commit/?id=5b6f0a5012e9bc37dcb32b57b41e2443a46da620

libbsd first declared the function in unistd.h in 2010 with commit
3fed78e5b08f78256e533788b4bcd6502b0949d7 and inherited the bug from
FreeBSD's man page.

No need to do anything for backwards compat.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2 years agobuild: Improve C99 compatibility of __progname configure check
Florian Weimer [Tue, 13 Dec 2022 02:37:06 +0000 (03:37 +0100)] 
build: Improve C99 compatibility of __progname configure check

The check uses printf, so it needs to include <stdio.h> for
compilers which do not support implicit function declarations.
(They were removed from C99.)

Closes: !23
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2 years agobuild: Enable -Wall for automake
Guillem Jover [Tue, 13 Dec 2022 02:35:05 +0000 (03:35 +0100)] 
build: Enable -Wall for automake

This will make sure to warn about bogus or deprecated constructs.

2 years agobuild: Add missing AM_PROG_AR macro call to configure.ac
Guillem Jover [Tue, 13 Dec 2022 02:34:37 +0000 (03:34 +0100)] 
build: Add missing AM_PROG_AR macro call to configure.ac

Warned-by: autoreconf
2 years agobuild: Fix configure.ac indentation
Guillem Jover [Tue, 13 Dec 2022 02:31:38 +0000 (03:31 +0100)] 
build: Fix configure.ac indentation

Use the same style as the newly added code, which should make the code
more readable, and produce more conforming C output.

2 years agobuild: Require automake 1.11
Guillem Jover [Tue, 13 Dec 2022 02:10:28 +0000 (03:10 +0100)] 
build: Require automake 1.11

This is a rather old release (from 2009), that provides AM_SILENT_RULES.

2 years agobuild: Do not require funopen() to be ported
Guillem Jover [Wed, 23 Nov 2022 22:31:54 +0000 (23:31 +0100)] 
build: Do not require funopen() to be ported

This function cannot be easily and (more importantly) correctly ported
without cooperation from the libc stdio layer. We already document that
users should be prepared to have the function not available on some
platforms and that they should ideally switch their code to other
more portable and better interfaces.

Instead of making the build fail, and requiring porters to add
exceptions for something that most probably cannot be ported correctly
anyway, simply print a warning and let it build. This will not be a
regression because on those systems libbsd would have never been built
before.

Prompted-by: Jens Finkhaeuser <jens@finkhaeuser.de>
2 years agobuild: Terminate lists in variables with «# EOL»
Guillem Jover [Wed, 23 Nov 2022 22:28:34 +0000 (23:28 +0100)] 
build: Terminate lists in variables with «# EOL»

This means we can add a trailing «\» to every element, so that they
can be removed without requiring modification of other lines, and can
be easily sorted.

Replace the old usage of $(nil) which could possibly end up with junk
added if such variable is ever defined, in the environment.

2 years agobuild: Use «yes» instead of «true» for AC_CHECK_FUNCS cache value
Guillem Jover [Wed, 23 Nov 2022 22:42:49 +0000 (23:42 +0100)] 
build: Use «yes» instead of «true» for AC_CHECK_FUNCS cache value

This autoconf macro sets the ac_cv_func_ cached variable to «yes» not
«true» so we were checking for an impossible condition.

2 years agoRelease libbsd 0.11.7 0.11.7
Guillem Jover [Thu, 6 Oct 2022 02:07:52 +0000 (04:07 +0200)] 
Release libbsd 0.11.7

2 years agoman: Discourage using the library in non-overlay mode
Guillem Jover [Thu, 6 Oct 2022 01:59:33 +0000 (03:59 +0200)] 
man: Discourage using the library in non-overlay mode

This makes code using it non-portable, and requires the namespeced
headers from libbsd, instead of any generic system headers. It also
requires more code changes than the overlay mode.

2 years agoinclude: Adjust reallocarray() per glibc adoption
Guillem Jover [Wed, 5 Oct 2022 10:08:31 +0000 (12:08 +0200)] 
include: Adjust reallocarray() per glibc adoption

On glibc 2.29 reallocarray() was moved to _DEFAULT_SOURCE.

Closes: !20
Based-on-patch-by: Callum Farmer <gmbr3@opensuse.org>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2 years agoinclude: Adjust arc4random() per glibc adoption
Callum Farmer [Wed, 5 Oct 2022 10:08:31 +0000 (12:08 +0200)] 
include: Adjust arc4random() per glibc adoption

Some arc4random functions were added in glibc 2.36.

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2 years agoinclude: explicit_bzero() requires _DEFAULT_SOURCE
Callum Farmer [Mon, 3 Oct 2022 15:09:18 +0000 (16:09 +0100)] 
include: explicit_bzero() requires _DEFAULT_SOURCE

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2 years agoinclude: Simplify glibc version dependent macro handling
Guillem Jover [Wed, 5 Oct 2022 00:05:46 +0000 (02:05 +0200)] 
include: Simplify glibc version dependent macro handling

We test once whether __GLIBC__ is not defined, so we do not need to test
whether it is on the OR branch afterwards. We decouple the glibc version
restriction check from the _*_SOURCE variable, as that contains an
implicit opposite version check.

2 years agodoc: Switch references from pkg-config to pkgconf
Guillem Jover [Tue, 4 Oct 2022 23:35:08 +0000 (01:35 +0200)] 
doc: Switch references from pkg-config to pkgconf

The former used to be the reference implementation, but it has been
stagnant to the point of not showing much signs of life. Switch to
the currently active and more complete implementation for references.

2 years agodoc: Add missing empty line to separate README sections
Guillem Jover [Tue, 4 Oct 2022 02:28:05 +0000 (04:28 +0200)] 
doc: Add missing empty line to separate README sections

2 years agodoc: Refer to the main git repository as primary
Guillem Jover [Tue, 4 Oct 2022 02:27:44 +0000 (04:27 +0200)] 
doc: Refer to the main git repository as primary

2 years agotest: Fix explicit_bzero() test on the Hurd
Guillem Jover [Wed, 24 Aug 2022 22:52:43 +0000 (00:52 +0200)] 
test: Fix explicit_bzero() test on the Hurd

On the Hurd a small read(3) might end up (indirectly) copying the data
on the stack, which we will end up finding even when we have cleared
the buffer.

To avoid these side effects, we add a new function, that we force not
to be inlined, so that we can reuse the same stack space, that will
blank any possible stack side effects. This should be portable
regardless of stack growing up or down.

Diagnosis-by: Samuel Thibault <sthibault@debian.org>
2 years agofgetwln: Add comment about lack of getwline(3) for recommendation
Guillem Jover [Tue, 23 Aug 2022 23:58:58 +0000 (01:58 +0200)] 
fgetwln: Add comment about lack of getwline(3) for recommendation

Ideally we'd recommend getwline(3), but unfortunately even though it
was part of the ISO/IEC TR 24731-2:2010 draft, it did not make it into
C11 and is not widely implemented.

2 years agosetmode: Dot not use saveset after free
Guillem Jover [Tue, 23 Aug 2022 21:49:34 +0000 (23:49 +0200)] 
setmode: Dot not use saveset after free

While we are only doing a pointer difference and not dereferencing it,
it's easier and more correct to do the pointer difference before passing
it to reallocarray().

Warned-by: gcc
2 years agoman: Rewrite gerprogname(3bsd) from scratch
Guillem Jover [Wed, 3 Aug 2022 01:05:52 +0000 (03:05 +0200)] 
man: Rewrite gerprogname(3bsd) from scratch

This gets rid of one of the last man pages with a BSD-4-clause license.

2 years agoman: Lowercase man page title
Guillem Jover [Wed, 3 Aug 2022 00:21:16 +0000 (02:21 +0200)] 
man: Lowercase man page title

While using fully uppercase man page titles has been the usual
convention for a very long time, it is rather ugly and something that
some other projects are switching away from.

2 years agoman: Document that some arc4random(3) functions are now in glibc 2.36
Guillem Jover [Tue, 2 Aug 2022 23:23:09 +0000 (01:23 +0200)] 
man: Document that some arc4random(3) functions are now in glibc 2.36

2 years agoSync arc4random(3) implementation from OpenBSD
Guillem Jover [Wed, 3 Aug 2022 00:03:05 +0000 (02:03 +0200)] 
Sync arc4random(3) implementation from OpenBSD

Closes: #12
3 years agoFix ELF support for big endian SH
Fabrice Fontaine [Tue, 7 Jun 2022 17:27:13 +0000 (19:27 +0200)] 
Fix ELF support for big endian SH

Fix the following build failure with big endian SH (e.g. sh4aeb):

  ,---
  In file included from nlist.c:44:
  nlist.c: In function '__elf_is_okay__':
  local-elf.h:223:25: error: 'ELFDATA2LMSB' undeclared (first use in this function); did you mean 'ELFDATA2LSB'?
    223 | #define ELF_TARG_DATA   ELFDATA2LMSB
        |                         ^~~~~~~~~~~~
  `---

Fixes: http://autobuild.buildroot.org/results/2980fb79c208454195d77383f1ece9afbd7f981b
Closes: !19
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
3 years agoman: Use -compact also for alternative functions in libbsd(7)
Guillem Jover [Mon, 4 Apr 2022 09:49:52 +0000 (11:49 +0200)] 
man: Use -compact also for alternative functions in libbsd(7)

The other function lists use the compact mode, let's be uniform about
this.

3 years agogetentropy: Fix function cast for getauxval()
Guillem Jover [Thu, 31 Mar 2022 18:46:56 +0000 (20:46 +0200)] 
getentropy: Fix function cast for getauxval()

Fix also the Hurd implementation, missed in the original fix.

Extends: commit 72a82ee262795c9162e712885381a111fcf988bc
Warned-by: gcc
3 years agoRelease libbsd 0.11.6 0.11.6
Guillem Jover [Wed, 30 Mar 2022 21:09:35 +0000 (23:09 +0200)] 
Release libbsd 0.11.6

3 years agoAdd LoongArch support to nlist()
WANG Xuerui [Sat, 11 Sep 2021 04:54:28 +0000 (12:54 +0800)] 
Add LoongArch support to nlist()

Closes: !13
Signed-off-by: WANG Xuerui <git@xen0n.name>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
3 years agoman: Document when functions were added to musl in libbsd(7)
Guillem Jover [Wed, 30 Mar 2022 20:56:43 +0000 (22:56 +0200)] 
man: Document when functions were added to musl in libbsd(7)

The explicit_bzero(3) and reallocarray(3) functions are also present on
musl libc, mention it in the superseded section.

3 years agoRemove arc4random() OpenBSD support
Guilherme Janczak [Fri, 31 Dec 2021 08:25:08 +0000 (08:25 +0000)] 
Remove arc4random() OpenBSD support

The arc4random() support for OpenBSD does not build. The intention was
to include any portability code so that the library could be easily
ported to such systems, but it makes little sense to build it on OpenBSD
where most of the functionality will be already present, or the software
would have been ported anyway.

[guillem@hadrons.org: Reword commit message to add rationale. ]

Closes: !15
Signed-off-by: Guillem Jover <guillem@hadrons.org>
3 years agobuild: Add alpine to CI for tests with musl libc
Duncan Overbruck [Mon, 24 Jan 2022 14:11:38 +0000 (15:11 +0100)] 
build: Add alpine to CI for tests with musl libc

Closes: !18
Signed-off-by: Guillem Jover <guillem@hadrons.org>
3 years agotest: Import explicit_bzero and strtonum test cases from OpenBSD
Guillem Jover [Sat, 29 Jan 2022 13:48:22 +0000 (14:48 +0100)] 
test: Import explicit_bzero and strtonum test cases from OpenBSD

- Remove trailing spaces.
- Declare file-scope functions and variables static.
- Declare functions with a proper prototype.
- Do not mix declarations and code for C90 conformance.
- Do not compare size_t and ssize_t variables.

3 years agobuild: Sort test programs in .gitignore
Guillem Jover [Sat, 29 Jan 2022 13:52:08 +0000 (14:52 +0100)] 
build: Sort test programs in .gitignore

3 years agotest: Add fpurge() test case using open_memstream(3) FILE
Duncan Overbruck [Tue, 25 Jan 2022 19:34:39 +0000 (20:34 +0100)] 
test: Add fpurge() test case using open_memstream(3) FILE

Signed-off-by: Guillem Jover <guillem@hadrons.org>
3 years agofpurge: Make it work with non fd based FILEs
Duncan Overbruck [Tue, 25 Jan 2022 19:32:30 +0000 (20:32 +0100)] 
fpurge: Make it work with non fd based FILEs

Streams opened with for example open_memstream(3) will have no associated
file descriptor, and fileno(3) will fail.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
3 years agotest: Remove static FILE declaration from fpurge test
Duncan Overbruck [Mon, 24 Jan 2022 15:47:00 +0000 (16:47 +0100)] 
test: Remove static FILE declaration from fpurge test

This does not work with libcs that do not declare the structure
in a header file, like musl. And gets in the way of supporting
non-fd based streams.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
3 years agoRelease libbsd 0.11.5 0.11.5
Guillem Jover [Tue, 25 Jan 2022 00:48:29 +0000 (01:48 +0100)] 
Release libbsd 0.11.5

3 years agoRevert "build: Add missing proctitle unit test program"
Guillem Jover [Tue, 25 Jan 2022 00:41:14 +0000 (01:41 +0100)] 
Revert "build: Add missing proctitle unit test program"

This reverts commit beafad2657c7a57109c28f8bad9cb028c84c7dd5.

This test was already handled later on as part of the BUILD_LIBBSD_CTOR
conditional. Adding it to the unconditional set made the build fail when
the system does not have GNU .init_array section support.

Closes: #9
Analysis-by: Duncan Overbruck <mail@duncano.de>
3 years agoDocument how to build from git and from a tarball release
Guillem Jover [Sun, 23 Jan 2022 20:07:45 +0000 (21:07 +0100)] 
Document how to build from git and from a tarball release

Closes: #8
3 years agobuild: Check for objdump explicitly
Guillem Jover [Sun, 23 Jan 2022 17:54:33 +0000 (18:54 +0100)] 
build: Check for objdump explicitly

We should not assume that something will implicitly check for this tool,
as we need it ourselves, and this is an internal implementation detail
of right now libtool.

Fixes: commit f11ab6722367f1cf62704ed3c827b9b68dcb5397
3 years agobuild: Respect $(OBJDUMP)
Sam James [Sun, 23 Jan 2022 15:36:55 +0000 (15:36 +0000)] 
build: Respect $(OBJDUMP)

We already search for it in `./configure` so let's respect
the result of that search.

This helps with cross-compilation and any other cases
where one might want to choose a different toolchain.

Closes: !16
Bug: https://bugs.gentoo.org/831863
Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
3 years agoRelease libbsd 0.11.4 0.11.4
Guillem Jover [Sat, 22 Jan 2022 21:41:51 +0000 (22:41 +0100)] 
Release libbsd 0.11.4

3 years agoman: Add missing comma in .Dd for tree(3)
Guillem Jover [Wed, 1 Dec 2021 23:35:05 +0000 (00:35 +0100)] 
man: Add missing comma in .Dd for tree(3)

Reported-by: Thorsten Glaser <tg@mirbsd.de>
3 years agoman: Update tree(3) man page from OpenBSD
Guillem Jover [Tue, 30 Nov 2021 03:00:54 +0000 (04:00 +0100)] 
man: Update tree(3) man page from OpenBSD

This man page has a BSD-3-clause-author license instead of the old
BSD-4-clause license.

3 years agobuild: Clarify link-time warnings
Guillem Jover [Sun, 28 Nov 2021 22:19:16 +0000 (23:19 +0100)] 
build: Clarify link-time warnings

Mention the involved function instead of stating an implicit "this
function". Mention libbsd when proposing using an alternative libmd
to make the context clear.

3 years agoSwitch md5 compatibility logic back to direct linking
Guillem Jover [Sun, 28 Nov 2021 21:44:08 +0000 (22:44 +0100)] 
Switch md5 compatibility logic back to direct linking

When using the recent dlsym() based wrapper, we are not requiring any
symbol from libmd, as we resolve those dynamically at run-time. We were
ending up linking against libmd because in another part of the code we
require (depending on the architecture) the SHA512 functions for the
getentropy() local implementation. But that function might be provided
by the system libc on some systems, which means we end up not linking
against libmd at all.

To solve this we go back to the previous simpler solution of linking
directly, which had the main drawback of then making programs fail to
link when not specifying -lmd (on platforms that need it). And then
switch the .so link point from a symlink to a linker script, so that we
can inject the -lmd library as-needed. This is similar to what glibc is
doing.

Fixes: commit 31f034e3862debda8615a449b1c11c4d6920dcc7
3 years agobuild: Split libmd dependency due to MD5 functions from SHA requirements
Guillem Jover [Sun, 28 Nov 2021 21:40:58 +0000 (22:40 +0100)] 
build: Split libmd dependency due to MD5 functions from SHA requirements

To be able to rework the md5 deprecation logic, we need to detangle when
we depend on libmd due to requiring MD5 functions, which might be
otherwise provided by libc, or when we require SHA functions for the
internal getentropy() implementation.

3 years agobuild: Add new libbsd_symver_weak() macro
Guillem Jover [Sun, 28 Nov 2021 21:34:59 +0000 (22:34 +0100)] 
build: Add new libbsd_symver_weak() macro

We will use it for the reworked md5 deprecation logic.

3 years agotest: Check that strdup() does not fail
Guillem Jover [Sat, 27 Nov 2021 20:09:18 +0000 (21:09 +0100)] 
test: Check that strdup() does not fail

Warned-by: gcc
3 years agogetentropy: Add missing prototype for BSD variant
Guillem Jover [Sat, 27 Nov 2021 20:07:00 +0000 (21:07 +0100)] 
getentropy: Add missing prototype for BSD variant

Warned-by: gcc
3 years agonlist: Remove condition which is always true
Guillem Jover [Sat, 27 Nov 2021 19:26:05 +0000 (20:26 +0100)] 
nlist: Remove condition which is always true

The nlist() function is limited to handle ELF binaries of the same class
as size as the size_t of the architecture built.

In addition the SIZE_T_MAX macro is BSD specific, and was falling back
to the wrong constant on most 64-bit non-BSD systems.

Warned-by: gcc
3 years agobuild: Append __ after __attribute and __typeof keywords
Guillem Jover [Sat, 27 Nov 2021 21:52:28 +0000 (22:52 +0100)] 
build: Append __ after __attribute and __typeof keywords

Be consistent with other usages in the code base.

3 years agobuild: Ignore backup files
Guillem Jover [Sat, 27 Nov 2021 05:54:49 +0000 (06:54 +0100)] 
build: Ignore backup files

3 years agotest: Explicitly mark symbols as used
Victor Westerhuis [Fri, 26 Nov 2021 19:24:20 +0000 (20:24 +0100)] 
test: Explicitly mark symbols as used

Because some of the symbols are not otherwise referenced, GCC would like
to remove them.

Closes: !14
Signed-off-by: Guillem Jover <guillem@hadrons.org>
3 years agobuild: Enable .init_array support when building with LTO
Victor Westerhuis [Fri, 26 Nov 2021 19:01:18 +0000 (20:01 +0100)] 
build: Enable .init_array support when building with LTO

Because these symbols are not otherwise referenced, GCC would like
to remove them.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
3 years agoman: Fix .Nx macro usage
Guillem Jover [Thu, 7 Oct 2021 21:08:42 +0000 (23:08 +0200)] 
man: Fix .Nx macro usage

Its arguments are used as version numbers, so we need continue the
content on the next line.

3 years agobuild: Allow building with -flto on gcc-10 and newer
Alexander Miller [Thu, 30 Sep 2021 01:39:57 +0000 (03:39 +0200)] 
build: Allow building with -flto on gcc-10 and newer

Global asm statements (like .symver directives) do not work reliably
in gcc with link time optimization. Use the symver attribute introduced
with gcc-10 to set symbol versions instead, if available.

[guillem@hadrons.org:
 - Simplify by using __has_attribute fallback from <sys/cdefs.h>.
 - Coding style changes. ]

Signed-off-by: Guillem Jover <guillem@hadrons.org>
3 years agotest: Fix pipe_feed() to allow checking fprintf format strings
Guillem Jover [Mon, 1 Mar 2021 04:14:10 +0000 (05:14 +0100)] 
test: Fix pipe_feed() to allow checking fprintf format strings

Warned-by: gcc -W
3 years agobuild: Add missing proctitle unit test program
Guillem Jover [Sat, 6 Mar 2021 23:22:59 +0000 (00:22 +0100)] 
build: Add missing proctitle unit test program

3 years agotest: Do not pass NULL as the first funopen() argument
Guillem Jover [Tue, 17 Aug 2021 01:14:57 +0000 (03:14 +0200)] 
test: Do not pass NULL as the first funopen() argument

Warned-by: gcc -W
3 years agobuild: Detect sed at configure time
Guillem Jover [Tue, 17 Aug 2021 00:59:59 +0000 (02:59 +0200)] 
build: Detect sed at configure time

Check whether sed is available and use the implementation matching the
requirements via the SED variable.

3 years agovis: Add prototypes for strnvis() and strnunvis() variants
Guillem Jover [Tue, 2 Mar 2021 04:18:04 +0000 (05:18 +0100)] 
vis: Add prototypes for strnvis() and strnunvis() variants

Warned-by: gcc
3 years agotest: Cast literal strings to (char *) on n_name assignment
Guillem Jover [Mon, 1 Mar 2021 23:48:31 +0000 (00:48 +0100)] 
test: Cast literal strings to (char *) on n_name assignment

The member is declared as n_name so we cannot directly assign a literal
string constant.

Warned-by: gcc
3 years agoAdd missing prototypes to functions
Guillem Jover [Mon, 1 Mar 2021 23:48:02 +0000 (00:48 +0100)] 
Add missing prototypes to functions

Warned-by: gcc
3 years agobuild: Add compiler warnings support
Guillem Jover [Fri, 19 Feb 2021 05:55:17 +0000 (06:55 +0100)] 
build: Add compiler warnings support

Detect as many warnings as possible during configure and enable them
if the user did not supply any, so that any such problem can be spotted
and fixed.

4 years agonlist: Remove repeated shadowing variable declaration 1/merge
Guillem Jover [Fri, 19 Feb 2021 05:51:18 +0000 (06:51 +0100)] 
nlist: Remove repeated shadowing variable declaration

Warned-by: gcc
4 years agogetentropy: Fix function cast for getauxval()
Guillem Jover [Sat, 20 Feb 2021 21:22:54 +0000 (22:22 +0100)] 
getentropy: Fix function cast for getauxval()

Warned-by: gcc
4 years agotest: Add proper prototypes for main() function
Guillem Jover [Fri, 19 Feb 2021 05:49:53 +0000 (06:49 +0100)] 
test: Add proper prototypes for main() function

Warned-by: gcc
4 years agoMark local functions as static
Guillem Jover [Fri, 19 Feb 2021 05:49:24 +0000 (06:49 +0100)] 
Mark local functions as static

Warned-by: gcc
4 years agoAdd link-time warnings to MD5 wrapper functions
Guillem Jover [Thu, 11 Feb 2021 03:41:46 +0000 (04:41 +0100)] 
Add link-time warnings to MD5 wrapper functions

Let's get the word out that these functions are deprecated and should be
switched away from.

4 years agoRequire a semicolon for libbsd_link_warning() macro
Guillem Jover [Thu, 11 Feb 2021 03:40:48 +0000 (04:40 +0100)] 
Require a semicolon for libbsd_link_warning() macro

Remove the semicolon in the macro definition to force adding one on the
call sites, to make the code look like an actual function.

4 years agoman: Call the libbsd-ctor library by its name instead of bsd-ctor
Guillem Jover [Thu, 18 Feb 2021 22:38:30 +0000 (23:38 +0100)] 
man: Call the libbsd-ctor library by its name instead of bsd-ctor

4 years agoman: Fix pkg-config(1) references in libbsd(7) man page
Guillem Jover [Thu, 18 Feb 2021 22:38:30 +0000 (23:38 +0100)] 
man: Fix pkg-config(1) references in libbsd(7) man page

4 years agobuild: Add code coverage support in the GitLab CI
Guillem Jover [Sun, 28 Feb 2021 04:16:01 +0000 (05:16 +0100)] 
build: Add code coverage support in the GitLab CI

4 years agobuild: Use apt-get instead of apt in the GitLab CI
Guillem Jover [Sun, 28 Feb 2021 04:14:54 +0000 (05:14 +0100)] 
build: Use apt-get instead of apt in the GitLab CI

The former is to be used programmatically, while the latter is intended
for interactive use.

4 years agobuild: Add a Libs.private field to overlay pkg-config file
Guillem Jover [Tue, 9 Feb 2021 07:35:36 +0000 (08:35 +0100)] 
build: Add a Libs.private field to overlay pkg-config file

We need to list all internal libraries there so that we can statically
link.

Fixes: commit 2374f409defb380d0c5c07f28b9c166ef8bdc742
4 years agoRelease libbsd 0.11.3 0.11.3
Guillem Jover [Tue, 9 Feb 2021 05:14:25 +0000 (06:14 +0100)] 
Release libbsd 0.11.3

4 years agoSwitch libmd wrapper to use dlsym()
Guillem Jover [Tue, 9 Feb 2021 04:57:37 +0000 (05:57 +0100)] 
Switch libmd wrapper to use dlsym()

Switch from the previous versioned symbol implementation which required
users to also link against the message digest provider explicitly, or
they would fail to find the symbols, to an implementation that loads
the symbols from the linked library providing the functions using
dlsym(), thus preserving backwards compatibility.

4 years agobuild: Add a Libs.private field to pkg-config file
Guillem Jover [Tue, 9 Feb 2021 04:56:49 +0000 (05:56 +0100)] 
build: Add a Libs.private field to pkg-config file

We need to list all internal libraries there so that we can statically
link.

4 years agobuild: Use a single variable to track libraries to link against
Guillem Jover [Tue, 9 Feb 2021 05:04:38 +0000 (06:04 +0100)] 
build: Use a single variable to track libraries to link against

Using various variables means we have to keep these in sync in various
places. Just use a single variable that we can use anywhere where this
is needed.

4 years agobuild: Fix message digest library checks
Guillem Jover [Tue, 9 Feb 2021 05:02:46 +0000 (06:02 +0100)] 
build: Fix message digest library checks

They were not failing when not finding the SHA-2 functions and
were hardcoding -lmd regardless of what library had been found.

4 years agoUse uintptr_t and size_t instead of __-prefixed types in <sys/cdefs.h>
Guillem Jover [Tue, 9 Feb 2021 01:46:49 +0000 (02:46 +0100)] 
Use uintptr_t and size_t instead of __-prefixed types in <sys/cdefs.h>

The __-prefixed types cannot be assumed to be defined. Use the standard
types instead.

Closes: #6
4 years agoRelease libbsd 0.11.2 0.11.2
Guillem Jover [Mon, 8 Feb 2021 02:59:56 +0000 (03:59 +0100)] 
Release libbsd 0.11.2

4 years agoclosefrom: Use close_range() on Linux when available
Guillem Jover [Mon, 8 Feb 2021 02:45:06 +0000 (03:45 +0100)] 
closefrom: Use close_range() on Linux when available

Closes: !11
Based-on-patch-by: cptpcrd <cptpcrd.git@gmail.com>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
4 years agoclosefrom: Handle lowfd < 0 properly
cptpcrd [Sun, 7 Feb 2021 19:22:21 +0000 (14:22 -0500)] 
closefrom: Handle lowfd < 0 properly

More important if close_range() is going to be used, since casting
negative values to 'unsigned int' might hide the errors.

[guillem@hadrons.org: Minor coding style fix. ]

Signed-off-by: Guillem Jover <guillem@hadrons.org>
4 years agoclosefrom: Import some changes from sudo
Guillem Jover [Mon, 8 Feb 2021 01:52:50 +0000 (02:52 +0100)] 
closefrom: Import some changes from sudo

Take most of the changes done in sudo, but preserve the existing local
changes and refactoring.

In addition, refactor pstat implementation into closefrom_pstat(), so
that the code is easier to read, and requires no conditional
declarations.

4 years agoUpdate <sys/queue.h> from FreeBSD
Faidon Liambotis [Sun, 7 Feb 2021 18:47:00 +0000 (20:47 +0200)] 
Update <sys/queue.h> from FreeBSD

This brings <sys/queue.h> to the most up-to-date version from FreeBSD,
incorporating 18 commits from the past 5 years (2015-02-24 - 2021-01-25):

  $ git log --oneline 9090a24aed70..8d55837dc133 sys/sys/queue.h share/man/man3/queue.3

Only minimal changes compared to the FreeBSD version have been applied
(queue.3 -> queue.3bsd, _LIBBSD_ prefix).

[guillem@hadrons.org: Remove reference to kernel mode in man page. ]

Closes: !12
Signed-off-by: Guillem Jover <guillem@hadrons.org>
4 years agotest: Improve code coverage for strnstr(3) unit tests
Guillem Jover [Sun, 7 Feb 2021 22:24:51 +0000 (23:24 +0100)] 
test: Improve code coverage for strnstr(3) unit tests

4 years agoman: Update libbsd(7) man page with updates in 0.11.0
Guillem Jover [Sun, 7 Feb 2021 09:56:51 +0000 (10:56 +0100)] 
man: Update libbsd(7) man page with updates in 0.11.0

4 years agobuild: Install libmd-dev in the gitlab CI
Guillem Jover [Sun, 7 Feb 2021 09:37:18 +0000 (10:37 +0100)] 
build: Install libmd-dev in the gitlab CI

4 years agobuild: Switch gitlab CI to use a Debian buster
Guillem Jover [Sun, 7 Feb 2021 09:35:57 +0000 (10:35 +0100)] 
build: Switch gitlab CI to use a Debian buster

4 years agoRelease libbsd 0.11.1 0.11.1
Guillem Jover [Sun, 7 Feb 2021 01:03:59 +0000 (02:03 +0100)] 
Release libbsd 0.11.1

4 years agoAdd support for new LIBBSD_VIS_OPENBSD selection macro
Guillem Jover [Sat, 6 Feb 2021 22:28:42 +0000 (23:28 +0100)] 
Add support for new LIBBSD_VIS_OPENBSD selection macro

This will make it possible to explicitly select the OpenBSD vis
implementation (the current default) for code of OpenBSD origins.

4 years agoRelease libbsd 0.11.0 0.11.0
Guillem Jover [Sat, 6 Feb 2021 23:23:43 +0000 (00:23 +0100)] 
Release libbsd 0.11.0

4 years agoUpdate copyright claims
Guillem Jover [Sat, 6 Feb 2021 23:09:45 +0000 (00:09 +0100)] 
Update copyright claims

4 years agoUse libmd hashing function implementations instead of embedding our own
Guillem Jover [Sat, 6 Feb 2021 23:09:30 +0000 (00:09 +0100)] 
Use libmd hashing function implementations instead of embedding our own

This splits the implementation responsibilities, and reduces embedded
code copies, which was one of the driving points with this project to
start with, so it's nice to give a good example.