summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2016-01-27Fix heap buffer overflow in fgetwln()Hanno Boeck1-1/+1
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>
2015-12-14Add support for GNU/Hurd to getentropy()Guillem Jover3-0/+449
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.
2015-12-07Add missing copyright and license headersGuillem Jover1-0/+26
2015-12-02Fix getentropy implementation to use the correct system hooksGuillem Jover1-6/+6
Include getentropy_<SYSTEM>.c instead of arc4random_<SYSTEM>.c.
2015-12-02Add support for GNU/kFreeBSD for closefrom() and getentropy()Guillem Jover2-2/+2
2015-12-02Unify most arc4random Unix hooks into a single fileGuillem Jover5-191/+15
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.
2015-12-01Use local SHA512 headerGuillem Jover4-3/+7
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.
2015-11-30Update arc4random module from OpenBSD and LibreSSLGuillem Jover9-220/+764
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
2015-11-30Add private getentropy module from OpenBSD and LibreSSLGuillem Jover8-0/+2382
Adapt the code to the local build system.
2015-11-30Add private SHA512 module from FreeBSDGuillem Jover3-0/+373
2015-11-30Add NIOS2 support to nlist()Marek Vasut1-0/+6
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>
2015-11-30build: Move hash/helper.c into new libbsd_la_included_sourcesGuillem Jover1-1/+6
Use this variable in EXTRA_DIST and libbsd_la_DEPENDENCIES.
2015-09-24Add explicit_bzero() function from OpenBSDGuillem Jover3-0/+24
2015-09-24Make closefrom_procfs() fail when reallocarray() failsGuillem Jover1-2/+5
2015-09-23Lock the file streams in fgetln() and fparseln()Guillem Jover2-5/+8
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.
2015-09-23Add compile and link-time deprecation warnings for fgetln()Guillem Jover1-0/+5
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.
2015-09-23build: Add support for linker warningsGuillem Jover2-0/+34
2015-09-23Switch fparseln() implementation from fgetln() to getline()Guillem Jover1-3/+9
2015-09-23test: Add fparseln() unit testGuillem Jover1-33/+0
2015-09-23Avoid left shift overflow in reallocarrayBrent Cook1-2/+2
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>
2015-09-23Make mergesort setup() staticGuillem Jover1-1/+1
2015-09-23Use ANSI C prototypesGuillem Jover5-48/+17
2015-09-23Use reallocarray() instead of malloc() or realloc()Guillem Jover4-7/+9
2015-09-23Do not close file descriptors while scanning the /proc filesystemGuillem Jover1-2/+26
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
2015-09-23Move procfs based implementation into a new closefrom_procfs() functionGuillem Jover1-16/+28
2015-09-23Refactor file descriptor closure into a new closefrom_close()Guillem Jover1-17/+15
2015-09-23Update closefrom() functionGuillem Jover1-36/+69
Import from sudo. Adapt the build system to detect the required features.
2015-09-23test: Move and activate fpurge() test case from module to a dedicated fileGuillem Jover1-20/+0
2015-09-23Use stdint integer types instead of BSD legacy onesGuillem Jover3-26/+26
2014-07-20build: Remove hard requirement for GNU .init_array section supportGuillem Jover1-2/+7
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.
2014-07-17Add reallocarray() function from OpenBSDBenjamin Baier3-0/+41
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2014-07-17Add stringlist module from NetBSDGuillem Jover3-0/+161
2014-07-15Add getbsize() functionGuillem Jover3-0/+105
Import code from DragonFlyBSD and man page from FreeBSD.
2014-03-06Add OpenRISC support to nlist()Christian Svensson1-0/+6
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2013-10-21Add timeconv module from FreeBSDGuillem Jover3-0/+129
Inline license information from FreeBSD root dir COPYRIGHT file.
2013-10-21Add funopen() functionGuillem Jover3-0/+147
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.
2013-10-21Fix dehumanize_number() to correctly detect overflowsGuillem Jover1-4/+10
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
2013-07-14Warn when setproctitle() gets called before initializationGuillem Jover1-1/+9
Try to give a helpful message in case the program is not initializing the setproctitle() machinery.
2013-07-14Move setproctitle() automatic initialization to its own libraryGuillem Jover5-10/+78
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
2013-07-14build: Move version ABI from Makefile to configure.acGuillem Jover1-1/+1
It's easier to find there, and the value can be reused in case we have to provide another shared library.
2013-06-08Release libbsd 0.5.20.5.2Guillem Jover1-1/+1
2013-06-08Create a shallow copy of environ before replacing it in setproctitle()Guillem Jover1-9/+34
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
2013-06-08Specify setproctitle_stub() signature manually if typeof is missingGuillem Jover1-2/+5
Do not stop exporting the function in the version node even if typeof is not available, as that would break ABI.
2013-06-08Try to check if setproctitle() constructor got passed argumentsGuillem Jover1-0/+4
2013-06-08Force setproctitle() into .init_array sectionGuillem Jover1-2/+10
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
2013-05-27Release libbsd 0.5.10.5.1Guillem Jover1-1/+1
2013-05-27Release libbsd 0.5.00.5.0Guillem Jover1-1/+1
2013-05-27build: Use AM_V_at for mkdirGuillem Jover1-1/+1
2013-05-27Fix comparison between signed and unsigned integer compiler warningsGuillem Jover3-3/+4
2013-05-27Update radixsort module from NetBSDGuillem Jover1-38/+30
Merge some interesting changes.