From dfdf53df99c8f59e5e3a4296c455041bee96a88d Mon Sep 17 00:00:00 2001 From: jvoisin Date: Thu, 30 Apr 2026 17:50:27 +0200 Subject: Improve coverage for wmemcpy and wmemmove Like it's already done for memcpy and memmove. Add tests as well, to prove that nothing broke. --- include/wchar.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/wchar.h b/include/wchar.h index 0842115..9e32720 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -221,21 +221,25 @@ _FORTIFY_FN(wcstombs) size_t wcstombs(char * _FORTIFY_POS0 __s, } _FORTIFY_FN(wmemcpy) wchar_t *wmemcpy(wchar_t * _FORTIFY_POS0 __d, - const wchar_t *__s, size_t __n) + const wchar_t * _FORTIFY_POS0 __s, + size_t __n) { - size_t __b = __bos(__d, 0); + size_t __bd = __bos(__d, 0); + size_t __bs = __bos(__s, 0); - if (__n > __b / sizeof(wchar_t)) + if (__n > __bd / sizeof(wchar_t) || __n > __bs / sizeof(wchar_t)) __builtin_trap(); return __orig_wmemcpy(__d, __s, __n); } _FORTIFY_FN(wmemmove) wchar_t *wmemmove(wchar_t * _FORTIFY_POS0 __d, - const wchar_t *__s, size_t __n) + const wchar_t * _FORTIFY_POS0 __s, + size_t __n) { - size_t __b = __bos(__d, 0); + size_t __bd = __bos(__d, 0); + size_t __bs = __bos(__s, 0); - if (__n > __b / sizeof(wchar_t)) + if (__n > __bd / sizeof(wchar_t) || __n > __bs / sizeof(wchar_t)) __builtin_trap(); return __orig_wmemmove(__d, __s, __n); } -- cgit v1.3