[vlc-devel] [PATCH 2/2] smb2: support browsing IPv6 nodes

Rémi Denis-Courmont remi at remlab.net
Thu May 28 16:42:04 CEST 2020


Le torstaina 28. toukokuuta 2020, 16.58.29 EEST Pierre Lamot a écrit :
>   Url of items discovered when listing smb2 folders where ill-formed on IPv6
> hosts.
> ---
>  modules/access/smb2.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/modules/access/smb2.c b/modules/access/smb2.c
> index d287493e4f..afa3e08d1c 100644
> --- a/modules/access/smb2.c
> +++ b/modules/access/smb2.c
> @@ -324,7 +324,14 @@ vlc_smb2_get_url(vlc_url_t *url, const char *file)
>  {
>      /* smb2://<psz_host><psz_path><file>?<psz_option> */
>      char *buf;
> -    if (asprintf(&buf, "smb://%s%s%s%s%s%s", url->psz_host,
> +    const char* fmt;
> +
> +    if (strchr(url->psz_host, ':') != NULL)
> +        fmt = "smb://[%s]%s%s%s%s%s";
> +    else
> +        fmt = "smb://%s%s%s%s%s%s";
> +
> +    if (asprintf(&buf, fmt, url->psz_host,
>                   url->psz_path != NULL ? url->psz_path : "",
>                   url->psz_path != NULL && url->psz_path[0] != '\0' &&
>                   url->psz_path[strlen(url->psz_path) - 1] != '/' ? "/" :
> "",

LGTM but we have memstream nowadays to avoid monstruous printf() constructs.

-- 
Rémi Denis-Courmont
http://www.remlab.net/





More information about the vlc-devel mailing list