[vlc-devel] [PATCH] upnp: Correct top directory url formatting

Rémi Denis-Courmont remi at remlab.net
Thu Nov 19 16:13:56 CET 2020


Le keskiviikkona 18. marraskuuta 2020, 20.32.27 EET dev.asenat at posteo.net a 
écrit :
> From: Alaric Senat <dev.asenat at posteo.net>
> 
> As pointed out in #25055 the choice of url option delimiter is probably
> meant to be that way. std::string.find() returns std::string::npos (aka
> -1) in case of no match.
> ---
>  modules/services_discovery/upnp.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/modules/services_discovery/upnp.cpp
> b/modules/services_discovery/upnp.cpp index 054a5d1910..a249e3b4d2 100644
> --- a/modules/services_discovery/upnp.cpp
> +++ b/modules/services_discovery/upnp.cpp
> @@ -407,7 +407,7 @@ bool MediaServerList::addServer( MediaServerDesc* desc )
> } else {
>          char* psz_mrl;
>          // We might already have some options specified in the location.
> -        char opt_delim = desc->location.find( '?' ) == 0 ? '?' : '&';
> +        char opt_delim = desc->location.find( '?' ) == std::string::npos ?
> '?' : '&'; if( asprintf( &psz_mrl, "upnp://%s%cObjectID=0",
> desc->location.c_str(), opt_delim ) < 0 ) return false;

Are you sure that the URL ends with either a list of parameters or a path? 
There are other cases that this leaves broken. Blindly appending to a URL is 
not a great idea.


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





More information about the vlc-devel mailing list