summaryrefslogtreecommitdiff
path: root/Libraries/LibC/string.cpp
AgeCommit message (Collapse)Author
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling
2021-01-09LibC: Add explicit_bzero()Andreas Kling
This is a variant of bzero() that is guaranteed to not get optimized away by the compiler. Useful for clearing out sensitive data.
2021-01-09LibC: Move bzero() and bcopy() per Dr. POSIXAndreas Kling
2020-11-14LibC: strtok_r() should not go past the last tokenAndreas Kling
When we hit the last token, make the saved pointer point to the null terminator instead of to the next token. This ensures that the next call to strtok_r() returns null as expected. Found by running GCC in UE. :^)
2020-11-14LibC: Fix OOB access in strerror() with invalid inputAndreas Kling
Calling strerror() with a negative number should not access below the error string array. Found by running GCC in UE. :^)
2020-11-01Kernel+LibC: Don't allow a directory to become a subdirectory of itselfAndreas Kling
If you try to do this (e.g "mv directory directory"), sys$rename() will now fail with EDIRINTOSELF. Dr. POSIX says we should return EINVAL for this, but a custom error code allows us to print a much more helpful error message when this problem occurs. :^)
2020-10-02Everywhere: Fix typosNico Weber
Mostly in comments, but sprintf() now prints "August" instead of "Auguest" so that's something.
2020-09-27LibC: Add EPFNOSUPPORT error numberLuke
Not used anywhere in Serenity currently, but required for OpenSSH.
2020-08-24LibC: Implement strlcpyBen Wiederhake
2020-08-24LibC: Stub and test strlcpyBen Wiederhake
2020-08-24LibC: Prevent slowness and overrun in strdup/strndupBen Wiederhake
strdup: Because the length is already known at the time of copying, there is no need to use strcpy (which has to check every single byte, and thus tends to be slower than memcpy). strndup: If 'str' is not NUL-terminated, strndup used to run off into the adjacent memory region. This can be fixed by using the proper strlen variant: strnlen.
2020-08-21AK+LibC+Kernel: Move the implementation of memmem to AKAnotherTest
2020-08-01Kernel+LibC: Implement 'memmem'AnotherTest
This commit adds an implementation of memmem, using the Bitap text search algorithm for needles smaller than 32 bytes, and a naive loop search for longer needles.
2020-07-27AK+LibC: Always use REP MOVSB/STOSB for memcpy()/memset()Andreas Kling
There's no great advantage to using MMX instructions here on modern processors, since REP MOVSB/STOSB are optimized in microcode anyway and tend to run much faster than MMX/SSE/AVX variants. This also makes it much easier to implement high-level emulation of memcpy/memset in UserspaceEmulator once we get there. :^)
2020-02-22LibC: Implement strchrnul()Shannon Booth
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
2020-01-16LibC: Add strnlen()Andreas Kling
2019-12-27LibC: Remove some functions we had two ofAndreas Kling
2019-12-15Kernel+FileManager: Disallow watch_file() in unsupported file systemsAndreas Kling
Currently only Ext2FS and TmpFS supports InodeWatchers. We now fail with ENOTSUPP if watch_file() is called on e.g ProcFS. This fixes an issue with FileManager chewing up all the CPU when /proc was opened. Watchers don't keep the watched Inode open, and when they close, the watcher FD will EOF. Since nothing else kept /proc open in FileManager, the watchers created for it would EOF immediately, causing a refresh over and over. Fixes #879.
2019-11-10LibC: Add strtok_r() and make strtok() a wrapper around itAndreas Kling
2019-10-17LibC: Better strtok implementation (string.h)Jonah Alligood
2019-10-17LibC: strtok is now implemented (string.h)Jonah Alligood
2019-10-17LibC: sys_errlist should be const char* constAndreas Kling
Patch from Anonymous.
2019-07-29Kernel+AK: Remove AK/StdLibExtras.cpp, moving kernel stuff to Kernel/.Andreas Kling
We had some kernel-specific gizmos in AK that should really just be in the Kernel subdirectory instead. The only thing remaining after moving those was mmx_memcpy() which I moved to the ARCH(i386)-specific section of LibC/string.cpp.
2019-07-09LibC: Provide generic versions of memcpy() and memset() for non-i386 builds.Andreas Kling
We don't actually do any non-i386 builds at the moment, this is just gently steering in a nice direction for the future. :^)
2019-07-04Libraries: Create top level directory for libraries.Andreas Kling
Things were getting a little crowded in the project root, so this patch moves the Lib*/ directories into Libraries/.