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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260126031038.35387-2-im.lechain@gmail.com>
Date: Mon, 26 Jan 2026 11:10:38 +0800
From: "licheng.li" <im.lechain@...il.com>
To: Willy Tarreau <w@....eu>
Cc: Thomas Weißschuh <linux@...ssschuh.net>,
	linux-kernel@...r.kernel.org,
	im.lechain@...il.com
Subject: [PATCH 2/2] selftests/nolibc: add tests for printf left alignment

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;
-- 
2.52.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ