Date: Sat, 5 Nov 2022 00:31:06 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 15a6febddbf5 - stable/13 - strfmon_test: Reserve space for the null terminator Message-ID: <202211050031.2A50V6vu071080@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=15a6febddbf5f186ca9608cd6f85ded0f666bb12 commit 15a6febddbf5f186ca9608cd6f85ded0f666bb12 Author: Jose Luis Duran <jlduran@gmail.com> AuthorDate: 2022-10-27 10:01:24 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-11-05 00:30:39 +0000 strfmon_test: Reserve space for the null terminator (cherry picked from commit edcee003e5a79386653c8092af3577a112e95451) --- lib/libc/tests/stdlib/strfmon_test.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/libc/tests/stdlib/strfmon_test.c b/lib/libc/tests/stdlib/strfmon_test.c index d8e4f478547a..c2fa6250dc58 100644 --- a/lib/libc/tests/stdlib/strfmon_test.c +++ b/lib/libc/tests/stdlib/strfmon_test.c @@ -55,7 +55,7 @@ ATF_TC_BODY(strfmon_locale_thousands, tc) atf_tc_skip("multi-byte thousands-separator not found"); n = 1234.56; - strfmon(actual, sizeof(actual), "%i", n); + strfmon(actual, sizeof(actual) - 1, "%i", n); strcpy(expected, "1"); strlcat(expected, ts, sizeof(expected)); @@ -95,7 +95,7 @@ ATF_TC_BODY(strfmon_examples, tc) for (i = 0; i < nitems(tests); ++i) { snprintf(format, sizeof(format), "[%s] [%s] [%s]", tests[i].format, tests[i].format, tests[i].format); - strfmon(actual, sizeof(actual), format, + strfmon(actual, sizeof(actual) - 1, format, 123.45, -123.45, 3456.781); ATF_CHECK_STREQ_MSG(tests[i].expected, actual, "[%s]", tests[i].format); @@ -135,7 +135,7 @@ ATF_TC_BODY(strfmon_cs_precedes_0, tc) for (j = 0; j < 5; ++j) { lc->n_sign_posn = j; - strfmon(buf, sizeof(buf), "[%n] ", -123.0); + strfmon(buf, sizeof(buf) - 1, "[%n] ", -123.0); strlcat(actual, buf, sizeof(actual)); } @@ -178,7 +178,7 @@ ATF_TC_BODY(strfmon_cs_precedes_1, tc) for (j = 0; j < 5; ++j) { lc->n_sign_posn = j; - strfmon(buf, sizeof(buf), "[%n] ", -123.0); + strfmon(buf, sizeof(buf) - 1, "[%n] ", -123.0); strlcat(actual, buf, sizeof(actual)); } @@ -206,7 +206,7 @@ ATF_TC_BODY(strfmon_international_currency_code, tc) if (setlocale(LC_MONETARY, tests[i].locale) == NULL) atf_tc_skip("unable to setlocale()"); - strfmon(actual, sizeof(actual), "[%i]", 123.45); + strfmon(actual, sizeof(actual) - 1, "[%i]", 123.45); ATF_CHECK_STREQ(tests[i].expected, actual); } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202211050031.2A50V6vu071080>