[vlc-devel] [PATCH] http: handle 302 relative redirections

Denis Charmet typx at dinauz.org
Mon Dec 2 14:26:39 CET 2013


Hi,
Le lundi 02 décembre 2013 à 12:34:36, Francois Cartegnie a écrit :
> Wrong branch;
> That one handles both appending and /foo redirections.
> 
> ---
>  modules/access/http.c | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/modules/access/http.c b/modules/access/http.c
> index 3908fb7..2fc1dab 100644
> --- a/modules/access/http.c
> +++ b/modules/access/http.c
> @@ -488,6 +488,42 @@ connect:
>              goto error;
>          }
>  
> +        /* Test if we have a relative redirection */
> +        if ( !strstr( p_sys->psz_location, "://" ) )
> +        {
> +            char *psz_temp;
> +            size_t i_scheme_length = strlen( p_access->psz_access );
> +            size_t i_append_length = strlen( p_sys->psz_location );
> +            size_t i_current_length = 0;
> +            if ( *p_sys->psz_location != '/' )
> +            {
> +                i_current_length = strlen( p_access->psz_location );
> +            }
> +            else
> +            {
> +                psz_temp = index( p_access->psz_location, '/' );
> +                if ( psz_temp )
> +                    i_current_length = psz_temp - p_access->psz_location + 1;
> +            }
> +            psz_temp = malloc( i_scheme_length + 3 + i_current_length +
> +                               i_append_length + 1 );
> +            if ( !psz_temp )
> +                goto error;
> +            char *psz = psz_temp;
> +            memcpy( psz, p_access->psz_access, i_scheme_length );
> +            psz += i_scheme_length;
> +            memcpy( psz, "://", 3 );
> +            psz += 3;
> +            memcpy( psz, p_access->psz_location, i_current_length );
> +            psz += i_current_length;
> +            memcpy( psz, p_sys->psz_location, i_append_length );
> +            psz += i_append_length;
> +            *psz = 0;
why not snprintf(psz_temp, <size>,"%s://%s%s",...)? or even asprintf()?
> +            free( p_sys->psz_location );
> +            p_sys->psz_location = psz_temp;
> +            msg_Dbg( p_access, "redirection after relative fix to %s", p_sys->psz_location );
> +        }
> +
>          const char *psz_protocol;
>          if( !strncmp( p_sys->psz_location, "http://", 7 ) )
>              psz_protocol = "http";
> -- 
> 1.8.3.1
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel

Regards,

-- 
Denis Charmet - TypX
Le mauvais esprit est un art de vivre



More information about the vlc-devel mailing list