Hi,

(note that this is v2 of the patch with a change to getnameinfo()'s 2nd
field, passing ->addr.sa.sa_len now)

ACK, tested and reviewed.

The tabbing is left for David to repair :-)

gert


On Sun, Sep 02, 2012 at 09:15:33PM +0200, Arne Schwabe wrote:
> Signed-off-by: Arne Schwabe <a...@rfc2549.org>
> ---
>  src/openvpn/socket.c |   89 
> ++++++++++++++++++++++----------------------------
>  1 file changed, 39 insertions(+), 50 deletions(-)
> 
> diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
> index a34e78c..5b2bb9d 100644
> --- a/src/openvpn/socket.c
> +++ b/src/openvpn/socket.c
> @@ -2387,57 +2387,46 @@ print_sockaddr_ex (const struct openvpn_sockaddr 
> *addr,
>                  const unsigned int flags,
>                  struct gc_arena *gc)
>  {
> -  struct buffer out = alloc_buf_gc (128, gc);
> -  bool addr_is_defined;
> -  addr_is_defined = addr_defined (addr);
> -  if (!addr_is_defined) {
> -    return "[undef]";
> -  }
> -  switch(addr->addr.sa.sa_family)
> -    {
> -    case AF_INET:
> -     {
> -       const int port= ntohs (addr->addr.in4.sin_port);
> -       buf_puts (&out, "[AF_INET]");
> -
> -       if (!(flags & PS_DONT_SHOW_ADDR))
> -         buf_printf (&out, "%s", (addr_defined (addr) ? inet_ntoa 
> (addr->addr.in4.sin_addr) : "[undef]"));
> -
> -       if (((flags & PS_SHOW_PORT) || (addr_defined (addr) && (flags & 
> PS_SHOW_PORT_IF_DEFINED)))
> -           && port)
> -         {
> -           if (separator)
> -             buf_printf (&out, "%s", separator);
> -
> -           buf_printf (&out, "%d", port);
> -         }
> +     struct buffer out = alloc_buf_gc (128, gc);
> +     bool addr_is_defined;
> +     char buf[NI_MAXHOST] = "";
> +     
> +     addr_is_defined = addr_defined (addr);
> +     if (!addr_is_defined) {
> +             return "[undef]";
>       }
> -      break;
> -    case AF_INET6:
> -     {
> -       const int port= ntohs (addr->addr.in6.sin6_port);
> -       char buf[INET6_ADDRSTRLEN] = "";
> -       buf_puts (&out, "[AF_INET6]");
> -       if (addr_is_defined)
> -         {
> -           getnameinfo(&addr->addr.sa, sizeof (struct sockaddr_in6),
> -                       buf, sizeof (buf), NULL, 0, NI_NUMERICHOST);
> -           buf_puts (&out, buf);
> -         }
> -       if (((flags & PS_SHOW_PORT) || (addr_is_defined && (flags & 
> PS_SHOW_PORT_IF_DEFINED)))
> -           && port)
> -         {
> -           if (separator)
> -             buf_puts (&out, separator);
> -
> -           buf_printf (&out, "%d", port);
> -         }
> -     }
> -      break;
> -    default:
> -      ASSERT(0);
> -    }
> -  return BSTR (&out);
> +     
> +     int port;
> +     switch(addr->addr.sa.sa_family)
> +  {
> +       case AF_INET:
> +             port= ntohs (addr->addr.in4.sin_port);
> +             buf_puts (&out, "[AF_INET]");
> +             break;
> +       case AF_INET6:
> +             port= ntohs (addr->addr.in6.sin6_port);
> +             buf_puts (&out, "[AF_INET6]");
> +             break;
> +       default:
> +             ASSERT(0);
> +  }
> +     
> +     if (!(flags & PS_DONT_SHOW_ADDR))
> +       {
> +             getnameinfo(&addr->addr.sa,  addr->addr.sa.sa_len,
> +                                     buf, sizeof (buf), NULL, 0, 
> NI_NUMERICHOST);
> +             buf_puts (&out, buf);
> +       }
> +     if (((flags & PS_SHOW_PORT) || (addr_is_defined && (flags & 
> PS_SHOW_PORT_IF_DEFINED)))
> +             && port)
> +       {
> +             if (separator)
> +                     buf_puts (&out, separator);
> +             
> +             buf_printf (&out, "%d", port);
> +       }
> +     
> +     return BSTR (&out);
>  }
>  
>  const char *
> -- 
> 1.7.9.6 (Apple Git-31.1)
> 
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Openvpn-devel mailing list
> Openvpn-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openvpn-devel
> 

-- 
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             g...@greenie.muc.de
fax: +49-89-35655025                        g...@net.informatik.tu-muenchen.de

Attachment: pgpA7fHrzjOaF.pgp
Description: PGP signature

Reply via email to