Implement more security stuff

- Support deterministic stacks on OpenBSD
- Support OpenBSD system call origin verification
- Fix overrun by one in chibicc string token allocator
- Get all chibicc tests passing under Address Sanitizer
This commit is contained in:
Justine Tunney 2021-02-02 20:21:06 -08:00
parent cbfd4ccd1e
commit c843243322
56 changed files with 376 additions and 245 deletions

View file

@ -17,7 +17,6 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/str/internal.h"
#include "libc/str/tinystrstr.internal.h"
/**
* Naïve substring search implementation.
@ -25,5 +24,15 @@
* @asyncsignalsafe
*/
char16_t *tinystrstr16(const char16_t *haystack, const char16_t *needle) {
return (/*unconst*/ char16_t *)tinystrstr(haystack, needle);
size_t i;
for (;;) {
for (i = 0;;) {
if (!needle[i]) return (/*unconst*/ char16_t *)haystack;
if (!haystack[i]) break;
if (needle[i] != haystack[i]) break;
++i;
}
if (!*haystack++) break;
}
return NULL;
}