Hi,

On Mon, Nov 23, 2015 at 07:56:09PM +0100, Steffan Karger wrote:
> If get_ipv6_addr() would fail *after* allocating memory for ipv6_local,
> add_option() would fail to free that memory.
> 
> The fix here is to remove the allocation from get_ipv6_addr(), and create
> a separate function for the strip-and-allocate, such that failures are
> easier to handle.

Generally speaking, this makes sense.  This particular bit is unsafe (so NAK):

> @@ -4467,10 +4481,9 @@ add_option (struct options *options,
>    else if (streq (p[0], "ifconfig-ipv6") && p[1] && p[2] )
>      {
>        unsigned int netbits;
> -      char * ipv6_local;
>  
>        VERIFY_PERMISSION (OPT_P_UP);
> -      if ( get_ipv6_addr( p[1], NULL, &netbits, &ipv6_local, msglevel ) &&
> +      if ( get_ipv6_addr( p[1], NULL, &netbits, msglevel ) &&
>             ipv6_addr_safe( p[2] ) )
>          {
>         if ( netbits < 64 || netbits > 124 )
> @@ -4483,7 +4496,7 @@ add_option (struct options *options,
>              /* explicitly ignoring this is a const char */
>              free ((char *) options->ifconfig_ipv6_local);
>  
> -       options->ifconfig_ipv6_local = ipv6_local;
> +       options->ifconfig_ipv6_local = get_ipv6_addr_no_netbits (p[1], 
> &options->gc);

There's a free() in case this option is called twice - but since the
address is in &gc now, we must not free() it...

(Seems when I wrote that, I did not grok the options->gc possibilities yet)

gert
-- 
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: signature.asc
Description: PGP signature

Reply via email to