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]
Date:   Mon, 29 Aug 2022 20:31:18 -0400
From:   Kent Overstreet <kent.overstreet@...ux.dev>
To:     linux-kernel@...r.kernel.org
Cc:     Kent Overstreet <kent.overstreet@...ux.dev>,
        Petr Mladek <pmladek@...e.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Sergey Senozhatsky <senozhatsky@...omium.org>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Rasmus Villemoes <linux@...musvillemoes.dk>
Subject: [PATCH 1/2] lib/test_printf.c: Add ip6 tests

This adds missing tests for ip6 address: both bare address and
sockaddr_in6, as well as the additional flags for compressed address,
port, scope and flow.

Signed-off-by: Kent Overstreet <kent.overstreet@...ux.dev>
Cc: Petr Mladek <pmladek@...e.com>
Cc: Steven Rostedt <rostedt@...dmis.org>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Rasmus Villemoes <linux@...musvillemoes.dk>
---
 lib/test_printf.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/lib/test_printf.c b/lib/test_printf.c
index 4bd15a593f..6a56dbf076 100644
--- a/lib/test_printf.c
+++ b/lib/test_printf.c
@@ -18,6 +18,7 @@
 #include <linux/dcache.h>
 #include <linux/socket.h>
 #include <linux/in.h>
+#include <linux/in6.h>
 
 #include <linux/gfp.h>
 #include <linux/mm.h>
@@ -61,6 +62,9 @@ do_test(int bufsize, const char *expect, int elen,
 		pr_warn("vsnprintf(buf, %d, \"%s\", ...) returned %d, expected %d\n",
 			bufsize, fmt, ret, elen);
 		return 1;
+		pr_warn("vsnprintf(buf, %d, \"%s\", ...) returned %d, expected %d (%s != %s)\n",
+			bufsize, fmt, ret, elen, test_buffer, expect);
+		return 1;
 	}
 
 	if (memchr_inv(alloced_buffer, FILL_CHAR, PAD_SIZE)) {
@@ -452,6 +456,31 @@ ip4(void)
 static void __init
 ip6(void)
 {
+	struct sockaddr_in6 sa = { .sin6_family = AF_INET6 };
+
+	sa.sin6_port			= cpu_to_be16(12345);
+	sa.sin6_addr.in6_u.u6_addr16[0]	= cpu_to_be16(1);
+	sa.sin6_addr.in6_u.u6_addr16[1]	= cpu_to_be16(2);
+	sa.sin6_addr.in6_u.u6_addr16[6]	= cpu_to_be16(7);
+	sa.sin6_addr.in6_u.u6_addr16[7]	= cpu_to_be16(8);
+	sa.sin6_flowinfo		= cpu_to_be32(8008);
+	sa.sin6_scope_id		= 4004;
+
+	test("00010002000000000000000000070008",		"%pi6", &sa.sin6_addr);
+	test("00010002000000000000000000070008",		"%piS", &sa);
+	test("0001:0002:0000:0000:0000:0000:0007:0008",		"%pI6", &sa.sin6_addr);
+	test("0001:0002:0000:0000:0000:0000:0007:0008",		"%pIS", &sa);
+	test("1:2::7:8",					"%pISc", &sa);
+
+	test("[0001:0002:0000:0000:0000:0000:0007:0008]:12345",	"%pISp", &sa);
+	test("[0001:0002:0000:0000:0000:0000:0007:0008]%4004",	"%pISs", &sa);
+	test("[0001:0002:0000:0000:0000:0000:0007:0008]/8008",	"%pISf", &sa);
+
+	test("[1:2::7:8]:12345",				"%pIScp", &sa);
+	test("[1:2::7:8]%4004",					"%pIScs", &sa);
+	test("[1:2::7:8]/8008",					"%pIScf", &sa);
+
+	test("[1:2::7:8]:12345/8008%4004",			"%pIScpsf", &sa);
 }
 
 static void __init
-- 
2.36.1

Powered by blists - more mailing lists