[vlc-commits] contrib:ebml: Do not use elements with an unknown size if it's not allowed

Steve Lhomme git at videolan.org
Wed Dec 6 10:10:18 CET 2017


vlc/vlc-3.0 | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Wed Dec  6 09:36:23 2017 +0100| [5c5f72bb4cf4702561aa6b6fb2a870e33f5c581c] | committer: Hugo Beauzée-Luyssen

contrib:ebml: Do not use elements with an unknown size if it's not allowed

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>
(cherry picked from commit 5094c8e334680a69b2832e3aa93c56fa23d133b4)
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=5c5f72bb4cf4702561aa6b6fb2a870e33f5c581c
---

 contrib/src/ebml/rules.mak           |  1 +
 contrib/src/ebml/unknown-check.patch | 43 ++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/contrib/src/ebml/rules.mak b/contrib/src/ebml/rules.mak
index cb5667e8eb..d77032a08e 100644
--- a/contrib/src/ebml/rules.mak
+++ b/contrib/src/ebml/rules.mak
@@ -11,6 +11,7 @@ $(TARBALLS)/libebml-$(EBML_VERSION).tar.xz:
 ebml: libebml-$(EBML_VERSION).tar.xz .sum-ebml
 	$(UNPACK)
 	$(APPLY) $(SRC)/ebml/ebml-maxread.patch
+	$(APPLY) $(SRC)/ebml/unknown-check.patch
 	$(MOVE)
 
 # libebml requires exceptions
diff --git a/contrib/src/ebml/unknown-check.patch b/contrib/src/ebml/unknown-check.patch
new file mode 100644
index 0000000000..895a4d664e
--- /dev/null
+++ b/contrib/src/ebml/unknown-check.patch
@@ -0,0 +1,43 @@
+From ff0dc3cc21494578ce731f5d7dcde5fdec23d40f Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <slhomme at matroska.org>
+Date: Wed, 6 Dec 2017 09:32:13 +0100
+Subject: [PATCH] Do not output an element with size Unknown if it's not
+ allowed
+
+Similar to what is done in FindNextID().
+
+SetSizeInfinite() doesn't actually set anything. SetSizeIsFinite() is the one
+that actually sets it and it is an internal API.
+---
+ src/EbmlElement.cpp | 14 ++++++--------
+ 1 file changed, 6 insertions(+), 8 deletions(-)
+
+diff --git a/src/EbmlElement.cpp b/src/EbmlElement.cpp
+index ae4441e..ac0be41 100644
+--- a/src/EbmlElement.cpp
++++ b/src/EbmlElement.cpp
+@@ -461,15 +461,13 @@ EbmlElement * EbmlElement::FindNextElement(IOCallback & DataStream, const EbmlSe
+           //  1 : same level
+           //  + : further parent
+           if (Result->ValidateSize() && (SizeFound == SizeUnknown || UpperLevel > 0 || MaxDataSize == 0 || MaxDataSize >= (PossibleID_Length + PossibleSizeLength + SizeFound))) {
+-            if (SizeFound == SizeUnknown) {
+-              Result->SetSizeInfinite();
++            if (SizeFound != SizeUnknown || Result->SetSizeInfinite()) {
++              Result->SizePosition = DataStream.getFilePointer() - SizeIdx + EBML_ID_LENGTH(PossibleID);
++              Result->ElementPosition = Result->SizePosition - EBML_ID_LENGTH(PossibleID);
++              // place the file at the beggining of the data
++              DataStream.setFilePointer(Result->SizePosition + _SizeLength);
++              return Result;
+             }
+-
+-            Result->SizePosition = DataStream.getFilePointer() - SizeIdx + EBML_ID_LENGTH(PossibleID);
+-            Result->ElementPosition = Result->SizePosition - EBML_ID_LENGTH(PossibleID);
+-            // place the file at the beggining of the data
+-            DataStream.setFilePointer(Result->SizePosition + _SizeLength);
+-            return Result;
+           }
+         }
+         delete Result;
+-- 
+2.10.1.windows.1
+



More information about the vlc-commits mailing list