summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibC/stdlib.cpp
AgeCommit message (Collapse)Author
2021-10-17LibC: Implement mbstowcsTim Schumacher
2021-10-17LibC: Implement wctombTim Schumacher
2021-09-20LibC+DynamicLoader: Store the auxiliary vector address at startupItamar
Previously, getauxval() got the address of the auxiliary vector by traversing to the end of the `environ` pointer. The assumption that the auxiliary vector comes after the environment array is true at program startup, however the environment array may be re-allocated and change its address during runtime which would cause getauxval() to work with an incorrect auxiliary vector address. To fix this, we now get the address of the auxiliary vector once in __libc_init and store it in a libc-internal pointer which is then used by getauxval(). Fixes #10087.
2021-08-08Userland: Use kmalloc_array() where appropriateAndreas Kling
2021-07-18LibC strtod: Reduce incremental error to nearly nothingPeter Bindels
Instead of scaling by 1/10th N times, scale 10^N and then divide by that. Avoid doing this beyond double-infinity. This decreases the progressive error for numbers outside of integer range immensely. Not a full 100% fix; there is still a single ULP difference detected by a Javascript test
2021-06-04LibC: Implement `mblen()`Jelle Raaijmakers
2021-05-30LibC: Implement getprogname and setprognameTim Schumacher
2021-05-27LibC: Use u32 in arc4random instead of char[4]Andrew Kaster
There's no alignment requirements on a char[4] buffer, so this was causing unaligned reads that were caught by UBSAN.
2021-05-18LibC: Remove static from function local constexpr variableLenny Maiorani
Problem: - Function local `constexpr` variables do not need to be `static`. This consumes memory which is unnecessary and can prevent some optimizations. Solution: - Remove `static` keyword.
2021-05-14AK: Introduce get_random_uniform()Jean-Baptiste Boric
This is arc4random_uniform(), but inside AK.
2021-05-09LibC: Implement the _Exit functionGunnar Beutner
libstdc++v3 checks whether this function is available and makes certain functions available in the std namespace if so.
2021-04-29iLibC: Fix some missed camelCase => snake_caseAndreas Kling
2021-04-29Implemented llabs() in stdlib.h/cpp.Holden Green
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-20LibC+LibPthread: Implement function forwarding for libpthreadGunnar Beutner
GCC will insert various calls to pthread functions when compiling C++ code with static initializers, even when the user doesn't link their program against libpthread explicitly. This is used to make static initializers thread-safe, e.g. when building a library that does not itself use thread functionality and thus does not link against libpthread - but is intended to be used with other code that does use libpthread explicitly. This makes these symbols available in libc.
2021-04-18Kernel+LibC: Clean up how assertions work in the kernel and LibCGunnar Beutner
This also brings LibC's abort() function closer to the spec.
2021-04-18LibC+LibPthread: Make sure TLS keys are destroyed after everything elseGunnar Beutner
This ensures that __thread variables can be used when global destructors are being invoked.
2021-04-11LibC: Move S_* defines into <fcntl.h>Gunnar Beutner
According to the Single UNIX Specification, Version 2 that's where those macros should be defined. This fixes the libiconv port. This also fixes some (but not all) build errors for the diffutils and nano ports.
2021-03-09LibC: Add imaxdiv and lldivMițca Dumitru
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2021-02-15LibC: Make strtoull accept the '0x' prefix when base 16 is specifiedAnotherTest
Dr.POSIX says it should be.
2021-02-05Userland: Add LibSystem and funnel all syscalls through itAndreas Kling
This achieves two things: - Programs can now intentionally perform arbitrary syscalls by calling syscall(). This allows us to work on things like syscall fuzzing. - It restricts the ability of userspace to make syscalls to a single 4KB page of code. In order to call the kernel directly, an attacker must now locate this page and call through it.
2021-01-31LibC: Don't honor LIBC_* malloc debugging flags in AT_SECURE contextAndreas Kling
Just ignore all these environment flags if the AT_SECURE flag is set in the program's auxiliary vector. This prevents a user from tricking set-uid programs into dumping debug information via environment flags.
2021-01-22LibC: Templatize unique filename enumeration for mkstemp() et alAndreas Kling
This allows us to implement mkstemp() with open() directly, instead of first lstat()'ing, and then open()'ing the filename. Also implement tmpfile() in terms of mkstemp() instead of mktemp().
2021-01-20LibC: Implement uniform random sampling without modulo biasBen Wiederhake
2021-01-17LibC: Change a couple of ASSERT_NOT_REACHED() to TODO()Linus Groh
Just for semantic correctness and better visibility of those unimplemented stub functions.
2021-01-16LibC: Avoid silent truncation after overlong realpathBen Wiederhake
The realpath syscall can attempt to return arbitrarily long paths, in particular paths that are longer than PATH_MAX. The only way to detect this case is checking whether 'rc', the true length of the returned path including NUL byte, exceeds our buffer length. In such a case, the buffer contains invalid data. All Serenity code calls LibC's realpath() with a nullptr buffer, meaning that realpath is supposed to allocate memory on its own. All Serenity code can handle arbitrarily long paths returned by LibC's realpath, so it is safe to "do the dance" and repeat the syscall with a new buffer. Ports are likely to be graceful in this regard, too. If a Port calls realpath() with a pre-allocated buffer, however, there is nothing better we can do than return a truncated buffer.
2021-01-16LibC: Fix memory leak in realpathBen Wiederhake
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling