[FFmpeg-devel] [PATCH] Handling special characters in a URL.

Michael Niedermayer michaelni at gmx.at
Mon Mar 4 15:19:42 CET 2013


On Mon, Mar 04, 2013 at 06:30:03AM +0530, Senthilnathan Maadasamy wrote:
> On Sat, Mar 2, 2013 at 2:35 AM, Michael Niedermayer <michaelni at gmx.at>wrote:
> 
> > On Fri, Mar 01, 2013 at 08:02:44AM +0530, Senthilnathan Maadasamy wrote:
> > > On Fri, Mar 1, 2013 at 7:49 AM, Michael Niedermayer <michaelni at gmx.at
> > >wrote:
> >
> +static void percent_encode_url(char *component, size_t component_size = 0,
> > +                               const char *allowed)
> > +{
> > +    char enc[MAX_URL_SIZE], c;
> > +    int enc_len = 0;
> > +    char *src = component;
> > +
> > +    if (!src) return;
> > +
> >
> > +    while (c = *src) {
> >
> > accesses out of array, src is 0 elements large so any access must be
> > outside
> >
> > i dont know if this is the only case where this happens
> 
> Agreed.  This can also happen in some cases where component_size != 0.
>  Fixed and attached the patch.
> 
> Thanks,
> Senthil

>  utils.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 50 insertions(+)
> 0d6c0383ddf0fe9de96577a2acc67557536d69b1  special-characters-in-URL.patch
> From d705db3edf676897ead7942d439c15a13bec6b26 Mon Sep 17 00:00:00 2001
> From: Senthilnathan M <senthilnathan.maadasamy at gmail.com>
> Date: Sun, 10 Feb 2013 23:08:52 +0530
> Subject: [PATCH] Support for special characters in URL.  Fixes ticket 2031.
> 
> Signed-off-by: Senthilnathan M <senthilnathan.maadasamy at gmail.com>
> ---
>  libavformat/utils.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 50 insertions(+)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 6024205..7770418 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -3767,6 +3767,53 @@ void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload,
>      pkt_dump_internal(avcl, NULL, level, pkt, dump_payload, st->time_base);
>  }
>  
> +/**
> + * Percent encode part of an URL string according to RFC 3986.
> + *
> + * @param component      portion of an URL (e.g. protocol, hostname, path) to
> + *                       percent-encode.  This will be percent-encoded in place.
> + * @param component_size size in bytes of the component buffer
> + * @param allowed        string containing the allowed characters which must not be
> + *                       encoded. It may be NULL if there are no such characters.
> + */
> +static void percent_encode_url(char *component, size_t component_size,
> +                               const char *allowed)
> +{
> +    char enc[MAX_URL_SIZE], c;
> +    size_t enc_len = 0;
> +    size_t len = 0;
> +    char *src = component;
> +
> +    if (!src) return;
> +
> +    while (len < component_size && (c = src[len])) {

> +        if (isalnum(c) || strchr("-._~%", c) ||

isalnum is locale specific

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130304/36810e66/attachment.asc>


More information about the ffmpeg-devel mailing list