meta: taglib: reject non expected schemes
authorFrançois Cartegnie <fcvlcdev@free.fr>
Wed, 2 Sep 2020 14:53:13 +0000 (16:53 +0200)
committerSebastian Ramacher <sramacher@debian.org>
Tue, 21 Jan 2025 18:02:47 +0000 (19:02 +0100)
refs #25035

(cherry picked from commit 8191ac5727a3525a6bee99e1674167a7894f9ccb) (rebased)
rebased:
- 3.0 already has a26e2ba370d898dda04c718176af7d2e329dab7a above

Gbp-Pq: Name 0042-meta-taglib-reject-non-expected-schemes.patch

modules/meta_engine/taglib.cpp

index 0b7b5820fc7bb60abfd579a90a8d3e6e526dab39..ced4f56b5fb4c66f02a1e76524cd3f5365a8b763 100644 (file)
@@ -910,6 +910,23 @@ static int ReadWAVMeta( const RIFF::WAV::File *wav, demux_meta_t *demux_meta )
     return VLC_SUCCESS;
 }
 
+static bool isSchemeCompatible( const char *psz_uri )
+{
+    const char *p = strstr( psz_uri, "://" );
+    if( p == NULL )
+        return false;
+
+    size_t i_len = p - psz_uri;
+    const char * compatibleschemes[] =
+    {
+        "file", "smb",
+    };
+    for( size_t i=0; i<ARRAY_SIZE(compatibleschemes); i++ )
+        if( !strncasecmp( psz_uri, compatibleschemes[i], i_len ) )
+            return true;
+    return false;
+}
+
 /**
  * Get the tags from the file using TagLib
  * @param p_this: the demux object
@@ -928,6 +945,12 @@ static int ReadMeta( vlc_object_t* p_this)
     if( unlikely(psz_uri == NULL) )
         return VLC_ENOMEM;
 
+    if( !isSchemeCompatible( psz_uri ) )
+    {
+        free( psz_uri );
+        return VLC_EGENERIC;
+    }
+
     if( !b_extensions_registered )
     {
 #if TAGLIB_VERSION >= TAGLIB_VERSION_1_11