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-next>] [day] [month] [year] [list]
Message-Id: <20221227173620.6577-1-glipus@gmail.com>
Date:   Tue, 27 Dec 2022 10:36:20 -0700
From:   Maxim Georgiev <glipus@...il.com>
To:     mkubecek@...e.cz
Cc:     netdev@...r.kernel.org, kuba@...nel.org, glipus@...il.com
Subject: [PATCH ethtool-next] Fixing boolean value output for Netlink reported values in JSON format

Current implementation of show_bool_val() passes "val" parameter of pointer
type as a last parameter to print_bool():
https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/tree/netlink/netlink.h#n131
...
static inline void show_bool_val(const char *key, const char *fmt, uint8_t *val)
{
	if (is_json_context()) {
		if (val)
>			print_bool(PRINT_JSON, key, NULL, val);
	} else {
...
print_bool() expects the last parameter to be bool:
https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/tree/json_print.c#n153
...
void print_bool(enum output_type type,
		const char *key,
		const char *fmt,
		bool value)
{
...
Current show_bool_val() implementation converts "val" pointer to bool while
calling show_bool_val(). As a result show_bool_val() always prints the value
as "true" as long as it gets a non-null pointer to the boolean value, even if
the referred boolean value is false.

Fixes: 7e5c1ddbe67d ("pause: add --json support")
Signed-off-by: Maxim Georgiev <glipus@...il.com>
---
 netlink/netlink.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/netlink/netlink.h b/netlink/netlink.h
index 3240fca..1274a3b 100644
--- a/netlink/netlink.h
+++ b/netlink/netlink.h
@@ -128,7 +128,7 @@ static inline void show_bool_val(const char *key, const char *fmt, uint8_t *val)
 {
 	if (is_json_context()) {
 		if (val)
-			print_bool(PRINT_JSON, key, NULL, val);
+			print_bool(PRINT_JSON, key, NULL, *val);
 	} else {
 		print_string(PRINT_FP, NULL, fmt, u8_to_bool(val));
 	}
-- 
2.38.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ