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:   Wed, 25 Dec 2019 12:36:07 -0800
From:   Stephen Hemminger <stephen@...workplumber.org>
To:     Peter Junos <petoju@...il.com>
Cc:     netdev@...r.kernel.org
Subject: Re: [PATCH] ss: use compact output for undetected screen width

On Mon, 23 Dec 2019 13:47:16 +0100
Peter Junos <petoju@...il.com> wrote:

> This change fixes calculation of width in case user pipes the output.
> 
> SS output output works correctly when stdout is a terminal. When one
> pipes the output, it tries to use 80 or 160 columns. That adds a
> line-break if user has terminal width of 100 chars and output is of
> the similar width.
> 
> To reproduce the issue, call
> ss | less
> and see every other line empty if your screen is between 80 and 160
> columns wide.
> 
> Signed-off-by: Peter Junos <petoju@...il.com>

I would prefer that if the use pipes the command output to a pipe that
the line length was assumed to be infinite.  

> @@ -1159,7 +1159,13 @@ static int render_screen_width(void)
>   */
>  static void render_calc_width(void)
>  {
> +	bool compact_output = false;
>  	int screen_width = render_screen_width();
> +	if (screen_width == -1) {
> +		screen_width = 80;
> +		compact_output = true;
> +	}
> +
>  	struct column *c, *eol = columns - 1;
>  	int first, len = 0, linecols = 0;
>  

With this patch, declarations and code are now mixed (more than before).
I would expect something like:

static void render_calc_width(void)
{
	int screen_width, first, len = 0, linecols = 0;
	bool compact_output = false;
	struct column *c, *eol = columns - 1;

	screen_width = render_screen_width();
	if (screen_width == -1) {
		screen_width = INT_MAX;
		compact_output = true;
	}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ