diff mbox series

[FFmpeg-devel,17/23] fftools/cmdutils: tighten condition for media type stream specifiers

Message ID 20240914111036.17164-18-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/23] compat: drop gcc, suncc, and pthreads stdatomic emulation | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov Sept. 14, 2024, 10:45 a.m. UTC
Require the character indicating media type to be followed by a
non-alphanumeric character (or end of string).

Needed by future syntax extensions.
---
 fftools/cmdutils.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index a9a7ff4194..1573106d8b 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -988,6 +988,12 @@  FILE *get_preset_file(char *filename, size_t filename_size,
     return f;
 }
 
+static int cmdutils_isalnum(char c)
+{
+    return (c >= '0' && c <= '9') ||
+           (c >= 'A' && c <= 'Z') ||
+           (c >= 'a' && c <= 'z');
+}
 
 void stream_specifier_uninit(StreamSpecifier *ss)
 {
@@ -1024,8 +1030,9 @@  int stream_specifier_parse(StreamSpecifier *ss, const char *spec,
 
             // this terminates the specifier
             break;
-        } else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' ||
-                   *spec == 't' || *spec == 'V') { /* opt:[vasdtV] */
+        } else if ((*spec == 'v' || *spec == 'a' || *spec == 's' ||
+                    *spec == 'd' || *spec == 't' || *spec == 'V') &&
+                   !cmdutils_isalnum(*(spec + 1))) { /* opt:[vasdtV] */
             if (ss->media_type != AVMEDIA_TYPE_UNKNOWN) {
                 av_log(logctx, AV_LOG_ERROR, "Stream type specified multiple times\n");
                 ret = AVERROR(EINVAL);