|
|
Message-ID: <20261101212622.GU3542221@port70.net>
Date: Sun, 1 Nov 2026 22:26:22 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: Bernie Innocenti <bernie@...ewiz.org>
Cc: musl@...ts.openwall.com
Subject: Re: [PATCH libc-test] functional/swprintf: pass the buffer
size in wide characters
* Bernie Innocenti <bernie@...ewiz.org> [2026-10-30 06:58:20 +0900]:
> swprintf takes the size of the buffer in wchar_t, not bytes: sizeof b
> claimed four times the space b has.
thanks. i pushed this fix and the fma test.
> ---
> 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.