lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aXnABWo3g2XVN2HK@1wt.eu>
Date: Wed, 28 Jan 2026 08:51:33 +0100
From: Willy Tarreau <w@....eu>
To: "licheng.li" <im.lechain@...il.com>
Cc: Thomas Weißschuh <linux@...ssschuh.net>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] selftests/nolibc: add tests for printf left alignment

On Mon, Jan 26, 2026 at 11:10:38AM +0800, licheng.li wrote:
> From: Cheng Li <im.lechain@...il.com>
> 
> This patch adds validation for the recently added '-' flag support in
> printf(). It ensures that strings and numbers are correctly padded
> with spaces on the right side when the left-alignment flag is used.
> 
> The test adds minimal overhead to the test binary size.
> On x86_64:
> 
>   text    data     bss     dec     hex filename
>  43677     248     112   44037    ac05 nolibc-test (before)
>  43761     248     112   44121    ac59 nolibc-test (after)
> 
> The test logic adds 84 bytes.
> 
> Signed-off-by: Cheng Li <im.lechain@...il.com>
> ---
>  tools/testing/selftests/nolibc/nolibc-test.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
> index 3c5a226dad3a..3d47711cad8f 100644
> --- a/tools/testing/selftests/nolibc/nolibc-test.c
> +++ b/tools/testing/selftests/nolibc/nolibc-test.c
> @@ -1723,6 +1723,7 @@ static int run_printf(int min, int max)
>  		CASE_TEST(truncation);   EXPECT_VFPRINTF(25, "01234567890123456789", "%s", "0123456789012345678901234"); break;
>  		CASE_TEST(string_width); EXPECT_VFPRINTF(10, "         1", "%10s", "1"); break;
>  		CASE_TEST(number_width); EXPECT_VFPRINTF(10, "         1", "%10d", 1); break;
> +		CASE_TEST(left_align);   EXPECT_VFPRINTF(10, "foo      |", "%-9s|", "foo"); break;
>  		CASE_TEST(width_trunc);  EXPECT_VFPRINTF(25, "                    ", "%25d", 1); break;
>  		CASE_TEST(scanf);        EXPECT_ZR(1, test_scanf()); break;
>  		CASE_TEST(strerror);     EXPECT_ZR(1, test_strerror()); break;

Your first patch also made a special case of the '0', that will
pad with zeroes on the left, and which is not obvious when reading
the code (BTW I'm realizing now that it's not mentioned in the
commit message), so in my opinion your patch should also test for
this case, which could easily be overlooked and broken by accident.

Thanks,
Willy

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ