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

Thomas Guillem thomas at gllm.fr
Fri May 29 08:32:45 CEST 2020


Hello Pierre,

Could you split this commit in 2, please? One for the memstream migration and one for the ipv6 support.

Thanks!
Thomas

On Thu, May 28, 2020, at 17:54, Pierre Lamot wrote:
>   Url of items discovered when listing smb2 folders where ill-formed on IPv6
>   hosts.
> ---
>  modules/access/smb2.c | 37 +++++++++++++++++++++++++++----------
>  1 file changed, 27 insertions(+), 10 deletions(-)
> 
> diff --git a/modules/access/smb2.c b/modules/access/smb2.c
> index d287493e4f..dee2653ed4 100644
> --- a/modules/access/smb2.c
> +++ b/modules/access/smb2.c
> @@ -42,6 +42,7 @@
>  #include <vlc_keystore.h>
>  #include <vlc_interrupt.h>
>  #include <vlc_network.h>
> +#include <vlc_memstream.h>
>  
>  #include <smb2/smb2.h>
>  #include <smb2/libsmb2.h>
> @@ -323,17 +324,33 @@ static char *
>  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,
> -                 url->psz_path != NULL ? url->psz_path : "",
> -                 url->psz_path != NULL && url->psz_path[0] != '\0' &&
> -                 url->psz_path[strlen(url->psz_path) - 1] != '/' ? "/" 
> : "",
> -                 file,
> -                 url->psz_option != NULL ? "?" : "",
> -                 url->psz_option != NULL ? url->psz_option : "") == -1)
> -        return NULL;
> +    struct vlc_memstream buf;
> +    vlc_memstream_open(&buf);
> +    if (strchr(url->psz_host, ':') != NULL)
> +        vlc_memstream_printf(&buf, "smb://[%s]", url->psz_host);
> +    else
> +        vlc_memstream_printf(&buf, "smb://%s", url->psz_host);
> +
> +    if (url->i_port != 0)
> +        vlc_memstream_printf(&buf, ":%d", url->i_port);
> +
> +    if (url->psz_path != NULL)
> +    {
> +        vlc_memstream_puts(&buf, url->psz_path);
> +        if (url->psz_path[0] != '\0' && 
> url->psz_path[strlen(url->psz_path) - 1] != '/')
> +            vlc_memstream_putc(&buf, '/');
> +    }
>      else
> -        return buf;
> +        vlc_memstream_putc(&buf, '/');
> +
> +    vlc_memstream_puts(&buf, file);
> +
> +    if (url->psz_option)
> +        vlc_memstream_printf(&buf, "?%s", url->psz_option);
> +
> +    if (vlc_memstream_close(&buf))
> +        return NULL;
> +    return buf.ptr;
>  }
>  
>  static int AddItem(stream_t *access, struct vlc_readdir_helper *rdh,
> -- 
> 2.25.1
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list