[vlc-commits] [Git][videolan/vlc][master] 4 commits: taglib: limit the amount of data read at once

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Sep 8 08:26:00 UTC 2026



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
a074fac0 by Steve Lhomme at 2026-09-08T08:08:51+00:00
taglib: limit the amount of data read at once

The size of data in ByteVector is limited to unsigned int. We can't read more than that.
Very large values are likely bogus anyway.

Fixes #30094

- - - - -
7338d64b by Steve Lhomme at 2026-09-08T08:08:51+00:00
Revert "meta_engine: taglib: add sequential read limit on VlcIostream"

setMaxSequentialRead() is not a method of IOStream and is not used since
e30871c7724d681d8028dd05b461246899d1ae1e.

This reverts commit d375284a144e6b18896deda3a86b9560bc04f3d8.

- - - - -
e0d0d07b by Steve Lhomme at 2026-09-08T08:08:51+00:00
taglib: add override on overridden methods

- - - - -
4a956b12 by Steve Lhomme at 2026-09-08T08:08:51+00:00
tablib: fix potential read overflow

length() returns a different type since ec29dfca1e59530dd412d779e0b045079b72ffb6.

- - - - -


1 changed file:

- modules/meta_engine/taglib.cpp


Changes:

=====================================
modules/meta_engine/taglib.cpp
=====================================
@@ -204,8 +204,6 @@ public:
         : m_stream( p_stream )
         , m_previousPos( 0 )
         , m_borked( false )
-        , m_seqReadLength( 0 )
-        , m_seqReadLimit( std::numeric_limits<long>::max() )
     {
     }
 
@@ -214,7 +212,7 @@ public:
         vlc_stream_Delete( m_stream );
     }
 
-    FileName name() const
+    FileName name() const override
     {
         // Taglib only cares about the file name part, so it doesn't matter
         // whether we include the mrl scheme or not
@@ -222,12 +220,18 @@ public:
     }
 
 #if TAGLIB_VERSION >= VERSION_INT(2, 0, 0)
-    ByteVector readBlock(size_t length)
+    ByteVector readBlock(size_t length) override
 #else
-    ByteVector readBlock(ulong length)
+    ByteVector readBlock(ulong length) override
 #endif
     {
-        if(m_borked || m_seqReadLength >= m_seqReadLimit)
+        if (length > std::numeric_limits<unsigned int>::max())
+            // ByteVector can't hold more data than unsigned int size
+            // we can read less and provide what we got
+            // we can't return nothing in case it considers it's EOF, so read 16 KB
+            length = 1 << 14;
+
+        if(m_borked)
             return {};
         ByteVector res(length, 0);
         ssize_t i_read = vlc_stream_Read( m_stream, res.data(), length);
@@ -236,60 +240,59 @@ public:
         else if ((size_t)i_read != length)
             res.resize(i_read);
         m_previousPos += i_read;
-        m_seqReadLength += i_read;
         return res;
     }
 
-    void writeBlock(const ByteVector&)
+    void writeBlock(const ByteVector&) override
     {
         // Let's stay Read-Only for now
     }
 
 #if TAGLIB_VERSION >= VERSION_INT(2, 0, 0)
-    void insert(const ByteVector&, offset_t, size_t)
+    void insert(const ByteVector&, offset_t, size_t) override
 #else
-    void insert(const ByteVector&, ulong, ulong)
+    void insert(const ByteVector&, ulong, ulong) override
 #endif
     {
     }
 
 #if TAGLIB_VERSION >= VERSION_INT(2, 0, 0)
-    void removeBlock(offset_t, size_t)
+    void removeBlock(offset_t, size_t) override
 #else
-    void removeBlock(ulong, ulong)
+    void removeBlock(ulong, ulong) override
 #endif
     {
     }
 
-    bool readOnly() const
+    bool readOnly() const override
     {
         return true;
     }
 
-    bool isOpen() const
+    bool isOpen() const override
     {
         return true;
     }
 
-    void setMaxSequentialRead(long s)
-    {
-        m_seqReadLimit = s;
-    }
-
 #if TAGLIB_VERSION >= VERSION_INT(2, 0, 0)
-    void seek(offset_t offset, Position p)
+    void seek(offset_t offset, Position p) override
 #else
-    void seek(long offset, Position p)
+    void seek(long offset, Position p) override
 #endif
     {
         uint64_t pos = 0;
-        long len;
         switch (p)
         {
             case Current:
                 pos = m_previousPos;
                 break;
             case End:
+            {
+#if TAGLIB_VERSION >= VERSION_INT(2, 0, 0)
+                offset_t len;
+#else
+                long len;
+#endif
                 len = length();
                 if(len > -1)
                 {
@@ -301,33 +304,33 @@ public:
                     return;
                 }
                 break;
+            }
             default:
                 break;
         }
         m_borked = (vlc_stream_Seek( m_stream, pos + offset ) != 0);
         if(!m_borked)
             m_previousPos = pos + offset;
-        m_seqReadLength = 0;
     }
 
-    void clear()
+    void clear() override
     {
         return;
     }
 
 #if TAGLIB_VERSION >= VERSION_INT(2, 0, 0)
-    offset_t tell() const
+    offset_t tell() const override
 #else
-    long tell() const
+    long tell() const override
 #endif
     {
         return m_previousPos;
     }
 
 #if TAGLIB_VERSION >= VERSION_INT(2, 0, 0)
-    offset_t length()
+    offset_t length() override
 #else
-    long length()
+    long length() override
 #endif
     {
         uint64_t i_size;
@@ -337,9 +340,9 @@ public:
     }
 
 #if TAGLIB_VERSION >= VERSION_INT(2, 0, 0)
-    void truncate(offset_t)
+    void truncate(offset_t) override
 #else
-    void truncate(long)
+    void truncate(long) override
 #endif
     {
     }
@@ -348,8 +351,6 @@ private:
     stream_t* m_stream;
     int64_t m_previousPos;
     bool m_borked;
-    long m_seqReadLength;
-    long m_seqReadLimit;
 };
 
 static int ExtractCoupleNumberValues( vlc_meta_t* p_meta, const char *psz_value,



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a6c467e743f49055282d8b7696c8c401cdff4fcd...4a956b129931934456dd1a88a0fbea0aeeeb8505

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a6c467e743f49055282d8b7696c8c401cdff4fcd...4a956b129931934456dd1a88a0fbea0aeeeb8505
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list