]> git.ipfire.org Git - thirdparty/libbsd.git/log
thirdparty/libbsd.git
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.

4 years agoProvide a default progname on Windows
Aaron Dierking [Thu, 5 Jul 2018 21:47:47 +0000 (14:47 -0700)] 
Provide a default progname on Windows

[guillem@hadrons.org:
 - Remove .exe extension from default program name.
 - Call reallocarray() once by switching to a «do {} while» loop.
 - Minor coding style fixes. ]

Signed-off-by: Guillem Jover <guillem@hadrons.org>
4 years agoImport pwcache module from OpenBSD
Guillem Jover [Sat, 6 Feb 2021 22:43:12 +0000 (23:43 +0100)] 
Import pwcache module from OpenBSD

4 years agoman: Remove empty line in reallocarray(3bsd)
Guillem Jover [Sun, 7 Feb 2021 00:27:51 +0000 (01:27 +0100)] 
man: Remove empty line in reallocarray(3bsd)

Warned-by: lintian
Fixes: commit 01f0d1ea1e71f1018a009ebd9203dd48e6d90c45
4 years agoAdd recallocarray() and freezero() from OpenBSD
Faidon Liambotis [Thu, 31 Dec 2020 10:46:03 +0000 (12:46 +0200)] 
Add recallocarray() and freezero() from OpenBSD

Add recallocarray(), introduced in OpenBSD 6.1, and freezero(),
introduced in OpenBSD 6.2. The former is imported as-is from OpenBSD,
while the latter is the non-malloc-internal branch of the same code (and
also the OpenSSH portable variant).

Both of these originated in OpenBSD, but have also been implemented by
IllumOS, cf. https://www.illumos.org/issues/8546

Documentation for these functions is in malloc(3) upstream, the relevant
parts of which were previously imported in reallocarray(3bsd). Update
reallocarray(3bsd) with the changes that were introduced since, and add
the relevant bits for recallocarray() and freezero(), plus aliases.

[guillem@hadrons.org: Update copyright in COPYING. ]

Closes: !10
Signed-off-by: Guillem Jover <guillem@hadrons.org>
4 years agoFix ELF detection on Intel compilers
Seth R Johnson [Thu, 14 Nov 2019 12:26:41 +0000 (07:26 -0500)] 
Fix ELF detection on Intel compilers

The Intel compiler does not define __amd64__ on x86_64 platforms;
instead, like other compilers, it defines __x86_64__ .

Closes: !8
Signed-off-by: Guillem Jover <guillem@hadrons.org>
4 years agoman: Add a timespec(3bsd) alias to timeval(3bsd)
Guillem Jover [Sun, 20 Sep 2020 01:30:20 +0000 (03:30 +0200)] 
man: Add a timespec(3bsd) alias to timeval(3bsd)

Even though man-pages project now includes man pages for system data
types, we still include these for any other system that does not have
them, to provide a self-contained project with code and documentation.

4 years agoman: Add missing LIBRARY section
Guillem Jover [Wed, 16 Sep 2020 21:41:28 +0000 (23:41 +0200)] 
man: Add missing LIBRARY section

4 years agoFix coding style
Guillem Jover [Sun, 20 Sep 2020 01:32:57 +0000 (03:32 +0200)] 
Fix coding style

4 years agotest: Fix short lived memory leaks
Guillem Jover [Sun, 16 Aug 2020 20:01:42 +0000 (22:01 +0200)] 
test: Fix short lived memory leaks

These are non-issues, but having a clean ASAN test suite makes it
possible to detect actual problems in the tested code.

Warned-by: gcc ASAN
4 years agofunopen: Fix memory leak in funopen_close() when closefn is NULL
Guillem Jover [Sun, 16 Aug 2020 19:58:04 +0000 (21:58 +0200)] 
funopen: Fix memory leak in funopen_close() when closefn is NULL

We need to free the cookiewrap even when the closefn method is NULL.

Warned-by: gcc ASAN
4 years agobuild: Detect support for --version-script in ld
Guillem Jover [Fri, 15 Nov 2019 23:04:18 +0000 (00:04 +0100)] 
build: Detect support for --version-script in ld

4 years agoDo not define SIZE_T_MAX if already defined
Guillem Jover [Mon, 12 Aug 2019 21:52:10 +0000 (23:52 +0200)] 
Do not define SIZE_T_MAX if already defined

4 years agoman: Add missing doc-operating-system-NetBSD string variable
Guillem Jover [Mon, 12 Aug 2019 21:25:20 +0000 (23:25 +0200)] 
man: Add missing doc-operating-system-NetBSD string variable

Fixes: commit 99320b9168ffb0112def1a712e8d59441d1b46d9.
4 years agoAdd missing strnvisx() to the symbols script
Guillem Jover [Mon, 26 Aug 2019 03:39:17 +0000 (05:39 +0200)] 
Add missing strnvisx() to the symbols script

Fixes: commit 2d7de186e9cb19a756c0630ee85cb3f2d29b3484.
5 years agoRelease libbsd 0.10.0 0.10.0
Guillem Jover [Wed, 7 Aug 2019 16:34:09 +0000 (18:34 +0200)] 
Release libbsd 0.10.0

5 years agoerr: Add err(), warn(), errx() and warnx() familiy of functions
Guillem Jover [Tue, 6 Aug 2019 13:49:41 +0000 (15:49 +0200)] 
err: Add err(), warn(), errx() and warnx() familiy of functions

Some systems such as Windows or musl-libc based ones do not have these
BSD extensions. In addition libbsd itself is making use of the warnx()
functions, so we better provide these interfaces in case they are
missing.

5 years agoerr: Rewrite warnc() and errc() family functions to be standalone
Guillem Jover [Tue, 6 Aug 2019 13:37:43 +0000 (15:37 +0200)] 
err: Rewrite warnc() and errc() family functions to be standalone

Do not depend on the system vwarn() and verr() functions to implement
the *c() variants, as the system might actually lack any of the <err.h>
BSD extensions.

5 years agoerr: Mark error functions as non-returning with __dead2
Guillem Jover [Tue, 6 Aug 2019 13:29:54 +0000 (15:29 +0200)] 
err: Mark error functions as non-returning with __dead2

5 years agoAdd e2k support for nlist()
Michael Shigorin [Tue, 6 Aug 2019 22:02:09 +0000 (00:02 +0200)] 
Add e2k support for nlist()

This is a Russian 64-bit LE VLIW architecture named Elbrus
(formerly Elbrus 2000).

[guillem@hadrons.org:
 - Place the entry in alphabetical order. ]

Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agoAdd AArch64 ILP32 support to nlist()
Frank Schaefer [Tue, 28 May 2019 21:04:54 +0000 (16:04 -0500)] 
Add AArch64 ILP32 support to nlist()

Closes: !7
Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agoAdd ARC support to nlist()
Rosen Penev [Fri, 17 May 2019 01:44:56 +0000 (01:44 +0000)] 
Add ARC support to nlist()

Closes: !6
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agoAdd a comment to note the ELF entries are sorted alphabetically
Guillem Jover [Tue, 6 Aug 2019 22:00:15 +0000 (00:00 +0200)] 
Add a comment to note the ELF entries are sorted alphabetically

This should help people wanting to add new entries.

5 years agoRe-allow direct use of nlist.n_name in <nlist.h>
James Clarke [Sun, 3 Feb 2019 00:11:15 +0000 (00:11 +0000)] 
Re-allow direct use of nlist.n_name in <nlist.h>

Commit e8d340de ("Remove a.out support from nlist()") introduced a copy
of the definition of nlist from a.out.h. However, as well as having
n_name inside n_un, on the various BSDs n_name could also be accessed
as a direct member of nlist, and this is made use of by FreeBSD's
usr.bin/netstat/main.c. Thus we should also add the same enclosing
anonymous union.

[guillem@hadrons.org:
 - Add a minimal unit test. ]

Closes: !4
Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agonlist: Fix out-of-bounds read on strtab
Guillem Jover [Wed, 7 Aug 2019 20:58:30 +0000 (22:58 +0200)] 
nlist: Fix out-of-bounds read on strtab

When doing a string comparison for a symbol name from the string table,
we should make sure we do a bounded comparison, otherwise a non-NUL
terminated string might make the code read out-of-bounds.

Warned-by: coverity
5 years agonlist: Fix unbounded malloc() calls
Guillem Jover [Sat, 15 Jun 2019 12:33:32 +0000 (14:33 +0200)] 
nlist: Fix unbounded malloc() calls

There are a couple of malloc() calls with unbounded size arguments,
coming from the parsed file. We need to make sure the size is not
larger than the file being parsed, otherwise we might end up with
out of memory conditions.

Reported-by: Daniel Hodson <daniel@elttam.com.au>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agonlist: Fix pread() return value check
Guillem Jover [Sat, 15 Jun 2019 12:33:32 +0000 (14:33 +0200)] 
nlist: Fix pread() return value check

We should check for partial reads, and not continue in those cases,
as we are not retrying them, otherwise we might end up operating on
uninitialized data.

Reported-by: Daniel Hodson <daniel@elttam.com.au>
Based-on-patch-by: Daniel Hodson <daniel@elttam.com.au>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agonlist: Check whether sh_link is within bounds
Guillem Jover [Sat, 15 Jun 2019 12:33:32 +0000 (14:33 +0200)] 
nlist: Check whether sh_link is within bounds

The sh_link members should be >= e_shnum, otherwise we might do out of
bounds read accesses on the shdr array.

Reported-by: Daniel Hodson <daniel@elttam.com.au>
Based-on-patch-by: Daniel Hodson <daniel@elttam.com.au>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agonlist: Check that e_shnum and e_shentsize are within bounds
Guillem Jover [Sat, 15 Jun 2019 12:33:32 +0000 (14:33 +0200)] 
nlist: Check that e_shnum and e_shentsize are within bounds

The e_shnum must not be 0, otherwise we will do a zero sized allocation
and further processing of the executable will lead to out of bounds
read/write accesses. The e_shentsize must be equal to sizeof(Elf_Shdr),
otherwise we will perform out of bounds read accesses on the shdr array.

Reported-by: Daniel Hodson <daniel@elttam.com.au>
Based-on-patch-by: Daniel Hodson <daniel@elttam.com.au>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agonlist: Check whether the nl argument is not NULL
Guillem Jover [Sat, 15 Jun 2019 12:33:32 +0000 (14:33 +0200)] 
nlist: Check whether the nl argument is not NULL

This prevents programming errors.

Reported-by: Daniel Hodson <daniel@elttam.com.au>
Based-on-patch-by: Daniel Hodson <daniel@elttam.com.au>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agoman: Add man page sections to function references
Guillem Jover [Wed, 31 Jul 2019 01:49:43 +0000 (03:49 +0200)] 
man: Add man page sections to function references

Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agoman: Fix typo
Sebastian [Sun, 10 Mar 2019 10:03:12 +0000 (10:03 +0000)] 
man: Fix typo

Closes: !5
Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agoman: Fix typos
Guillem Jover [Wed, 31 Jul 2019 01:49:24 +0000 (03:49 +0200)] 
man: Fix typos

Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agoman: Replace references to a.out(5) with elf(5)
Guillem Jover [Wed, 31 Jul 2019 01:02:38 +0000 (03:02 +0200)] 
man: Replace references to a.out(5) with elf(5)

The a.out(5) support in nlist(3) got removed some time ago, and
there is now only elf(5) support.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agoman: Define doc-operating-system-NetBSD string variables
Guillem Jover [Thu, 13 Jun 2019 21:43:57 +0000 (23:43 +0200)] 
man: Define doc-operating-system-NetBSD string variables

This way we do not depend on the installed groff being new enough.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agoman: Use major.minor version for .Nx macros
Guillem Jover [Thu, 13 Jun 2019 21:42:49 +0000 (23:42 +0200)] 
man: Use major.minor version for .Nx macros

The macro only recognizes this version form, and not just major alone.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agoman: Add doc-str-Lb-libbsd aliases for str-Lb-libbsd
Guillem Jover [Thu, 13 Jun 2019 21:36:09 +0000 (23:36 +0200)] 
man: Add doc-str-Lb-libbsd aliases for str-Lb-libbsd

groff(1) has changed the internal layout for the .Lb doc strings, but to
preserve backwards compatibility we cannot simply rename them, we need
to create new aliases so that these will work with old and new macros.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agoUpdate TODO
Guillem Jover [Wed, 31 Jul 2019 00:58:01 +0000 (02:58 +0200)] 
Update TODO

Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agoProvide a <sys/param.h> with MIN() and MAX()
Aaron Dierking [Thu, 14 Jun 2018 18:38:32 +0000 (11:38 -0700)] 
Provide a <sys/param.h> with MIN() and MAX()

Windows doesn't provide <sys/param.h>. Several libbsd sources require it
for MIN(), and these are useful non-system-specific macros anyway.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agobuild: Disable CRT warnings on Windows
Aaron Dierking [Thu, 14 Jun 2018 18:38:33 +0000 (11:38 -0700)] 
build: Disable CRT warnings on Windows

These warnings are not helpful for libbsd.

[guillem@hadrons.org:
 - Rename WINDOWS conditional to OS_WINDOWS.
 - Add a nil terminator to the AM_CPPFLAGS. ]

Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agobuild: Detect Windows/MinGW at configure time
Aaron Dierking [Thu, 14 Jun 2018 18:38:32 +0000 (11:38 -0700)] 
build: Detect Windows/MinGW at configure time

Extend the host OS checks to define an OS_WINDOWS automake conditional if
the host is MinGW-like. This will be useful for future Windows-specific
build tweaks.

[guillem@hadrons.org:
 - Rename WINDOWS conditional to OS_WINDOWS. ]

Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agobuild: Support platforms without symbol versioning
Guillem Jover [Tue, 6 Aug 2019 17:14:29 +0000 (19:14 +0200)] 
build: Support platforms without symbol versioning

The .symver directive is ELF-specific. On non-ELF platforms, work around
this with __attribute__((__alias__)) for the default symbol, and ignore
the variant versioned symbols.

Based-on-patch-by: Aaron Dierking <aarond@fb.com>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
5 years agobuild: Abstract symbol versioning via new libbsd_symver_* macros
Guillem Jover [Tue, 6 Aug 2019 16:51:45 +0000 (18:51 +0200)] 
build: Abstract symbol versioning via new libbsd_symver_* macros

This makes it more obvious what they are doing. It will make it easier
to make these directives more portable, as they are really ELF specific.

5 years agobuild: Use __register_atfork() only if really available
Guillem Jover [Tue, 6 Aug 2019 21:16:42 +0000 (23:16 +0200)] 
build: Use __register_atfork() only if really available

This is a glibc-specific symbol that has no public declaration. But is
being used by the OpenBSD and this implementation as a hack to avoid
having to link against the pthread library. This interface is at least
included in LSB 5.0 [L], and using pthread_atfork() is otherwise
problematic anyway [P].

 [L] <https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/baselib---register-atfork.html>
 [P] <http://austingroupbugs.net/view.php?id=851>

One problem is that we were using it whenever __GLIBC__ is defined,
which is supposed to be defined only on an actual glibc, but uClibc
defines that macro, but it does not provide the symbol on its noMMU
variant.

We add a new configure check that will try to link a program that uses
that symbol to make sure it is present.

Closes: !2
Reported-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
5 years agobuild: Fix check for clock_gettime() within librt
Guillem Jover [Tue, 6 Aug 2019 21:11:50 +0000 (23:11 +0200)] 
build: Fix check for clock_gettime() within librt

The check was always setting the libraries to link to include -lrt,
as the success case includes the builtin one. Handle the various
values.

7 years agoCorrect Clang feature detection
Aaron Dierking [Thu, 14 Jun 2018 18:38:31 +0000 (11:38 -0700)] 
Correct Clang feature detection

Clang's __GNUC__ and __GNUC_MINOR__ definitions are not reliable and may
not be defined at all when targeting the MSVC ABI. Use feature-checking
macros when possible or check for __clang__.

[guillem@hadrons.org: Update for __ protected keyword change. ]

Signed-off-by: Guillem Jover <guillem@hadrons.org>
7 years agoProtect C language extensions with two leading and trailing underscores
Guillem Jover [Sun, 17 Jun 2018 22:36:44 +0000 (00:36 +0200)] 
Protect C language extensions with two leading and trailing underscores

This should make their usage safer against user macros.

7 years agoGuard non-portable forwarded includes
Aaron Dierking [Thu, 14 Jun 2018 18:38:32 +0000 (11:38 -0700)] 
Guard non-portable forwarded includes

These headers are not available on Windows. <bsd/sys/cdefs.h> ensures
that __has_include() and __has_include_next() are defined.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
7 years agoWindows support for inet_net_pton()
Aaron Dierking [Thu, 14 Jun 2018 18:38:32 +0000 (11:38 -0700)] 
Windows support for inet_net_pton()

Signed-off-by: Guillem Jover <guillem@hadrons.org>
7 years agoWindows support for HASHFileChunk()
Aaron Dierking [Thu, 14 Jun 2018 18:38:32 +0000 (11:38 -0700)] 
Windows support for HASHFileChunk()

<io.h> provides the necessary file I/O functions.

[guillem@hadrons.org: Move include before <hashinc>. ]

Signed-off-by: Guillem Jover <guillem@hadrons.org>
7 years agoDon't require <grp.h>
Aaron Dierking [Thu, 14 Jun 2018 18:38:32 +0000 (11:38 -0700)] 
Don't require <grp.h>

This is only used in the overlay test and Windows does not provide it.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
7 years agoOnly define S_ISTXT if S_ISVTX is defined
Aaron Dierking [Thu, 14 Jun 2018 18:38:32 +0000 (11:38 -0700)] 
Only define S_ISTXT if S_ISVTX is defined

Windows doesn't provide S_ISVTX. Prefer not defining it rather than
defining it to something invalid.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
7 years agoUse CHAR_BIT instead of NBBY in strnvis()
Aaron Dierking [Thu, 14 Jun 2018 18:38:31 +0000 (11:38 -0700)] 
Use CHAR_BIT instead of NBBY in strnvis()

<sys/param.h> is not available on Windows.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
7 years agoReplace reintroduced legacy u_* type usage in strnvis() and strnunvis()
Aaron Dierking [Thu, 14 Jun 2018 18:38:31 +0000 (11:38 -0700)] 
Replace reintroduced legacy u_* type usage in strnvis() and strnunvis()

This fixes a regression caused by 2d7de18. These types are not available
on all systems.

Fixes: commit 2d7de186e9cb19a756c0630ee85cb3f2d29b3484
Signed-off-by: Guillem Jover <guillem@hadrons.org>
7 years agoRemove dead code in vis
Guillem Jover [Fri, 8 Jun 2018 22:08:14 +0000 (00:08 +0200)] 
Remove dead code in vis

The loop only executes while len > 0, and the trinary operator in the
function argument is checking against len >= 1 which will always be
true.

Warned-by: coverity
7 years agoFix vis family of functions to not leak
Guillem Jover [Wed, 6 Jun 2018 03:41:34 +0000 (05:41 +0200)] 
Fix vis family of functions to not leak

The code uses an internal helper function to avoid code repetition. But
to get there, the function takes a pointer to a pointer, so that the few
functions that require returning an allocated buffer can get hold of it
this way.

The problem is that the user might pass a NULL pointer and trigger an
internal allocation even if the functions are not expected to do so.

Add a new internal helper for non-allocations, that will assert that
condition, and make any other function that requires this behavior call
this one instead.

Warned-by: coverity
7 years agoflopen: Add missing <fcntl.h> include
Baruch Siach [Tue, 5 Jun 2018 16:21:46 +0000 (19:21 +0300)] 
flopen: Add missing <fcntl.h> include

Commit 993828d84ee (Add flopenat() function from FreeBSD) dropped the
fcntl.h header. This breaks the build with musl libc:

flopen.c: In function ‘vflopenat’:
flopen.c:60:14: error: ‘O_CREAT’ undeclared (first use in this function)
  if (flags & O_CREAT) {
              ^~~~~~~

Restore the fcntl.h header include to fix the build.

Fixes: commit 993828d84eed0468c6c15b2818e534e6b134b8e4
Submitted-also-by: parazyd <parazyd@dyne.org>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
7 years agobuild: Simplify gitlab CI configuration
Guillem Jover [Thu, 31 May 2018 01:59:49 +0000 (03:59 +0200)] 
build: Simplify gitlab CI configuration

Merge all stages so that we do not need to pass artifacts around.
Quiesce «apt install».

7 years agobuild: Install git in gitlab CI configuration
Guillem Jover [Thu, 31 May 2018 01:46:14 +0000 (03:46 +0200)] 
build: Install git in gitlab CI configuration

7 years agobuild: Fix gitlab CI configuration
Guillem Jover [Thu, 31 May 2018 01:34:07 +0000 (03:34 +0200)] 
build: Fix gitlab CI configuration

Run «apt install» in non-interactive mode, and do not install
Recommends. Replace build-essential, which is rather fat, with gcc
and make. Execute autogen instead of autoreconf directly.

7 years agobuild: Add a gitlab CI configuration file
Guillem Jover [Wed, 30 May 2018 23:45:28 +0000 (01:45 +0200)] 
build: Add a gitlab CI configuration file

7 years agoman: Fix comma splice
Jakub Wilk [Tue, 22 May 2018 11:08:56 +0000 (13:08 +0200)] 
man: Fix comma splice

Signed-off-by: Guillem Jover <guillem@hadrons.org>
7 years agoman: Fix name of the function injected by libbsd-ctor
Jakub Wilk [Tue, 22 May 2018 11:08:55 +0000 (13:08 +0200)] 
man: Fix name of the function injected by libbsd-ctor

Signed-off-by: Guillem Jover <guillem@hadrons.org>
7 years agoRelease libbsd 0.9.1 0.9.1
Guillem Jover [Tue, 22 May 2018 14:03:59 +0000 (16:03 +0200)] 
Release libbsd 0.9.1

7 years agoFix strnvis() and strnunvis() NetBSD ABI break
Guillem Jover [Tue, 22 May 2018 11:50:44 +0000 (13:50 +0200)] 
Fix strnvis() and strnunvis() NetBSD ABI break

The NetBSD implementations have different prototypes to the ones coming
from OpenBSD, which will break builds, and have caused segfaults at
run-time. We provide now both interfaces with different prototypes as
different version nodes allow selecting them at compile-time, defaulting
for now to the OpenBSD one to avoid build-time breakage, while emitting
a compile-time warning. Later on, in 0.10.0, we will be switching the
compile-time default to the NetBSD version.

Ref: http://gnats.netbsd.org/44977
Fixes: https://bugs.debian.org/899282
7 years agoAdd symbol redirection support
Guillem Jover [Tue, 22 May 2018 13:43:48 +0000 (15:43 +0200)] 
Add symbol redirection support

We need this to be able to select different version symbols at
compile-time.

7 years agoFix COPYING file format
Guillem Jover [Mon, 21 May 2018 20:41:23 +0000 (22:41 +0200)] 
Fix COPYING file format

We cannot refer to a License short-name if that is not on its own
License paragraph. Split several other common License fields into
their own paragraphs to avoid this problem in the future.

7 years agoRelease libbsd 0.9.0 0.9.0
Guillem Jover [Mon, 21 May 2018 02:41:56 +0000 (04:41 +0200)] 
Release libbsd 0.9.0