From ddd22b2f533db9c0da0bb262fbafa51f67c8587e Mon Sep 17 00:00:00 2001 From: jvoisin Date: Fri, 1 May 2026 00:36:32 +0200 Subject: Fix strncat/wcsncat Previously, no checks were done when __n <= __b, but strncat _appends_ after existing content, making this a overly broad check check. For example, with an 8-byte buffer containing "12345\0", strncat(buf, "ABCD", 4) would have the check skipped, but the result "12345ABCD\0" is 10 bytes, resulting in an overflow. This commit fixes this oversight, and adds a bunch of tests. --- tests/Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/Makefile') diff --git a/tests/Makefile b/tests/Makefile index 6904b2d..9bedd16 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -84,6 +84,11 @@ RUNTIME_TARGETS= \ test_strlcpy_dynamic_write \ test_strlcpy_static_write \ test_strncat_dynamic_write \ + test_strncat_n_eq_buf \ + test_strncat_n_gt_buf \ + test_strncat_n_lt_buf \ + test_strncat_n_one \ + test_strncat_safe \ test_strncat_static_write \ test_strncpy_dynamic_write \ test_strncpy_static_write \ @@ -101,6 +106,11 @@ RUNTIME_TARGETS= \ test_wcsnrtombs_static \ test_wcscat_static_write \ test_wcscpy_static_write \ + test_wcsncat_n_eq_buf \ + test_wcsncat_n_gt_buf \ + test_wcsncat_n_lt_buf \ + test_wcsncat_n_one \ + test_wcsncat_safe \ test_wcsncat_static_write \ test_wcsncpy_static_write \ test_wmemcpy_dynamic_read \ -- cgit v1.3