diff --git a/Makefile b/Makefile index fcc55e2986..b8d5d924f4 100644 --- a/Makefile +++ b/Makefile @@ -1796,6 +1796,7 @@ musl += string/wcsncasecmp_l.o musl += string/wcsncat.o musl += string/wcsncmp.o musl += string/wcsncpy.o +libc += string/__wcsncpy_chk.o musl += string/wcsnlen.o musl += string/wcspbrk.o musl += string/wcsrchr.o diff --git a/libc/string/__wcsncpy_chk.c b/libc/string/__wcsncpy_chk.c new file mode 100644 index 0000000000..ff3da7f506 --- /dev/null +++ b/libc/string/__wcsncpy_chk.c @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2022 Waldemar Kozaczuk + * + * This work is open source software, licensed under the terms of the + * BSD license as described in the LICENSE file in the top-level directory. + */ + +#include +#include + +wchar_t *__wcsncpy_chk(wchar_t * dest, const wchar_t * src, size_t n, size_t destlen) +{ + assert(wcslen(src) + sizeof(L'\0') <= destlen); + return wcsncpy(dest, src, n); +}