src


Log

Author Commit Date CI Message
Hanno Boeck c8f0723d 2016-01-27T15:10:11 Fix heap buffer overflow in fgetwln() In the function fgetwln() there's a 4 byte heap overflow. There is a while loop that has this check to see whether there's still enough space in the buffer: if (!fb->len || wused > fb->len) { If this is true more memory gets allocated. However this test won't be true if wused == fb->len, but at that point wused already points out of the buffer. Some lines later there's a write to the buffer: fb->wbuf[wused++] = wc; This bug was found with the help of address sanitizer. Warned-by: ASAN Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=93881 Signed-off-by: Guillem Jover <guillem@hadrons.org>
Guillem Jover 7a756875 2015-12-14T03:03:57 Add support for GNU/Hurd to getentropy() Reuse the getentropy code for Linux on the Hurd, which has fallbacks for when the better interfaces are not present. And remove all the code that is not supported currently on the Hurd. Ideally the Hurd should get an equivalent interfaces that does not suffer from the same problems as /dev/urandom.
Guillem Jover da137a09 2015-12-07T01:53:49 Add missing copyright and license headers
Guillem Jover d2f59a23 2015-12-02T04:00:58 Fix getentropy implementation to use the correct system hooks Include getentropy_<SYSTEM>.c instead of arc4random_<SYSTEM>.c.
Guillem Jover 01b77f0d 2015-12-02T03:32:13 Add support for GNU/kFreeBSD for closefrom() and getentropy()
Guillem Jover 75729394 2015-12-02T03:08:17 Unify most arc4random Unix hooks into a single file The Unix hook should work for most Unix-like systems, move glibc specific code there and a FreeBSd specific comment, and remove the rest. Also change the code to always fallback to use the generic Unix code. This should cover GNU/Hurd and GNU/kFreeBSD among others.
Guillem Jover 8493c7f2 2015-12-01T03:39:10 Use local SHA512 header Actually use the local private SHA512 header instead of relying on the OpenSSL one for no good reason. Add definition for expected macro SHA512_DIGEST_LENGTH.
Guillem Jover 874a0e51 2015-09-23T19:39:47 Update arc4random module from OpenBSD and LibreSSL Rework arc4random_stir() and arc4random_addrandom() code over the new internal API, and documentation in the man page. Adapt the code to the local build system. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=85827
Guillem Jover 9a9a8b2d 2015-09-23T19:39:47 Add private getentropy module from OpenBSD and LibreSSL Adapt the code to the local build system.
Guillem Jover 5f9265f8 2015-09-23T20:13:33 Add private SHA512 module from FreeBSD
Marek Vasut 1f77cdb4 2015-11-30T20:39:00 Add NIOS2 support to nlist() Add support for the NIOS2 soft-core CPU provided by Altera. Signed-off-by: Marek Vasut <marex@denx.de> Signed-off-by: Guillem Jover <guillem@hadrons.org> Cc: Ley Foon Tan <lftan@altera.com> Cc: Thomas Chou <thomas@wytron.com.tw> Cc: Walter Goossens <waltergoossens@home.nl>
Guillem Jover 0871daf7 2015-11-30T04:12:02 build: Move hash/helper.c into new libbsd_la_included_sources Use this variable in EXTRA_DIST and libbsd_la_DEPENDENCIES.
Guillem Jover 45443583 2015-09-23T19:37:37 Add explicit_bzero() function from OpenBSD
Guillem Jover 8641d8ae 2015-09-24T04:01:11 Make closefrom_procfs() fail when reallocarray() fails
Guillem Jover 0982dcd9 2015-09-23T07:10:18 Lock the file streams in fgetln() and fparseln() The fparseln() function had the NetBSD uppercase macros stubbed out, so replace them with the actual stdio ones. The fgetln() function was missing any locking at all.
Guillem Jover 151bc71d 2015-09-22T16:22:56 Add compile and link-time deprecation warnings for fgetln() Although the current implementation in libbsd is probably one of the safest ones around, it still poses some problems when used with many file streams. This function has now a replacement, that is both more standard and portable. Ask users to switch to getline(3) instead.
Guillem Jover 41ff37bb 2015-09-22T16:21:12 build: Add support for linker warnings
Guillem Jover 53d989a2 2014-12-13T21:28:36 Switch fparseln() implementation from fgetln() to getline()
Guillem Jover f50b197e 2015-09-22T22:30:17 test: Add fparseln() unit test
Brent Cook 9688ab26 2014-12-13T08:55:59 Avoid left shift overflow in reallocarray Some 64-bit platforms (e.g. Windows 64) have a 32-bit long. So, shifting 1UL 32-bits to the left causes an overflow. This replaces the constant 1UL with (size_t)1 so that we get the correct constant size for the platform. Import from OpenBSD. Signed-off-by: Guillem Jover <guillem@hadrons.org>
Guillem Jover 025b4480 2014-11-04T05:34:46 Make mergesort setup() static
Guillem Jover a6a101ef 2014-11-04T05:33:26 Use ANSI C prototypes
Guillem Jover 32388fe5 2014-11-03T23:21:52 Use reallocarray() instead of malloc() or realloc()
Guillem Jover 30e328cb 2014-11-03T00:43:27 Do not close file descriptors while scanning the /proc filesystem Closing file descriptors changes the content of the fd directories in the /proc filesystem, which means readdir() might get very confused. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=85663
Guillem Jover 4cc43915 2014-11-02T23:58:23 Move procfs based implementation into a new closefrom_procfs() function
Guillem Jover 34df1426 2014-11-05T20:01:53 Refactor file descriptor closure into a new closefrom_close()
Guillem Jover 3881c4fc 2014-11-02T00:23:00 Update closefrom() function Import from sudo. Adapt the build system to detect the required features.
Guillem Jover cfb4d462 2014-11-01T00:54:09 test: Move and activate fpurge() test case from module to a dedicated file
Guillem Jover 02b55488 2014-08-12T12:32:34 Use stdint integer types instead of BSD legacy ones
Guillem Jover e8d3d041 2014-07-20T01:48:20 build: Remove hard requirement for GNU .init_array section support In case the support is not available, just stop building the libbsd-ctor.a library, which is a nice to have thing, but should not have been a hard requirement from the start. This should allow to build libbsd on non-glibc based systems using another libc.
Benjamin Baier faa005cb 2014-06-27T02:05:11 Add reallocarray() function from OpenBSD Signed-off-by: Guillem Jover <guillem@hadrons.org>
Guillem Jover 36aca8c0 2014-06-26T21:43:55 Add stringlist module from NetBSD
Guillem Jover e8f93003 2014-06-26T21:32:11 Add getbsize() function Import code from DragonFlyBSD and man page from FreeBSD.
Christian Svensson a88bb838 2014-03-06T22:10:36 Add OpenRISC support to nlist() Signed-off-by: Guillem Jover <guillem@hadrons.org>
Guillem Jover 8d16c3df 2013-10-11T05:43:42 Add timeconv module from FreeBSD Inline license information from FreeBSD root dir COPYRIGHT file.
Guillem Jover f41fdcf1 2013-10-21T05:07:56 Add funopen() function This is a wrapper over the glibc fopencookie() function. We diverge from the FreeBSD, OpenBSD and DragonFlyBSD declarations, because seekfn() there wrongly uses fpos_t, assuming it's an integral type, and any code using that on a system where fpos_t is a struct (such as GNU-based systems or NetBSD) will fail to build. In which case, as the code has to be modified anyway, we might just as well use the correct declaration.
Guillem Jover 61b2dbb8 2013-07-15T01:44:30 Fix dehumanize_number() to correctly detect overflows Do not allow numbers greated than INT64_MAX and smaller than INT64_MIN. Clarify the positive sign value by prefixing it with an explicit +. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=66909
Guillem Jover 948bcf1d 2013-07-13T02:11:20 Warn when setproctitle() gets called before initialization Try to give a helpful message in case the program is not initializing the setproctitle() machinery.
Guillem Jover c5b95902 2013-07-11T12:25:54 Move setproctitle() automatic initialization to its own library The automatic initialization cannot be part of the main shared library, because there is no thread-safe way to change the environ global variable. This is not a problem if the initializaion happens just at program load time, but becomes one if the shared library is directly or indirectly dlopen()ed during the execution of the program, which could have either kept references to the old environ or could change it in some other thread. This has been observed for example on systems using Samba NSS modules. To avoid any other possible fallout, the constructor is split into a new static library that needs to be linked explicitly into programs using setproctitle(). As an additional safety measure the pkg-config linker flags will mark the program as not allowing to be dlopen()ed so that we avoid the problem described above. Reported-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com> Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=66679
Guillem Jover 3077d2ff 2013-07-12T22:15:58 build: Move version ABI from Makefile to configure.ac It's easier to find there, and the value can be reused in case we have to provide another shared library.
Guillem Jover 1bf0a555 2013-06-08T17:43:42 Release libbsd 0.5.2
Guillem Jover ad613d9d 2013-06-07T07:11:50 Create a shallow copy of environ before replacing it in setproctitle() Because clearenv() or setenv() might free the environ array of pointers, we should make sure to copy it so that we can access it later on when doing the deep copy via setenv(). Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=65470
Guillem Jover e084ce3f 2013-06-07T04:46:29 Specify setproctitle_stub() signature manually if typeof is missing Do not stop exporting the function in the version node even if typeof is not available, as that would break ABI.
Guillem Jover 50e4c55a 2013-06-08T17:55:19 Try to check if setproctitle() constructor got passed arguments
Guillem Jover 6faea4d2 2013-05-29T02:23:56 Force setproctitle() into .init_array section The GNU .init_array support is an extension over the standard System V ABI .init_array support, which passes the main() arguments to the init function. This support comes in three parts. First the dynamic linker (from glibc) needs to support it. Then function pointers need to be placed in the section, for example by using __attribute__((constructor)), that the compiler (gcc or clang for example) might place in section .ctors and the linker (from binutils) will move to .init_array on the output object, or by placing them directly into .init_array by the compiler when compiling. If this does not happen and the function pointers end up in .ctors, then they will not get passed the main() arguments, which we do really need in this case. But this relies on recent binutils or gcc having native .init_array support, and not having it disabled through --disable-initfini-array. To guarantee we get the correct behaviour, let's just place the function pointer in the .init_array section directly, so we only require a recent enough glibc. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=65029
Guillem Jover 46633647 2013-05-27T06:52:05 Release libbsd 0.5.1
Guillem Jover 95878823 2013-05-21T04:34:34 Release libbsd 0.5.0
Guillem Jover 509841b5 2013-05-25T15:44:57 build: Use AM_V_at for mkdir
Guillem Jover 7c4caa67 2013-05-25T15:36:11 Fix comparison between signed and unsigned integer compiler warnings
Guillem Jover 30349f89 2013-05-25T15:35:39 Update radixsort module from NetBSD Merge some interesting changes.
Guillem Jover 96a2dae3 2013-05-25T15:31:45 Update setmode module from NetBSD Merge some interesting changes.
Casper Dik a4812cdf 2013-03-15T01:13:58 Fix getpeereid() compilation on Solaris The code in getpeereid() is unlikely to compile as ucred_t is an opaque struct (ucred_t * works but ucred_t does not). Either you need to give a pointer initialized to NULL and getpeerucred() allocates a new ucred or you call it with an allocated ucred as in this patch. Signed-off-by: Guillem Jover <guillem@hadrons.org>
Guillem Jover d3a09e1c 2012-12-27T11:19:20 Switch dehumanize_number() to use expand_number() The function is a duplicate of expand_number(), but covering less prefixes and with a slightly different function signature. Spotted-by: Peter da Silva <resuna@gmail.com>
Guillem Jover e9933255 2013-05-25T17:11:53 Make setproctitle() available in 0.2 and 0.5 version nodes Make the 0.5 version the default, so that code wanting the actual implemented version can get a proper versioned depdendency. For code linked against the old version, make it available as an alias.
Guillem Jover c984dacd 2012-11-27T14:24:13 Implement sendmail semantics for setproctitle() Prefix the title with "progname: ", and skip it if the format string starts with '-' (which gets skipped on output too).
Guillem Jover 35785f8d 2012-11-25T21:10:53 Modify setproctitle() to conform to project coding style Use local getprogname()/setprogname() instead of reimplementing them locally. Use clearenv() if available, not just on glibc. Use bool instead of _Bool. Use paranthesis on sizeof. Fold the SPT_MIN macro into spt_min(). Make spt_init() static. Avoid unnecessary gotos.
William Ahern 2a0260d0 2012-11-28T11:09:02 Add a setproctitle() implementation Taken from libnostd. Signed-off-by: Guillem Jover <guillem@hadrons.org>
Guillem Jover f8d52ead 2012-11-23T18:33:23 Add x32 support to nlist()
Guillem Jover cf683a27 2012-11-23T18:32:35 Add arm64 (aka aarch64) to nlist()
Guillem Jover a97ce513 2012-11-23T21:19:45 Add new fgetwln() function Man page taken from FreeBSD.
Strake ee0489eb 2012-08-07T08:44:30 Add new fparseln() function Taken from NetBSD. [guillem@hadrons.org: - Import from NetBSD instead of FreeBSD to get a 3-clause BSD license, instead of a 4-clause one. - Define compatibility macros. - Change library from libc to libbsd and header in man page. - Add copyright information to COPYING. - Add symbol to map file. ] Signed-off-by: Guillem Jover <guillem@hadrons.org>
Guillem Jover cb7bc0d8 2012-11-25T22:09:43 Add file buffer pool support to fgetln() This avoids buffer overwrites during concurrent or intermixed calls to fgetln() when using more than one different stream (currently 32), which the original interface supports natively by using an internal buffer from the FILE structure. Although this workaround is rudimentary, it should cover most of the theoretically problematic cases.
Guillem Jover 1be0bdb2 2012-11-25T21:13:38 Add new strnstr() function Taken from FreeBSD.
Guillem Jover ff0d700d 2012-11-23T17:16:43 Add new wcslcat() and wcslcpy() functions Taken from FreeBSD.
Guillem Jover 918a4dba 2012-06-27T09:15:15 Release libbsd 0.4.2
Guillem Jover 14524b54 2012-06-03T07:39:42 build: Set default compiler variables from configure This centralizes the setting so there's no duplication anymore, makes sure the user supplied variables are never overridden, and are only set when using gcc. Reported-by: Samuli Suominen <ssuominen@gentoo.org>
Guillem Jover c21d788f 2012-06-01T08:20:37 Release libbsd 0.4.1
Guillem Jover fdcae577 2012-06-01T08:17:42 build: Set runtimelibdir to libdir This makes sure the install-exec-hook under src works as expected even when no runtimelibdir was specified, otherwise the symlinks end up pointing to non-existing targets. Reported-by: Ryan Mullen <rmmullen@gmail.com>
Guillem Jover e9e4a60d 2012-06-01T08:15:00 build: Use MKDIR_P variable instead of literal «mkdir -p»
Guillem Jover 309c82a0 2012-05-29T04:38:07 Release libbsd 0.4.0
Guillem Jover cd67cb14 2012-05-29T07:17:46 Use implicit <md5.h> from overlay instead explicit <bsd/md5.h> This was assuming an installed <bsd/md5.h> on the system, due to the build system not including -Iinclude/ anymore. Regression introduced in commit 901ed630fc64fca828e031bc8fa6780db9f05db1.
Guillem Jover e7f39760 2012-03-23T10:31:42 Add email address to my name
Guillem Jover 75299746 2012-01-03T08:58:01 Base getprogname() on program_invocation_short_name presence instead of glibc
Guillem Jover d5d91869 2012-01-03T09:08:35 Base fpurge() implementation on __fpurge presence instead of glibc
Guillem Jover f8e80630 2012-01-03T08:40:18 Base fgetln() implementation on getline presence instead of glibc
Robert Millan 64348583 2011-12-31T04:30:48 Add new expand_number() function Taken from FreeBSD. [guillem@hadrons.org: - Include <stdint.h> in <bsd/libutil.h>. ] Signed-off-by: Guillem Jover <guillem@hadrons.org>
Guillem Jover 943939d0 2011-12-31T08:39:44 Add new closefrom() function Code taken from sudo, man page from FreeBSD.
Guillem Jover 3d614131 2011-12-31T06:01:27 Base errc() and warnc() on vwarnc() and verrc() respectively
Guillem Jover 87232260 2011-07-06T16:29:26 Use system __progname variable in progname module if available
Guillem Jover b5cc17d6 2011-07-05T23:27:31 Use getexecname() if available for getprogname() This function is present on Solaris.
Guillem Jover 980f04f7 2012-01-03T08:58:52 build: Do not define already defined _GNU_SOURCE The macro is defined by configure on config.h which is now implicitly included by all source files.
Guillem Jover 8d2f12d7 2012-01-03T08:45:05 build: Include <config.h> through -include for all source files
Guillem Jover 88004b30 2011-12-31T07:31:47 build: Set -Wno-unused-parameter to default CFLAGS
Guillem Jover dcaa93d9 2010-12-17T11:13:04 build: Switch to autotools
Guillem Jover 0aa777f4 2011-12-31T07:35:52 Move .pc and .map files to src/
Guillem Jover 540ab03b 2011-12-31T06:50:40 Move man pages to man/
Guillem Jover 2fb7200d 2011-10-23T19:27:44 Fix typos in source comments Found by codespell.
Guillem Jover 4a6303ba 2011-06-08T02:10:38 Constify bsd_getopt(3) arguments This matches the standard declaration for getopt(3).
Guillem Jover b891772a 2011-05-29T02:49:14 Remove blank lines at EOF
Guillem Jover 9d042171 2011-05-25T07:38:36 Map getopt to bsd_getopt if we are using the overlay This will ensure the code can safely and correctly use optreset transparently.
Guillem Jover 94fe901e 2011-05-14T18:12:48 Abort compilation if fgetln cannot be wrapped
Guillem Jover 28585a58 2011-05-14T17:58:08 Add fpurge function
Guillem Jover 8b6a7477 2011-02-23T12:38:42 Conditionalize temporary compatibility inclusions These inclusions were in place for backward compatibility purposes, when the headers were split so that code using them would not break. Make it possible for applications to disable them by defining LIBBSD_CLEAN_INCLUDES so that buildability can be tested and fixed before they get removed in a subsequent release.
Guillem Jover c594192b 2011-05-14T14:17:44 Correct library name in man pages
Guillem Jover 8478e574 2011-02-23T13:14:22 Update libbsd header references in man pages Point to the namespaced path for libbsd specific headers.
Guillem Jover 520682e5 2011-02-23T14:04:57 Add support for transparent compilation This means that software being ported should not need to be modified in the usual case, as the libbsd headers will take over the standard namespace and fill the missing gaps, and include the system headers. To use this the new libbsd-transparent.pc file can be used through pkg-config, which should end up doing the right thing.
Guillem Jover 1497d347 2011-02-25T13:52:59 Initialize __progname to program_invocation_short_name As we do not have cooperation from the crt0 code to set __progname, we have to set it ourselves from getprogname() in case it's NULL. On GNU systems we can use program_invocation_short_name which is actually set on crt0.
Guillem Jover c766e58a 2011-02-25T18:25:17 Add man pages for heapsort and mergesort Taken from FreeBSD, originally as qsort.3 but qsort references stripped.
Guillem Jover 4b95e82a 2011-02-25T18:48:10 Add new radixsort and sradixsort functions Taken from FreeBSD.
Guillem Jover be6ab549 2011-02-25T18:17:16 Add new mergesort function Taken from FreeBSD.