[vlc-commits] [Git][videolan/vlc][master] contrib: matroska: fix reading EBML lacing with just one frame
Steve Lhomme (@robUx4)
gitlab at videolan.org
Thu May 14 08:36:46 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
6f3c4087 by Steve Lhomme at 2026-05-14T07:57:09+00:00
contrib: matroska: fix reading EBML lacing with just one frame
The spec [^1] is not clear whether when there is a single frame in the lace
the size of the frame should be written. However it is forbidden to put
a single frame in a lace [^2]. libmatroska doesn't support it.
libavformat doesn't support lacing writing.
However the last frame size is never written in any lace, so that's the
first one when there's only one frame.
Fixes #29832
[^1]: https://www.rfc-editor.org/rfc/rfc9559#section-10.3.3
[^2]: https://www.rfc-editor.org/rfc/rfc9559#section-10.3
- - - - -
4 changed files:
- contrib/src/matroska/0001-KaxBlock-rework-EBML-lacing-sizes-in-SCOPE_PARTIAL_D.patch
- contrib/src/matroska/0002-KaxBlock-throw-when-the-EBML-length-difference-gives.patch
- + contrib/src/matroska/0003-KaxBlock-fix-reading-EBML-lacing-with-just-one-frame.patch
- contrib/src/matroska/rules.mak
Changes:
=====================================
contrib/src/matroska/0001-KaxBlock-rework-EBML-lacing-sizes-in-SCOPE_PARTIAL_D.patch
=====================================
@@ -1,7 +1,7 @@
From 058046e606eb60fcc0ce0ef3801ed11cf7e0e997 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4 at ycbcr.xyz>
Date: Tue, 28 Apr 2026 10:08:39 +0200
-Subject: [PATCH 1/2] KaxBlock: rework EBML lacing sizes in SCOPE_PARTIAL_DATA
+Subject: [PATCH 1/3] KaxBlock: rework EBML lacing sizes in SCOPE_PARTIAL_DATA
mode
We only read the bytes that correspond to frame sizes, rather
=====================================
contrib/src/matroska/0002-KaxBlock-throw-when-the-EBML-length-difference-gives.patch
=====================================
@@ -1,7 +1,7 @@
From b4c4a7ef50b3bb8cac30975437c89a377240ef6f Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4 at ycbcr.xyz>
Date: Tue, 28 Apr 2026 11:30:11 +0200
-Subject: [PATCH 2/2] KaxBlock: throw when the EBML length difference gives a
+Subject: [PATCH 2/3] KaxBlock: throw when the EBML length difference gives a
negative frame length
---
=====================================
contrib/src/matroska/0003-KaxBlock-fix-reading-EBML-lacing-with-just-one-frame.patch
=====================================
@@ -0,0 +1,43 @@
+From 66e4f59d325afc159b7a1e05683dd8b8698459ea Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Mon, 11 May 2026 09:43:20 +0200
+Subject: [PATCH 3/3] KaxBlock: fix reading EBML lacing with just one frame
+
+The spec [^1] is not clear whether when there is a single frame in the lace
+the size of the frame should be written. However it is forbidden to put
+a single frame in a lace [^2]. libmatroska doesn't support it.
+libavformat doesn't support lacing writing.
+However the last frame size is never written in any lace, so that's the
+first one when there's only one frame.
+
+[^1]: https://www.rfc-editor.org/rfc/rfc9559#section-10.3.3
+[^2]: https://www.rfc-editor.org/rfc/rfc9559#section-10.3
+---
+ src/KaxBlock.cpp | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/KaxBlock.cpp b/src/KaxBlock.cpp
+index ddf8b14..eccb4c7 100644
+--- a/src/KaxBlock.cpp
++++ b/src/KaxBlock.cpp
+@@ -683,6 +683,9 @@ filepos_t KaxInternalBlock::ReadData(IOCallback & input, ScopeMode ReadFully)
+ throw SafeReadIOCallback::EndOfStreamX(0);
+ };
+
++ if (FrameNum == 0)
++ Index = 0;
++ else {
+ binary length_buf[8];
+ if (input.read(length_buf, 1) != 1)
+ throw SafeReadIOCallback::EndOfStreamX(0);
+@@ -723,6 +726,7 @@ filepos_t KaxInternalBlock::ReadData(IOCallback & input, ScopeMode ReadFully)
+ SizeList[Index] = FrameSize;
+ LastBufferSize -= FrameSize + SizeRead;
+ }
++ }
+
+ SizeList[Index] = LastBufferSize;
+ break;
+--
+2.52.0.windows.1
+
=====================================
contrib/src/matroska/rules.mak
=====================================
@@ -23,6 +23,7 @@ matroska: libmatroska-$(MATROSKA_VERSION).tar.xz .sum-matroska
$(APPLY) $(SRC)/matroska/0001-KaxBlock-release-read-buffers-on-EndOfStream-error.patch
$(APPLY) $(SRC)/matroska/0001-KaxBlock-rework-EBML-lacing-sizes-in-SCOPE_PARTIAL_D.patch
$(APPLY) $(SRC)/matroska/0002-KaxBlock-throw-when-the-EBML-length-difference-gives.patch
+ $(APPLY) $(SRC)/matroska/0003-KaxBlock-fix-reading-EBML-lacing-with-just-one-frame.patch
$(MOVE)
.matroska: matroska toolchain.cmake
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/6f3c40871388ecdc3f1171acbeaec94c4bfd017e
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/6f3c40871388ecdc3f1171acbeaec94c4bfd017e
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list