[vlc-commits] demux: mp4: don't expect cdat/cdt2 pair for eia608

Francois Cartegnie git at videolan.org
Sun Jun 14 16:03:32 CEST 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sun Jun 14 16:00:08 2015 +0200| [bbe499581f042f108066f782bac7a8f2d325fa35] | committer: Francois Cartegnie

demux: mp4: don't expect cdat/cdt2 pair for eia608

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

 modules/demux/mp4/mp4.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index b368471..15c9429 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -430,13 +430,14 @@ static block_t * MP4_EIA608_Convert( block_t * p_block )
 {
     /* Rebuild codec data from encap */
     size_t i_copied = 0;
-    size_t i_remaining = p_block->i_buffer;
+    size_t i_remaining = __MIN(p_block->i_buffer, INT64_MAX / 3);
     uint32_t i_bytes = 0;
     block_t *p_newblock;
 
+    /* always need at least 10 bytes (atom size+header+1pair)*/
     if ( i_remaining < 10 ||
          !(i_bytes = GetDWBE(p_block->p_buffer)) ||
-         (i_bytes + 8 > i_remaining) ||
+         (i_bytes > i_remaining) ||
          memcmp("cdat", &p_block->p_buffer[4], 4) ||
          !(p_newblock = block_Alloc( i_remaining * 3 - 8 )) )
     {
@@ -459,9 +460,10 @@ static block_t * MP4_EIA608_Convert( block_t * p_block )
         i_remaining -= 2;
     } while( i_bytes >= 2 );
 
+    /* cdt2 is optional */
     if ( i_remaining >= 10 &&
          (i_bytes = GetDWBE(p_read)) &&
-         (i_bytes + 8 <= i_remaining) &&
+         (i_bytes <= i_remaining) &&
          !memcmp("cdt2", &p_read[4], 4) )
     {
         p_read += 8;



More information about the vlc-commits mailing list