blob: be10ee8b543dd25346c3b2e3d923ff2e7e70a284 [file] [log] [blame]
// Copyright Microsoft and CHERIoT Contributors.
// SPDX-License-Identifier: MIT
#include <cdefs.h>
#include <stddef.h>
#include <string.h>
char *__cheri_libcall strnstr(const char *haystack,
const char *needle,
size_t haystackLength)
{
size_t needleLen = strlen(needle);
while ((haystackLength > needleLen) && (*haystack != 0))
{
if (strncmp(haystack, needle, needleLen) == 0)
{
return const_cast<char *>(haystack);
}
haystack++;
haystackLength--;
}
return nullptr;
}