netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Florian Lehner <dev@der-flo.net>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH v3] ss: Enclose IPv6 address in brackets
Date: Tue, 1 Aug 2017 16:11:12 +0200	[thread overview]
Message-ID: <20170801141112.GZ16375@orbyte.nwl.cc> (raw)
In-Reply-To: <17aba498-3d75-2659-5fdc-4c95b0d214fa@der-flo.net>

On Tue, Aug 01, 2017 at 12:05:13PM +0200, Florian Lehner wrote:
[...]
> @@ -114,9 +114,13 @@ int addr64_n2a(__u64 addr, char *buff, size_t len);
>  int af_bit_len(int af);
>  int af_byte_len(int af);
> 
> -const char *format_host_r(int af, int len, const void *addr,
> -			       char *buf, int buflen);
> -const char *format_host(int af, int lne, const void *addr);
> +const char *format_host_rb(int af, int len, const void *addr,
> +			       char *buf, int buflen, bool *resolved);
> +#define format_host_r(af, len, addr, buf, buflen) \
> +	format_host_rb(af, len, addr, buf, buflen, NULL)
> +const char *format_host_b(int af, int lne, const void *addr, bool
> *resolved);
> +#define format_host(af, lne, addr) \
> +	format_host_b(af, lne, addr, NULL)
>  #define format_host_rta(af, rta) \
>  	format_host(af, RTA_PAYLOAD(rta), RTA_DATA(rta))
>  const char *rt_addr_n2a_r(int af, int len, const void *addr,
> diff --git a/lib/utils.c b/lib/utils.c
> index 9aa3219..42c3bf5 100644
> --- a/lib/utils.c
> +++ b/lib/utils.c
> @@ -898,8 +898,8 @@ static const char *resolve_address(const void *addr,
> int len, int af)
>  }
>  #endif
> 
> -const char *format_host_r(int af, int len, const void *addr,
> -			char *buf, int buflen)
> +const char *format_host_rb(int af, int len, const void *addr,
> +			char *buf, int buflen, bool *resolved)
>  {
>  #ifdef RESOLVE_HOSTNAMES
>  	if (resolve_hosts) {
> @@ -909,17 +909,20 @@ const char *format_host_r(int af, int len, const
> void *addr,
> 
>  		if (len > 0 &&
>  		    (n = resolve_address(addr, len, af)) != NULL)
> +		{
> +			*resolved = true;
>  			return n;
> +		}
>  	}
>  #endif
>  	return rt_addr_n2a_r(af, len, addr, buf, buflen);
>  }

Did you test that? I guess calling format_host() will lead to
dereference of a NULL pointer.

Cheers, Phil

  reply	other threads:[~2017-08-01 14:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-29 12:29 [PATCH] ss: Enclose IPv6 address in brackets Florian Lehner
2017-07-29 15:26 ` Stephen Hemminger
2017-07-31 10:30 ` Phil Sutter
2017-07-31 16:27   ` Stephen Hemminger
2017-07-31 16:43     ` Phil Sutter
2017-07-31 18:17   ` Florian Lehner
2017-07-31 19:50 ` [PATCH v2] " Florian Lehner
2017-07-31 20:27   ` Phil Sutter
2017-08-01 10:05 ` [PATCH v3] " Florian Lehner
2017-08-01 14:11   ` Phil Sutter [this message]
2017-08-01 16:07     ` Florian Lehner
2017-08-01 11:11 ` [PATCH] " David Laight
2017-08-01 14:41   ` Stephen Hemminger
2017-08-01 16:54 ` [PATCH v4] " Florian Lehner
2017-08-03 22:54   ` Stephen Hemminger
2017-08-04 18:02 ` [PATCH v5] " Florian Lehner
2017-08-04 19:05   ` Stephen Hemminger
2017-08-04 20:46     ` Eric Dumazet
2017-08-04 22:13       ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170801141112.GZ16375@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --cc=dev@der-flo.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).