libs/machine:strnlen need check return

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2024-01-16 13:31:27 +08:00 committed by Xiang Xiao
parent 603c87977f
commit 22e5c88479
1 changed files with 4 additions and 2 deletions

View File

@ -268,12 +268,14 @@ int strncmp(FAR const char *s1, FAR const char *s2, size_t n)
#ifdef CONFIG_LIBC_ARCH_STRNLEN
size_t strnlen(FAR const char *s, size_t maxlen)
{
size_t ret = arch_strnlen(s, maxlen);
# ifdef CONFIG_MM_KASAN
# ifndef CONFIG_MM_KASAN_DISABLE_READS_CHECK
__asan_loadN((FAR void *)s, maxlen + 1);
__asan_loadN((FAR void *)s, ret);
# endif
# endif
return arch_strnlen(s, maxlen);
return ret;
}
#endif