diff --git a/sys/libkern/strcmp.c b/sys/libkern/strcmp.c --- a/sys/libkern/strcmp.c +++ b/sys/libkern/strcmp.c @@ -41,8 +41,12 @@ int (strcmp)(const char *s1, const char *s2) { +#if defined(KASAN) || defined(KCSAN) + return (SAN_INTERCEPTOR(strcmp)(s1, s2)); +#else while (*s1 == *s2++) if (*s1++ == '\0') return (0); return (*(const unsigned char *)s1 - *(const unsigned char *)(s2 - 1)); +#endif } diff --git a/sys/libkern/strcpy.c b/sys/libkern/strcpy.c --- a/sys/libkern/strcpy.c +++ b/sys/libkern/strcpy.c @@ -35,8 +35,12 @@ char * (strcpy)(char * __restrict to, const char * __restrict from) { +#if defined(KASAN) || defined(KCSAN) + return (SAN_INTERCEPTOR(strcpy)(to, from)); +#else char *save = to; for (; (*to = *from) != 0; ++from, ++to); return(save); +#endif } diff --git a/sys/libkern/strlen.c b/sys/libkern/strlen.c --- a/sys/libkern/strlen.c +++ b/sys/libkern/strlen.c @@ -29,6 +29,13 @@ #include #include +#if defined(KASAN) || defined(KCSAN) +size_t +(strlen)(const char *str) +{ + return (SAN_INTERCEPTOR(strlen)(str)); +} +#else /* !KASAN && !KCSAN */ /* * Portable strlen() for 32-bit and 64-bit systems. * @@ -119,3 +126,4 @@ /* NOTREACHED */ return (0); } +#endif /* KASAN || KCSAN */