summaryrefslogtreecommitdiffstats
path: root/vlc/build/patches/ebml_maxread.patch
blob: e1b98cf64955446a76fec3438f097ee53fae868d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Source: http://git.videolan.org/?p=vlc/vlc-3.0.git;a=blob;f=contrib/src/ebml/ebml-maxread.patch
ebml: Do not use elements with an unknown size if it's not allowed

--- ebml/src/EbmlElement.cpp	2017-11-27 09:12:56.891612600 +0100
+++ ebml/src/EbmlElement.cpp.maxread	2017-11-27 09:29:17.335279000 +0100
@@ -404,12 +404,14 @@ EbmlElement * EbmlElement::FindNextEleme
         memmove(&PossibleIdNSize[0],&PossibleIdNSize[1], --ReadIndex);
       }
 
+      if (MaxDataSize <= ReadSize)
+          break;
       if (DataStream.read(&PossibleIdNSize[ReadIndex++], 1) == 0) {
         return NULL; // no more data ?
       }
       ReadSize++;
 
-    } while (!bFound && MaxDataSize > ReadSize);
+    } while (!bFound);
 
     if (!bFound)
       // we reached the maximum we could read without a proper ID
@@ -432,6 +434,10 @@ EbmlElement * EbmlElement::FindNextEleme
         bFound = false;
         break;
       }
+      if (MaxDataSize <= ReadSize) {
+        bFound = false;
+        break;
+      }
       if( DataStream.read( &PossibleIdNSize[SizeIdx++], 1 ) == 0 ) {
         return NULL; // no more data ?
       }