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.
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.
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>
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.
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>
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.
[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>
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>
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>
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.
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.
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.
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>
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>
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
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>
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>
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>