mp4: fix integer underflow
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 27 Jun 2019 20:19:38 +0000 (23:19 +0300)
committerSebastian Ramacher <sramacher@debian.org>
Sat, 20 Jul 2019 08:17:45 +0000 (09:17 +0100)
Reported-by: Hyeon-Ju Lee <zorurione@gmail.com>
(cherry picked from commit b2b157076d9e94df34502dd8df0787deb940e938)

Gbp-Pq: Name 0003-mp4-fix-integer-underflow.patch

modules/demux/mp4/mp4.c

index edda423bed92bf6c49971dd7011efef94b5f0bc5..0c7aa2dd5006f05e0cffa49831e747344e551c75 100644 (file)
@@ -421,11 +421,11 @@ static block_t * MP4_EIA608_Convert( block_t * p_block )
     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 > i_remaining) ||
-         memcmp("cdat", &p_block->p_buffer[4], 4) ||
-         !(p_newblock = block_Alloc( i_remaining * 3 - 8 )) )
+    i_bytes = GetDWBE(p_block->p_buffer);
+
+    if (10 < i_bytes || i_bytes < i_remaining ||
+        memcmp("cdat", &p_block->p_buffer[4], 4) ||
+        (p_newblock = block_Alloc(i_remaining * 3 - 8)) == NULL)
     {
         p_block->i_buffer = 0;
         return p_block;