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: <20260128094224.11299-3-im.lechain@gmail.com>
Date: Wed, 28 Jan 2026 17:42:24 +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 v2 2/2] selftests/nolibc: add tests for printf left alignment and zero padding

From: Cheng Li <im.lechain@...il.com>

This patch adds validation for the recently added left-alignment ('-')
and zero-padding ('0') flags in printf().

It ensures that:
 - Fields are correctly padded with spaces on the right when the '-'
   flag is used.
 - Integers are correctly padded with zeroes on the left when the '0'
   flag is used.

Signed-off-by: Cheng Li <im.lechain@...il.com>
---
v2 changes:
 - Added test cases for zero padding (%08d)
---
 tools/testing/selftests/nolibc/nolibc-test.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
index 3c5a226dad3a..47b20ecf5242 100644
--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -1723,6 +1723,8 @@ 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(leading_zero); EXPECT_VFPRINTF(10, "|00000001|", "|%08d|", 1); break;
+		CASE_TEST(left_align);   EXPECT_VFPRINTF(10, "|foo     |", "|%-8s|", "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