Hi,

On Thu, Sep 22, 2016 at 3:40 PM, David Sommerseth <dav...@openvpn.net>
wrote:

> This avoids allocating static memory which is not used unless the
> a HTTP proxy with authentication is configured.


.....

The only place the original code referred to the global
static_proxy_user_pass appears to be in this function and from its usage it
appears redundant.

 static void
>  get_user_pass_http (struct http_proxy_info *p, const bool force)
>  {
> -  if (!static_proxy_user_pass.defined || force)
> +  if (!proxy_user_pass_cache || !proxy_user_pass_cache->defined|| force)
>      {
>        unsigned int flags = GET_USER_PASS_MANAGEMENT;
> +
> +      if (!proxy_user_pass_cache)
> +        {
> +          ALLOC_OBJ_CLEAR (proxy_user_pass_cache, struct user_pass);
> +        }
> +      else
> +        {
> +          CLEAR (*proxy_user_pass_cache);
> +        }
> +
>        if (p->queried_creds)
>         flags |= GET_USER_PASS_PREVIOUS_CREDS_FAILED;
>        if (p->options.inline_creds)
>         flags |= GET_USER_PASS_INLINE_CREDS;
> -      get_user_pass (&static_proxy_user_pass,
> +      get_user_pass (proxy_user_pass_cache,
>                      p->options.auth_file,
>                      UP_TYPE_PROXY,
>                      flags);
>        p->queried_creds = true;
> -      p->up = static_proxy_user_pass;
>

A copy of the struct is made only when a new password is obtained using
get_user_pass. Then, what was the purpose of the static? Or was it a bug
that the copy of the cached password was not made every time this function
was called? If not, we can just delete the static and use p->up directly.

     }
> +  p->up = proxy_user_pass_cache;
>  }
>

Selva
------------------------------------------------------------------------------
_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to