Commit 064c638a authored by Rémi Duraffort's avatar Rémi Duraffort

Fix an infinite loop if we redirect from http to https (or contrary).

parent 220f75c8
...@@ -205,7 +205,8 @@ struct access_sys_t ...@@ -205,7 +205,8 @@ struct access_sys_t
}; };
/* */ /* */
static int OpenWithCookies( vlc_object_t *p_this, vlc_array_t *cookies ); static int OpenWithCookies( vlc_object_t *p_this, const char *psz_access,
vlc_array_t *cookies );
/* */ /* */
static ssize_t Read( access_t *, uint8_t *, size_t ); static ssize_t Read( access_t *, uint8_t *, size_t );
...@@ -238,10 +239,20 @@ static void AuthReset( http_auth_t *p_auth ); ...@@ -238,10 +239,20 @@ static void AuthReset( http_auth_t *p_auth );
*****************************************************************************/ *****************************************************************************/
static int Open( vlc_object_t *p_this ) static int Open( vlc_object_t *p_this )
{ {
return OpenWithCookies( p_this, NULL ); access_t *p_access = (access_t*)p_this;
return OpenWithCookies( p_this, p_access->psz_access, NULL );
} }
static int OpenWithCookies( vlc_object_t *p_this, vlc_array_t *cookies ) /**
* Open the given url using the given cookies
* @param p_this: the vlc object
* @psz_access: the acces to use (http, https, ...) (this value must be used
* instead of p_access->psz_access)
* @cookies: the available cookies
* @return vlc error codes
*/
static int OpenWithCookies( vlc_object_t *p_this, const char *psz_access,
vlc_array_t *cookies )
{ {
access_t *p_access = (access_t*)p_this; access_t *p_access = (access_t*)p_this;
access_sys_t *p_sys; access_sys_t *p_sys;
...@@ -305,7 +316,7 @@ static int OpenWithCookies( vlc_object_t *p_this, vlc_array_t *cookies ) ...@@ -305,7 +316,7 @@ static int OpenWithCookies( vlc_object_t *p_this, vlc_array_t *cookies )
msg_Warn( p_access, "invalid host" ); msg_Warn( p_access, "invalid host" );
goto error; goto error;
} }
if( !strncmp( p_access->psz_access, "https", 5 ) ) if( !strncmp( psz_access, "https", 5 ) )
{ {
/* HTTP over SSL */ /* HTTP over SSL */
p_sys->b_ssl = true; p_sys->b_ssl = true;
...@@ -337,7 +348,7 @@ static int OpenWithCookies( vlc_object_t *p_this, vlc_array_t *cookies ) ...@@ -337,7 +348,7 @@ static int OpenWithCookies( vlc_object_t *p_this, vlc_array_t *cookies )
{ {
char *buf; char *buf;
int i; int i;
i=asprintf(&buf, "%s://%s", p_access->psz_access, p_access->psz_path); i=asprintf(&buf, "%s://%s", psz_access, p_access->psz_path);
if (i >= 0) if (i >= 0)
{ {
msg_Dbg(p_access, "asking libproxy about url '%s'", buf); msg_Dbg(p_access, "asking libproxy about url '%s'", buf);
...@@ -473,9 +484,12 @@ connect: ...@@ -473,9 +484,12 @@ connect:
msg_Dbg( p_access, "redirection to %s", p_sys->psz_location ); msg_Dbg( p_access, "redirection to %s", p_sys->psz_location );
/* Do not accept redirection outside of HTTP works */ /* Do not accept redirection outside of HTTP works */
if( strncmp( p_sys->psz_location, "http", 4 ) const char *psz_protocol;
|| ( ( p_sys->psz_location[4] != ':' ) /* HTTP */ if( !strncmp( p_sys->psz_location, "http:", 5 ) )
&& strncmp( p_sys->psz_location + 4, "s:", 2 ) /* HTTP/SSL */ ) ) psz_protocol = "http";
else if( !strncmp( p_sys->psz_location, "https:", 6 ) )
psz_protocol = "https";
else
{ {
msg_Err( p_access, "insecure redirection ignored" ); msg_Err( p_access, "insecure redirection ignored" );
goto error; goto error;
...@@ -501,7 +515,7 @@ connect: ...@@ -501,7 +515,7 @@ connect:
free( p_sys ); free( p_sys );
/* Do new Open() run with new data */ /* Do new Open() run with new data */
return OpenWithCookies( p_this, cookies ); return OpenWithCookies( p_this, psz_protocol, cookies );
} }
if( p_sys->b_mms ) if( p_sys->b_mms )
...@@ -549,7 +563,7 @@ connect: ...@@ -549,7 +563,7 @@ connect:
} }
/* else probably Ogg Vorbis */ /* else probably Ogg Vorbis */
} }
else if( !strcasecmp( p_access->psz_access, "unsv" ) && else if( !strcasecmp( psz_access, "unsv" ) &&
p_sys->psz_mime && p_sys->psz_mime &&
!strcasecmp( p_sys->psz_mime, "misc/ultravox" ) ) !strcasecmp( p_sys->psz_mime, "misc/ultravox" ) )
{ {
...@@ -557,7 +571,7 @@ connect: ...@@ -557,7 +571,7 @@ connect:
/* Grrrr! detect ultravox server and force NSV demuxer */ /* Grrrr! detect ultravox server and force NSV demuxer */
p_access->psz_demux = strdup( "nsv" ); p_access->psz_demux = strdup( "nsv" );
} }
else if( !strcmp( p_access->psz_access, "itpc" ) ) else if( !strcmp( psz_access, "itpc" ) )
{ {
free( p_access->psz_demux ); free( p_access->psz_demux );
p_access->psz_demux = strdup( "podcast" ); p_access->psz_demux = strdup( "podcast" );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment