[FFmpeg-devel] [PATCH v17 4/5] libavformat: Remove MAX_PATH limit and use UTF-8 version of getenv()

Martin Storsjö martin at martin.st
Sun Jun 19 01:40:38 EEST 2022


On Fri, 17 Jun 2022, Nil Admirari wrote:

> 1. getenv() is replaced with getenv_utf8() across libavformat.
> 2. New versions of AviSynth+ are now called with UTF-8 filenames.
> 3. Old versions of AviSynth are still using ANSI strings,
>   but MAX_PATH limit on filename is removed.
> ---
> libavformat/avisynth.c    | 39 +++++++++++++++++++++++++++------------
> libavformat/http.c        | 20 +++++++++++++-------
> libavformat/ipfsgateway.c | 35 +++++++++++++++++++++++------------
> libavformat/tls.c         | 11 +++++++++--
> 4 files changed, 72 insertions(+), 33 deletions(-)
>
> @@ -198,6 +199,7 @@ void ff_http_init_auth_state(URLContext *dest, const URLContext *src)
> static int http_open_cnx_internal(URLContext *h, AVDictionary **options)
> {
>     const char *path, *proxy_path, *lower_proto = "tcp", *local_path;
> +    char *env_http_proxy, *env_no_proxy;
>     char *hashmark;
>     char hostname[1024], hoststr[1024], proto[10];
>     char auth[1024], proxyauth[1024] = "";
> @@ -211,9 +213,13 @@ static int http_open_cnx_internal(URLContext *h, AVDictionary **options)
>                  path1, sizeof(path1), s->location);
>     ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL);
>
> -    proxy_path = s->http_proxy ? s->http_proxy : getenv("http_proxy");
> -    use_proxy  = !ff_http_match_no_proxy(getenv("no_proxy"), hostname) &&
> +    env_http_proxy = getenv_utf8("http_proxy");
> +    proxy_path = s->http_proxy ? s->http_proxy : env_http_proxy;
> +
> +    env_no_proxy = getenv_utf8("no_proxy");
> +    use_proxy  = !ff_http_match_no_proxy(env_no_proxy, hostname) &&
>                  proxy_path && av_strstart(proxy_path, "http://", NULL);
> +    av_freep(&env_no_proxy);
>
>     if (!strcmp(proto, "https")) {
>         lower_proto = "tls";
> @@ -224,7 +230,7 @@ static int http_open_cnx_internal(URLContext *h, AVDictionary **options)
>         if (s->http_proxy) {
>             err = av_dict_set(options, "http_proxy", s->http_proxy, 0);
>             if (err < 0)
> -                return err;
> +                goto end;
>         }
>     }
>     if (port < 0)
> @@ -259,12 +265,12 @@ static int http_open_cnx_internal(URLContext *h, AVDictionary **options)
>         err = ffurl_open_whitelist(&s->hd, buf, AVIO_FLAG_READ_WRITE,
>                                    &h->interrupt_callback, options,
>                                    h->protocol_whitelist, h->protocol_blacklist, h);
> -        if (err < 0)
> -            return err;
>     }
>
> -    return http_connect(h, path, local_path, hoststr,
> -                        auth, proxyauth);
> +end:
> +    av_freep(&env_http_proxy);
> +    return err < 0 ? err : http_connect(
> +        h, path, local_path, hoststr, auth, proxyauth);
> }

FWIW - I wasn't entirely sure we can conclude that we always pass through 
a case that initializes the err variable here, so just to be sure, I 
locally amended this patch to initialize the err variable to 0 too.

// Martin



More information about the ffmpeg-devel mailing list