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

Michael Niedermayer michael at niedermayer.cc
Thu Jun 1 14:44:45 EEST 2017


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;
-- 
2.13.0



More information about the ffmpeg-devel mailing list