Skip to content

Commit 6fd4a65

Browse files
committed
libc: add __wcsncpy_chk() to support python 3.10
Signed-off-by: Waldemar Kozaczuk <jwkozaczuk@gmail.com>
1 parent c068149 commit 6fd4a65

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,6 +1796,7 @@ musl += string/wcsncasecmp_l.o
17961796
musl += string/wcsncat.o
17971797
musl += string/wcsncmp.o
17981798
musl += string/wcsncpy.o
1799+
libc += string/__wcsncpy_chk.o
17991800
musl += string/wcsnlen.o
18001801
musl += string/wcspbrk.o
18011802
musl += string/wcsrchr.o

libc/string/__wcsncpy_chk.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright (C) 2022 Waldemar Kozaczuk
3+
*
4+
* This work is open source software, licensed under the terms of the
5+
* BSD license as described in the LICENSE file in the top-level directory.
6+
*/
7+
8+
#include <wchar.h>
9+
#include <assert.h>
10+
11+
wchar_t *__wcsncpy_chk(wchar_t * dest, const wchar_t * src, size_t n, size_t destlen)
12+
{
13+
assert(wcslen(src) + sizeof(L'\0') <= destlen);
14+
return wcsncpy(dest, src, n);
15+
}

0 commit comments

Comments
 (0)