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: <20170731202742.GX16375@orbyte.nwl.cc>
Date:   Mon, 31 Jul 2017 22:27:42 +0200
From:   Phil Sutter <phil@....cc>
To:     Florian Lehner <dev@...-flo.net>
Cc:     netdev@...r.kernel.org
Subject: Re: [PATCH v2] ss: Enclose IPv6 address in brackets

On Mon, Jul 31, 2017 at 09:50:04PM +0200, Florian Lehner wrote:
> This updated patch adds support for RFC2732 IPv6 address format with
> brackets for the tool ss. Resolved hostnames will not be enclosed in
> brackets, therefore the global variable resolve_hosts is initialized and
> checked.
> 
> Signed-off-by: Lehner Florian <dev@...-flo.net>
> ---
>  misc/ss.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/misc/ss.c b/misc/ss.c
> index 12763c9..ac94537 100644
> --- a/misc/ss.c
> +++ b/misc/ss.c
> @@ -88,7 +88,7 @@ static int security_get_initial_context(char *name,
> char **context)
>  }
>  #endif
> 
> -int resolve_hosts;
> +int resolve_hosts = 0;

Global variables are guaranteed to be initialized to zero. According to
the web this is by C89.

>  int resolve_services = 1;
>  int preferred_family = AF_UNSPEC;
>  int show_options;
> @@ -1059,7 +1059,11 @@ static void inet_addr_print(const inet_prefix *a,
> int port, unsigned int ifindex
>  			ap = format_host(AF_INET, 4, a->data);
>  		}
>  	} else {
> -		ap = format_host(a->family, 16, a->data);
> +		if (a->family == AF_INET6 && !resolve_hosts) {
> +			sprintf(buf, "[%s]", format_host(a->family, 16, a->data));
> +		} else {
> +			ap = format_host(a->family, 16, a->data);
> +		}
>  		est_len = strlen(ap);
>  		if (est_len <= addr_width)
>  			est_len = addr_width;

This won't work if name resolution was requested but failed. In that
case an IPv6 address is returned but not enclosed in brackets.

Cheers, Phil

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ