|
|
Message-ID: <20261029215820.167178-1-bernie@codewiz.org>
Date: Fri, 30 Oct 2026 06:58:20 +0900
From: Bernie Innocenti <bernie@...ewiz.org>
To: musl@...ts.openwall.com
Cc: Bernie Innocenti <bernie@...ewiz.org>
Subject: [PATCH libc-test] functional/swprintf: pass the buffer size in wide characters
swprintf takes the size of the buffer in wchar_t, not bytes: sizeof b
claimed four times the space b has.
---
src/functional/swprintf.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/functional/swprintf.c b/src/functional/swprintf.c
index 243fae8..d480c73 100644
--- a/src/functional/swprintf.c
+++ b/src/functional/swprintf.c
@@ -129,9 +129,9 @@ int main(void)
TEST(i, b[5], 'x', "buffer overrun");
for (j=0; int_tests[j].fmt; j++) {
- i = swprintf(b, sizeof b, int_tests[j].fmt, int_tests[j].i);
+ i = swprintf(b, sizeof b / sizeof *b, int_tests[j].fmt, int_tests[j].i);
if (i != wcslen(int_tests[j].expect)) {
- t_error("swprintf(b, sizeof b, \"%ls\", %d) returned %d wanted %d\n",
+ t_error("swprintf(b, sizeof b / sizeof *b, \"%ls\", %d) returned %d wanted %d\n",
int_tests[j].fmt, int_tests[j].i, i, wcslen(int_tests[j].expect));
}
if (wcscmp(b, int_tests[j].expect) != 0)
@@ -139,9 +139,9 @@ int main(void)
}
for (j=0; fp_tests[j].fmt; j++) {
- i = swprintf(b, sizeof b, fp_tests[j].fmt, fp_tests[j].f);
+ i = swprintf(b, sizeof b / sizeof *b, fp_tests[j].fmt, fp_tests[j].f);
if (i != wcslen(fp_tests[j].expect)) {
- t_error("swprintf(b, sizeof b, \"%ls\", %f) returned %d wanted %d\n",
+ t_error("swprintf(b, sizeof b / sizeof *b, \"%ls\", %f) returned %d wanted %d\n",
fp_tests[j].fmt, fp_tests[j].f, i, wcslen(fp_tests[j].expect));
}
if (wcscmp(b, fp_tests[j].expect) != 0)
--
2.56.0
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.