diff options
| author | jvoisin | 2026-04-30 17:42:29 +0200 |
|---|---|---|
| committer | jvoisin | 2026-04-30 17:42:29 +0200 |
| commit | f9239e2c0f0be9856322727887a45333683940a6 (patch) | |
| tree | 714b611965666c4072fef6218e7a794dff1884cb /tests/Makefile | |
| parent | 6040b4a27409968c764353a98c45d972cfd89a8a (diff) | |
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.
Diffstat (limited to 'tests/Makefile')
| -rw-r--r-- | tests/Makefile | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tests/Makefile b/tests/Makefile index 71fb930..adea381 100644 --- a/tests/Makefile +++ b/tests/Makefile | |||
| @@ -94,6 +94,8 @@ RUNTIME_TARGETS= \ | |||
| 94 | test_vsnprintf_static \ | 94 | test_vsnprintf_static \ |
| 95 | test_vsprintf \ | 95 | test_vsprintf \ |
| 96 | test_wcrtomb \ | 96 | test_wcrtomb \ |
| 97 | test_wcsnrtombs_dynamic \ | ||
| 98 | test_wcsnrtombs_static \ | ||
| 97 | test_wcscat_static_write \ | 99 | test_wcscat_static_write \ |
| 98 | test_wcscpy_static_write \ | 100 | test_wcscpy_static_write \ |
| 99 | test_wcsncat_static_write \ | 101 | test_wcsncat_static_write \ |
