[vlc-commits] [Git][videolan/vlc][master] 6 commits: contrib: matroska: do not use Blocks with invalid track numbers
Steve Lhomme (@robUx4)
gitlab at videolan.org
Tue Nov 17 10:53:17 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
974e30ea by Steve Lhomme at 2026-11-17T09:19:39+00:00
contrib: matroska: do not use Blocks with invalid track numbers
This is done in SCOPE_ALL_DATA but not in SCOPE_PARTIAL_DATA.
Fixes #30283
Reported-by: Anthropic (ANT-2026-82J8BC58)
- - - - -
5cc3af2d by Steve Lhomme at 2026-11-17T09:19:39+00:00
demux: mkv: skip empty blocks when estimating duration
Partial reads can leave blocks without parsed frames. Skip those
blocks before using their timestamps to estimate the duration.
Refs #30283
Reported-by: Anthropic (ANT-2026-82J8BC58)
- - - - -
07c4d49a by Steve Lhomme at 2026-11-17T09:19:39+00:00
contrib: ebml: use readFully() to read EbmlBinary data
We don't support truncated reading of elements. And it was the last
class not to use readFully().
Fixes #30359
Originally reported in libebml [^1].
Reported-by: Judith Malshini (@JudithMalshini) , Chamod Anuradha (@Chamodanu), Anthropic (ANT-2026-VL8FHAAF).
[^1]: https://github.com/Matroska-Org/libebml/issues/360
- - - - -
8ea333df by Steve Lhomme at 2026-11-17T09:19:39+00:00
demux: mkv: check the VobSub extra data + 1 doesn't wrap
Fixes #30369
Reported-by: Anthropic (ANT-2026-82J8BC58)
- - - - -
44209c5c by Steve Lhomme at 2026-11-17T09:19:39+00:00
demux: mkv: return a regular int on error/success in zlib_decompress_extra()
- - - - -
d07ac7a2 by Steve Lhomme at 2026-11-17T09:19:39+00:00
demux: mkv: do not allocate extra data that can't fit i_extra_data
Refs #30369
Reported-by: Anthropic (ANT-2026-ZCIOBJ3U)
- - - - -
8 changed files:
- + contrib/src/ebml/0001-EbmlBinary-use-readFully-to-read-the-data.patch
- contrib/src/ebml/rules.mak
- + contrib/src/matroska/0001-KaxBlock-throw-an-exception-when-encountering-a-larg.patch
- contrib/src/matroska/rules.mak
- modules/demux/mkv/matroska_segment.cpp
- modules/demux/mkv/util.cpp
- modules/demux/mkv/util.hpp
- modules/demux/vobsub.h
Changes:
=====================================
contrib/src/ebml/0001-EbmlBinary-use-readFully-to-read-the-data.patch
=====================================
@@ -0,0 +1,35 @@
+From 25bf1456c2492174d2e1820eb6a09aa61413fb9a Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <slhomme at matroska.org>
+Date: Fri, 6 Nov 2026 11:59:12 +0100
+Subject: [PATCH] EbmlBinary: use readFully() to read the data
+
+We don't support truncated reading of elements. And it was the last
+class not to use readFully().
+
+This is also how the other EBML types are reading their full data.
+
+Reported-by: Judith Malshini (@JudithMalshini) , Chamod Anuradha (@Chamodanu)
+
+Fixes #360
+---
+ src/EbmlBinary.cpp | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/EbmlBinary.cpp b/src/EbmlBinary.cpp
+index a465c2f..0c0d832 100644
+--- a/src/EbmlBinary.cpp
++++ b/src/EbmlBinary.cpp
+@@ -100,8 +100,9 @@ filepos_t EbmlBinary::ReadData(IOCallback & input, ScopeMode ReadFully)
+ Data = (GetSize() < SIZE_MAX) ? static_cast<binary *>(malloc(GetSize())) : nullptr;
+ if (Data == nullptr)
+ throw CRTError(std::string("Error allocating data"));
++ input.readFully(Data, GetSize());
+ SetValueIsSet();
+- return input.read(Data, GetSize());
++ return GetSize();
+ }
+
+ bool EbmlBinary::operator==(const EbmlBinary & ElementToCompare) const
+--
+2.52.0.windows.1
+
=====================================
contrib/src/ebml/rules.mak
=====================================
@@ -16,6 +16,7 @@ $(TARBALLS)/libebml-$(EBML_VERSION).tar.xz:
ebml: libebml-$(EBML_VERSION).tar.xz .sum-ebml
$(UNPACK)
+ $(APPLY) $(SRC)/ebml/0001-EbmlBinary-use-readFully-to-read-the-data.patch
$(MOVE)
.ebml: ebml toolchain.cmake
=====================================
contrib/src/matroska/0001-KaxBlock-throw-an-exception-when-encountering-a-larg.patch
=====================================
@@ -0,0 +1,31 @@
+From 8511b049d2f6a5382ba4132f8d9b75dd8dc6eb9f Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <slhomme at matroska.org>
+Date: Thu, 5 Nov 2026 11:05:17 +0100
+Subject: [PATCH] KaxBlock: throw an exception when encountering a large track
+ number
+
+This was already done in 4457e70466dcc77984202a05525428383cb74fe3 for SCOPE_ALL_DATA
+but the same should be done for SCOPE_PARTIAL_DATA.
+(maybe that common code should be factorized)
+
+Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-82J8BC58.
+---
+ src/KaxBlock.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/KaxBlock.cpp b/src/KaxBlock.cpp
+index cf213c9..ce2ab71 100644
+--- a/src/KaxBlock.cpp
++++ b/src/KaxBlock.cpp
+@@ -618,7 +618,7 @@ filepos_t KaxInternalBlock::ReadData(IOCallback & input, ScopeMode ReadFully)
+ // there is extra data
+ if ((TrackNumber & 0x40) == 0) {
+ // We don't support track numbers that large !
+- return Result;
++ throw SafeReadIOCallback::EndOfStreamX(0);
+ }
+ TrackNumber = (TrackNumber & 0x3F) << 8;
+ TrackNumber += *cursor++;
+--
+2.52.0.windows.1
+
=====================================
contrib/src/matroska/rules.mak
=====================================
@@ -18,6 +18,7 @@ $(TARBALLS)/libmatroska-$(MATROSKA_VERSION).tar.xz:
matroska: libmatroska-$(MATROSKA_VERSION).tar.xz .sum-matroska
$(UNPACK)
+ $(APPLY) $(SRC)/matroska/0001-KaxBlock-throw-an-exception-when-encountering-a-larg.patch
$(call pkg_static,"libmatroska.pc.in")
$(MOVE)
=====================================
modules/demux/mkv/matroska_segment.cpp
=====================================
@@ -1055,6 +1055,10 @@ bool matroska_segment_c::EnsureDuration(KaxCluster & fromCluster)
{
if( MKV_CHECKED_PTR_DECL ( simpleblock, KaxSimpleBlock, l ) )
{
+ // with SCOPE_PARTIAL_DATA a Block whose header could not be
+ // read is kept in the Cluster, without frames or timestamp
+ if( simpleblock->NumberFrames() == 0 )
+ continue;
simpleblock->SetParent( *p_last_cluster );
i_last_timecode = std::max(i_last_timecode, simpleblock->GlobalTimestamp());
}
@@ -1065,6 +1069,8 @@ bool matroska_segment_c::EnsureDuration(KaxCluster & fromCluster)
{
if( MKV_CHECKED_PTR_DECL ( block, KaxBlock, g ) )
{
+ if( block->NumberFrames() == 0 )
+ continue;
block->SetParent( *p_last_cluster );
i_group_timecode += block->GlobalTimestamp();
}
=====================================
modules/demux/mkv/util.cpp
=====================================
@@ -35,7 +35,7 @@ namespace mkv {
*****************************************************************************/
#ifdef HAVE_ZLIB
-int32_t zlib_decompress_extra( demux_t * p_demux, mkv_track_t & tk )
+int zlib_decompress_extra( demux_t * p_demux, mkv_track_t & tk )
{
int result;
z_stream d_stream;
@@ -59,6 +59,15 @@ int32_t zlib_decompress_extra( demux_t * p_demux, mkv_track_t & tk )
do
{
n++;
+ if (n*1024 > std::numeric_limits<decltype(tk.i_extra_data)>::max())
+ {
+ msg_Err( p_demux, "Decompressed data too large, ignore track %u",
+ tk.i_number );
+ free(p_new_extra);
+ inflateEnd( &d_stream );
+ return 1;
+ }
+
void *alloc = realloc(p_new_extra, n*1024);
if( alloc == NULL )
{
=====================================
modules/demux/mkv/util.hpp
=====================================
@@ -27,7 +27,7 @@
namespace mkv {
#ifdef HAVE_ZLIB_H
-int32_t zlib_decompress_extra( demux_t * p_demux, mkv_track_t & tk );
+int zlib_decompress_extra( demux_t * p_demux, mkv_track_t & tk );
block_t *block_zlib_decompress( vlc_object_t *p_this, block_t *p_in_block );
#endif
bool lzo1x_decompress_extra( demux_t * p_demux, mkv_track_t & tk );
=====================================
modules/demux/vobsub.h
=====================================
@@ -20,6 +20,10 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
+// available in C++26, we compile with C++17
+// so we use our helper rather than the toolchain header
+#include "../../compat/stdckdint/stdckdint.h"
+
static inline void vobsub_palette_argb2ayvu( const uint32_t *src, uint32_t *dst )
{
int i;
@@ -78,8 +82,14 @@ static inline int vobsub_size_parse( const char *psz_buf,
static inline void vobsub_extra_parse(vlc_object_t *o, subs_format_t *subs,
const uint8_t *buf, size_t buf_size)
{
+ size_t extra_nul;
+ if (ckd_add(&extra_nul, buf_size, 1))
+ {
+ msg_Warn( o, "VobSub extra data too large %zu", buf_size );
+ return;
+ }
char *psz_start;
- char *psz_buf = (char*)malloc( buf_size + 1);
+ char *psz_buf = (char*)malloc( extra_nul );
if( unlikely( psz_buf == NULL ) )
return;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b4213d48aadcf82ee1ff115f4470069000ecbf45...d07ac7a2248bf7dac1b30f880109f8e83a208734
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b4213d48aadcf82ee1ff115f4470069000ecbf45...d07ac7a2248bf7dac1b30f880109f8e83a208734
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