From f9239e2c0f0be9856322727887a45333683940a6 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Thu, 30 Apr 2026 17:42:29 +0200 Subject: Fix a bug in wcsnrtombs __d is a char * destination buffer, so __b is already the byte capacity. Dividing by sizeof(wchar_t) makes no sense here, it was likely copy-pasted from mbsnrtowcs (where the destination is wchar_t *). The first branch also fails to limit __n (the byte write cap) to __b, so overflows are possible when a wide character produces multi-byte output. The second branch (else) correctly limits __n to __b. This commit replaces the broken two-branch logic with the simple correct pattern matching wcsrtombs, and adds two tests two prove that nothing broke. --- tests/Makefile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests/Makefile') diff --git a/tests/Makefile b/tests/Makefile index 71fb930..adea381 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -94,6 +94,8 @@ RUNTIME_TARGETS= \ test_vsnprintf_static \ test_vsprintf \ test_wcrtomb \ + test_wcsnrtombs_dynamic \ + test_wcsnrtombs_static \ test_wcscat_static_write \ test_wcscpy_static_write \ test_wcsncat_static_write \ -- cgit v1.3