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