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: <20231220200354.1b7023e1@hermes.local>
Date: Wed, 20 Dec 2023 20:03:54 -0800
From: Stephen Hemminger <stephen@...workplumber.org>
To: Benjamin Poirier <bpoirier@...dia.com>
Cc: netdev@...r.kernel.org, Petr Machata <petrm@...dia.com>, Roopa Prabhu
 <roopa@...dia.com>
Subject: Re: [PATCH iproute2-next 06/20] bridge: vlan: Use printf() to avoid
 temporary buffer

On Mon, 11 Dec 2023 09:07:18 -0500
Benjamin Poirier <bpoirier@...dia.com> wrote:

> Currently, print_vlan_tunnel_info() is first outputting a formatted string
> to a temporary buffer in order to use print_string() which can handle json
> or normal text mode. Since this specific string is only output in normal
> text mode, by calling printf() directly, we can avoid the need to first
> output to a temporary string buffer.
> 
> Reviewed-by: Petr Machata <petrm@...dia.com>
> Tested-by: Petr Machata <petrm@...dia.com>
> Signed-off-by: Benjamin Poirier <bpoirier@...dia.com>
> ---
>  bridge/vlan.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/bridge/vlan.c b/bridge/vlan.c
> index dfc62f83..797b7802 100644
> --- a/bridge/vlan.c
> +++ b/bridge/vlan.c
> @@ -662,11 +662,8 @@ static void print_vlan_tunnel_info(struct rtattr *tb, int ifindex)
>  		open_json_object(NULL);
>  		width = print_range("vlan", last_vid_start, tunnel_vid);
>  		if (width <= VLAN_ID_LEN) {
> -			char buf[VLAN_ID_LEN + 1];
> -
> -			snprintf(buf, sizeof(buf), "%-*s",
> -				 VLAN_ID_LEN - width, "");
> -			print_string(PRINT_FP, NULL, "%s  ", buf);
> +			if (!is_json_context())
> +				printf("%-*s  ", VLAN_ID_LEN - width, "");
>  		} else {

I think the fix needs to be deeper here.
In JSON the width doesn't matter.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ