[FFmpeg-devel] [PATCH 2/3] avutil/avstring: Fix av_match_name() with seperators in the name itself

wm4 nfxjfg at googlemail.com
Thu Jun 1 15:56:56 EEST 2017


On Thu,  1 Jun 2017 13:44:45 +0200
Michael Niedermayer <michael at niedermayer.cc> wrote:

> Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> ---
>  libavutil/avstring.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/libavutil/avstring.c b/libavutil/avstring.c
> index f03dd25141..c1348b3a13 100644
> --- a/libavutil/avstring.c
> +++ b/libavutil/avstring.c
> @@ -342,22 +342,28 @@ int av_escape(char **dst, const char *src, const char *special_chars,
>  
>  int av_match_name(const char *name, const char *names)
>  {
> -    const char *p;
> -    int len, namelen;
> +    const char *p, *namep;
> +    int len;
>  
>      if (!name || !names)
>          return 0;
>  
> -    namelen = strlen(name);
>      while (*names) {
>          int negate = '-' == *names;
>          p = strchr(names, ',');
>          if (!p)
>              p = names + strlen(names);
>          names += negate;
> -        len = FFMAX(p - names, namelen);
> -        if (!av_strncasecmp(name, names, len) || !strncmp("ALL", names, FFMAX(3, p - names)))
> -            return !negate;
> +        for (namep = name; namep && *namep; ) {
> +            const char *next_namep = strchr(namep, ',');
> +            int namelen = next_namep ? next_namep - namep : strlen(namep);
> +
> +            len = FFMAX(p - names, namelen);
> +            if (!av_strncasecmp(namep, names, len) || !strncmp("ALL", names, FFMAX(3, p - names)))
> +                return !negate;
> +            namep = next_namep;
> +            namep += !!namep;
> +        }
>          names = p + (*p == ',');
>      }
>      return 0;

The doxygen doesn't specify that name can be comma separated. Thus it's
an API break, as callers might pass names with commas in it, and expect
it not to be matched.


More information about the ffmpeg-devel mailing list