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:   Sat,  5 Dec 2020 22:13:33 +0100
From:   Petr Machata <me@...chata.org>
To:     netdev@...r.kernel.org, dsahern@...il.com,
        stephen@...workplumber.org
Cc:     Po.Liu@....com, toke@...e.dk, dave.taht@...il.com,
        edumazet@...gle.com, tahiliani@...k.edu.in, leon@...nel.org,
        Petr Machata <me@...chata.org>
Subject: [PATCH iproute2-next v2 5/7] lib: print_color_rate(): Fix formatting small rates in IEC mode

ISO/IEC units are distinguished from the decadic ones by using a prefixes
like "Ki", "Mi" instead of "K" and "M". The current code inserts the letter
"i" after the decadic unit when in IEC mode. However it does so even when
the prefix is an empty string, formatting 1Kbit in IEC mode as "1000ibit".
Fix by omitting the letter if there is no prefix.

Signed-off-by: Petr Machata <me@...chata.org>
---
 lib/json_print.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/json_print.c b/lib/json_print.c
index d28e957c9603..b086123ad1f4 100644
--- a/lib/json_print.c
+++ b/lib/json_print.c
@@ -333,7 +333,8 @@ int print_color_rate(bool use_iec, enum output_type type, enum color_attr color,
 		rate /= kilo;
 	}
 
-	rc = asprintf(&buf, "%.0f%s%sbit", (double)rate, units[i], str);
+	rc = asprintf(&buf, "%.0f%s%sbit", (double)rate, units[i],
+		      i > 0 ? str : "");
 	if (rc < 0)
 		return -1;
 
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ